Spaces:
Build error
Build error
kamaleswar Mohanta commited on
Commit ·
8291d80
1
Parent(s): e868a05
updated logging in assign workers
Browse files
src/langgraphagenticai/graph/__pycache__/graph_builder_blog.cpython-312.pyc
CHANGED
|
Binary files a/src/langgraphagenticai/graph/__pycache__/graph_builder_blog.cpython-312.pyc and b/src/langgraphagenticai/graph/__pycache__/graph_builder_blog.cpython-312.pyc differ
|
|
|
src/langgraphagenticai/nodes/__pycache__/blog_generation_node.cpython-312.pyc
CHANGED
|
Binary files a/src/langgraphagenticai/nodes/__pycache__/blog_generation_node.cpython-312.pyc and b/src/langgraphagenticai/nodes/__pycache__/blog_generation_node.cpython-312.pyc differ
|
|
|
src/langgraphagenticai/nodes/blog_generation_node.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from langgraph.graph import StateGraph, START, END
|
| 2 |
from langgraph.constants import Send
|
| 3 |
-
from src.langgraphagenticai.state.state import State,
|
| 4 |
from langchain_core.messages import SystemMessage, HumanMessage
|
| 5 |
import streamlit as st
|
| 6 |
import json
|
|
@@ -299,13 +299,15 @@ class BlogGenerationNode:
|
|
| 299 |
logger.info(f"Orchestrator returning: {return_state}")
|
| 300 |
return return_state
|
| 301 |
@log_entry_exit
|
| 302 |
-
def llm_call(self, state:
|
| 303 |
"""Worker writes a section of the report."""
|
| 304 |
section = self.llm.invoke([
|
| 305 |
SystemMessage(content="Write a report section following the provided name and description. Include no preamble for each section. Use markdown formatting."),
|
| 306 |
HumanMessage(content=f"Here is the section name: {state['section'].name} and description: {state['section'].description}")
|
| 307 |
])
|
| 308 |
logger.info(f"\n{'='*20}:llm_call output:{'='*20}\nGenerated section: {section.content}\n{'='*20}\n")
|
|
|
|
|
|
|
| 309 |
return {"completed_sections": state.get("completed_sections", []) + [section.content]}
|
| 310 |
|
| 311 |
@log_entry_exit
|
|
@@ -334,13 +336,6 @@ class BlogGenerationNode:
|
|
| 334 |
initial_draft = "\n\n---\n\n".join(completed_sections)
|
| 335 |
logger.info(f"Synthesized report:\n {initial_draft}")
|
| 336 |
|
| 337 |
-
|
| 338 |
-
logger.info("SYNTHESIZER DEBUG:")
|
| 339 |
-
logger.info(f"completed_sections count: {len(completed_sections)}")
|
| 340 |
-
for i, section in enumerate(completed_sections):
|
| 341 |
-
logger.info(f"Section {i+1}:\n{section}\n{'='*20}")
|
| 342 |
-
|
| 343 |
-
|
| 344 |
# Return the generated draft AND explicitly return an empty list
|
| 345 |
# for completed_sections to update the state, clearing the old sections.
|
| 346 |
return {
|
|
@@ -394,6 +389,11 @@ class BlogGenerationNode:
|
|
| 394 |
@log_entry_exit # Conditional edge function to create llm_call workers
|
| 395 |
def assign_workers(self, state: State):
|
| 396 |
"""Assign a worker to each section in the plan."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
return [Send("llm_call", {"section": s}) for s in state["sections"]]
|
| 398 |
|
| 399 |
@log_entry_exit# Conditional edge for feedback loop
|
|
|
|
| 1 |
from langgraph.graph import StateGraph, START, END
|
| 2 |
from langgraph.constants import Send
|
| 3 |
+
from src.langgraphagenticai.state.state import State, Sections, Section # Import from state.py
|
| 4 |
from langchain_core.messages import SystemMessage, HumanMessage
|
| 5 |
import streamlit as st
|
| 6 |
import json
|
|
|
|
| 299 |
logger.info(f"Orchestrator returning: {return_state}")
|
| 300 |
return return_state
|
| 301 |
@log_entry_exit
|
| 302 |
+
def llm_call(self, state: State) -> dict:
|
| 303 |
"""Worker writes a section of the report."""
|
| 304 |
section = self.llm.invoke([
|
| 305 |
SystemMessage(content="Write a report section following the provided name and description. Include no preamble for each section. Use markdown formatting."),
|
| 306 |
HumanMessage(content=f"Here is the section name: {state['section'].name} and description: {state['section'].description}")
|
| 307 |
])
|
| 308 |
logger.info(f"\n{'='*20}:llm_call output:{'='*20}\nGenerated section: {section.content}\n{'='*20}\n")
|
| 309 |
+
logger.info(f"\n---------------------state[completed_sections]:---------------------------- \n{state.get('completed_sections', [])}")
|
| 310 |
+
|
| 311 |
return {"completed_sections": state.get("completed_sections", []) + [section.content]}
|
| 312 |
|
| 313 |
@log_entry_exit
|
|
|
|
| 336 |
initial_draft = "\n\n---\n\n".join(completed_sections)
|
| 337 |
logger.info(f"Synthesized report:\n {initial_draft}")
|
| 338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
# Return the generated draft AND explicitly return an empty list
|
| 340 |
# for completed_sections to update the state, clearing the old sections.
|
| 341 |
return {
|
|
|
|
| 389 |
@log_entry_exit # Conditional edge function to create llm_call workers
|
| 390 |
def assign_workers(self, state: State):
|
| 391 |
"""Assign a worker to each section in the plan."""
|
| 392 |
+
logger.info(f"\n{'='*10} State before assigning workers {'='*10}")
|
| 393 |
+
logger.info(f" Current sections plan: {len(state.get('sections', []))} sections")
|
| 394 |
+
# Log the completed_sections list specifically
|
| 395 |
+
logger.info(f" Completed Sections before dispatch: {state.get('completed_sections', [])}")
|
| 396 |
+
logger.info(f"{'='*40}\n")
|
| 397 |
return [Send("llm_call", {"section": s}) for s in state["sections"]]
|
| 398 |
|
| 399 |
@log_entry_exit# Conditional edge for feedback loop
|
src/langgraphagenticai/state/state.py
CHANGED
|
@@ -33,7 +33,3 @@ class State(TypedDict):
|
|
| 33 |
final_report: str # Final report
|
| 34 |
draft_approved: bool # Whether the draft is approved
|
| 35 |
|
| 36 |
-
# Worker state
|
| 37 |
-
class WorkerState(TypedDict):
|
| 38 |
-
section: Section
|
| 39 |
-
completed_sections: Annotated[List[str], operator.add]
|
|
|
|
| 33 |
final_report: str # Final report
|
| 34 |
draft_approved: bool # Whether the draft is approved
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|