Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion langgraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
],
"graphs": {
"POC: Simple Agent": "./src/poc/simple_agent.py:graph",
"POC: Deep Agent": "./src/poc/deep_agent.py:graph"
"POC: Deep Agent": "./src/poc/deep_agent.py:graph",
"Walk and Learn Summary": "./src/agents/walkandlearn_summary/graph.py:graph"
},
"env": ".env"
}
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Source package."""
1 change: 1 addition & 0 deletions src/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Agents package."""
5 changes: 5 additions & 0 deletions src/agents/walkandlearn_summary/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Walk and Learn summary agent."""

from .graph import graph

__all__ = ["graph"]
85 changes: 85 additions & 0 deletions src/agents/walkandlearn_summary/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""LangGraph agent for summarizing conversations with emotional and technical summaries."""

from typing_extensions import TypedDict

from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain_core.messages import HumanMessage
from langgraph.graph import StateGraph, START, END, MessagesState

from agents.walkandlearn_summary.io import read_file, write_file, format_summary
from agents.walkandlearn_summary.prompts import EMOTIONAL_SUMMARY_PROMPT, TECHNICAL_SUMMARY_PROMPT


MODEL_NAME = "gpt-4o-mini"
MODEL_TEMPERATURE = 0

INPUT_FILE_PATH = "TODO_INPUT_FILE_PATH.txt" # TODO: Replace with actual input file path
OUTPUT_FILE_PATH = "TODO_OUTPUT_FILE_PATH.md" # TODO: Replace with actual output file path


class SummaryState(MessagesState):
conversation: str
emotional_summary: str
technical_summary: str


model = init_chat_model(MODEL_NAME, temperature=MODEL_TEMPERATURE)

emotional_agent = create_agent(
model=model,
tools=[],
system_prompt=EMOTIONAL_SUMMARY_PROMPT
)

technical_agent = create_agent(
model=model,
tools=[],
system_prompt=TECHNICAL_SUMMARY_PROMPT
)


def load_conversation_node(state: SummaryState) -> dict:
return {"conversation": read_file(INPUT_FILE_PATH)}


def emotional_summary_node(state: SummaryState) -> dict:
result = emotional_agent.invoke({
"messages": [HumanMessage(content=f"Please provide an emotional summary of the following conversation:\n\n{state['conversation']}")]
})
return {"emotional_summary": result["messages"][-1].content}


def technical_summary_node(state: SummaryState) -> dict:
# TODO: Uncomment below to enable technical agent (currently placeholder to save API costs)
return {"technical_summary": "[Technical summary placeholder - agent commented out for cost savings]"}

# result = technical_agent.invoke({
# "messages": [HumanMessage(content=f"Please provide a technical summary of the following conversation:\n\n{state['conversation']}")]
# })
# return {"technical_summary": result["messages"][-1].content}


def write_output_node(state: SummaryState) -> dict:
content = format_summary(state['emotional_summary'], state['technical_summary'])
write_file(OUTPUT_FILE_PATH, content)
return {}


graph = (
StateGraph(SummaryState)

.add_node("load_conversation", load_conversation_node)
.add_node("emotional_summary", emotional_summary_node)
.add_node("technical_summary", technical_summary_node)
.add_node("write_output", write_output_node)

.add_edge(START, "load_conversation")
.add_edge("load_conversation", "emotional_summary")
.add_edge("load_conversation", "technical_summary")
.add_edge("emotional_summary", "write_output")
.add_edge("technical_summary", "write_output")
.add_edge("write_output", END)

.compile()
)
34 changes: 34 additions & 0 deletions src/agents/walkandlearn_summary/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""File I/O utilities for the summarization workflow."""

from pathlib import Path


def read_file(file_path: str) -> str:
try:
with open(Path(file_path), "r", encoding="utf-8") as f:
return f.read()
except FileNotFoundError:
return f"File not found: {file_path}. Please set the correct file path in the configuration constants."


def write_file(file_path: str, content: str) -> None:
with open(Path(file_path), "w", encoding="utf-8") as f:
f.write(content)


def format_summary(emotional_summary: str, technical_summary: str) -> str:
return f"""# Emotional Summary

{emotional_summary}



================================================================
================================================================



# Technical Summary

{technical_summary}
"""
9 changes: 9 additions & 0 deletions src/agents/walkandlearn_summary/prompts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""System prompts for summarization agents."""

EMOTIONAL_SUMMARY_PROMPT = """You are the emotional summary agent.

TODO: Replace this placeholder with the actual system prompt for emotional summarization."""

TECHNICAL_SUMMARY_PROMPT = """You are the technical summary agent.

TODO: Replace this placeholder with the actual system prompt for technical summarization."""