Skip to content

Commit ead19c7

Browse files
committed
feat(langgraph-py): several fixes
1 parent 4e1c8ff commit ead19c7

File tree

17 files changed

+2762
-1254
lines changed

17 files changed

+2762
-1254
lines changed

typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
LangGraphPlatformMessage,
1515
PredictStateTool
1616
)
17+
from .endpoint import add_langgraph_fastapi_endpoint
1718

1819
__all__ = [
1920
"LangGraphAgent",
@@ -29,5 +30,6 @@
2930
"LangGraphPlatformResultMessage",
3031
"LangGraphPlatformActionExecutionMessage",
3132
"LangGraphPlatformMessage",
32-
"PredictStateTool"
33+
"PredictStateTool",
34+
"add_langgraph_fastapi_endpoint"
3335
]

typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import json
33
from typing import Optional, List, Any, Union, AsyncGenerator, Generator
44

5-
from fastapi.responses import StreamingResponse
6-
7-
from langgraph.graph.graph import CompiledGraph
5+
from langgraph.graph.state import CompiledStateGraph
86
from langchain.schema import BaseMessage, SystemMessage
97
from langchain_core.runnables import RunnableConfig, ensure_config
108
from langchain_core.messages import HumanMessage
@@ -78,13 +76,14 @@
7876
]
7977

8078
class LangGraphAgent:
81-
def __init__(self, *, name: str, graph: CompiledGraph, description: Optional[str] = None, config: Union[Optional[RunnableConfig], dict] = None):
79+
def __init__(self, *, name: str, graph: CompiledStateGraph, description: Optional[str] = None, config: Union[Optional[RunnableConfig], dict] = None):
8280
self.name = name
8381
self.description = description
8482
self.graph = graph
8583
self.config = config or {}
8684
self.messages_in_process: MessagesInProgressRecord = {}
8785
self.active_run: Optional[RunMetadata] = None
86+
self.constant_schema_keys = ['messages', 'tools']
8887

8988
def _dispatch_event(self, event: ProcessedEvents) -> str:
9089
return event # Fallback if no encoder
@@ -352,7 +351,6 @@ def set_message_in_progress(self, run_id: str, data: MessageInProgress):
352351
}
353352

354353
def get_schema_keys(self, config) -> SchemaKeys:
355-
CONSTANT_KEYS = ['messages']
356354
try:
357355
input_schema = self.graph.get_input_jsonschema(config)
358356
output_schema = self.graph.get_output_jsonschema(config)
@@ -363,14 +361,14 @@ def get_schema_keys(self, config) -> SchemaKeys:
363361
config_schema_keys = list(config_schema["properties"].keys()) if "properties" in config_schema else []
364362

365363
return {
366-
"input": [*input_schema_keys, *CONSTANT_KEYS],
367-
"output": [*output_schema_keys, *CONSTANT_KEYS],
364+
"input": [*input_schema_keys, *self.constant_schema_keys],
365+
"output": [*output_schema_keys, *self.constant_schema_keys],
368366
"config": config_schema_keys,
369367
}
370368
except Exception:
371369
return {
372-
"input": CONSTANT_KEYS,
373-
"output": CONSTANT_KEYS,
370+
"input": self.constant_schema_keys,
371+
"output": self.constant_schema_keys,
374372
"config": [],
375373
}
376374

File renamed without changes.
File renamed without changes.

typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/examples/agents/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/dojo.py renamed to typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/examples/agents/dojo.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
from dotenv import load_dotenv
66
load_dotenv()
77

8-
from .endpoint import add_langgraph_fastapi_endpoint
9-
from .agent import LangGraphAgent
10-
from .examples.human_in_the_loop import human_in_the_loop_graph
11-
from .examples.predictive_state_updates import predictive_state_updates_graph
12-
from .examples.shared_state import shared_state_graph
13-
from .examples.tool_based_generative_ui import tool_based_generative_ui_graph
14-
from .examples.agentic_chat import agentic_chat_graph
15-
from .examples.agentic_generative_ui import graph
8+
from ag_ui_langgraph import LangGraphAgent, add_langgraph_fastapi_endpoint
9+
from .human_in_the_loop import human_in_the_loop_graph
10+
from .predictive_state_updates import predictive_state_updates_graph
11+
from .shared_state import shared_state_graph
12+
from .tool_based_generative_ui import tool_based_generative_ui_graph
13+
from .agentic_chat import agentic_chat_graph
14+
from .agentic_generative_ui import graph
1615

1716
app = FastAPI(title="LangGraph Dojo Example Server")
1817

@@ -90,7 +89,7 @@ def main():
9089
"""Run the uvicorn server."""
9190
port = int(os.getenv("PORT", "8000"))
9291
uvicorn.run(
93-
"ag_ui_langgraph.dojo:app",
92+
"agents.dojo:app",
9493
host="0.0.0.0",
9594
port=port,
9695
reload=True
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)