Skip to content

Commit dedf931

Browse files
committed
Update all samples to match SDK PR #1448 API
- graphs parameter is now a list, not a dict - No graph()/entrypoint() lookup functions — reference objects directly - No entrypoints parameter on LangGraphPlugin - Use set_cache()/get_cache() for continue-as-new caching - Update tests and READMEs accordingly
1 parent 67d1310 commit dedf931

36 files changed

Lines changed: 80 additions & 125 deletions

langgraph_plugin/functional_api/continue_as_new/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
PipelineFunctionalWorkflow,
1212
activity_options,
1313
all_tasks,
14-
pipeline_entrypoint,
1514
)
1615

1716

1817
async def main() -> None:
1918
client = await Client.connect(os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"))
2019
plugin = LangGraphPlugin(
21-
entrypoints={"pipeline": pipeline_entrypoint},
2220
tasks=all_tasks,
2321
activity_options=activity_options,
2422
)

langgraph_plugin/functional_api/continue_as_new/workflow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from langgraph.func import entrypoint as lg_entrypoint
1111
from langgraph.func import task
1212
from temporalio import workflow
13-
from temporalio.contrib.langgraph import entrypoint, get_cache
13+
from temporalio.contrib.langgraph import get_cache, set_cache
1414

1515

1616
@task
@@ -65,9 +65,8 @@ class PipelineFunctionalWorkflow:
6565

6666
@workflow.run
6767
async def run(self, input_data: PipelineInput) -> dict[str, Any]:
68-
result = await entrypoint("pipeline", cache=input_data.cache).ainvoke(
69-
input_data.data
70-
)
68+
set_cache(input_data.cache)
69+
result = await pipeline_entrypoint.ainvoke(input_data.data)
7170

7271
if input_data.phase < 3:
7372
workflow.continue_as_new(

langgraph_plugin/functional_api/control_flow/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
ControlFlowWorkflow,
1212
activity_options,
1313
all_tasks,
14-
control_flow_pipeline,
1514
)
1615

1716

1817
async def main() -> None:
1918
client = await Client.connect(os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"))
2019
plugin = LangGraphPlugin(
21-
entrypoints={"control_flow": control_flow_pipeline},
2220
tasks=all_tasks,
2321
activity_options=activity_options,
2422
)

langgraph_plugin/functional_api/control_flow/workflow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from langgraph.func import entrypoint as lg_entrypoint
1212
from langgraph.func import task
1313
from temporalio import workflow
14-
from temporalio.contrib.langgraph import entrypoint
1514

1615

1716
@task
@@ -93,4 +92,4 @@ async def control_flow_pipeline(items: list[str]) -> dict:
9392
class ControlFlowWorkflow:
9493
@workflow.run
9594
async def run(self, items: list[str]) -> dict:
96-
return await entrypoint("control_flow").ainvoke(items)
95+
return await control_flow_pipeline.ainvoke(items)

langgraph_plugin/functional_api/hello_world/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
HelloWorldFunctionalWorkflow,
1212
activity_options,
1313
all_tasks,
14-
hello_entrypoint,
1514
)
1615

1716

1817
async def main() -> None:
1918
client = await Client.connect(os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"))
2019
plugin = LangGraphPlugin(
21-
entrypoints={"hello-world": hello_entrypoint},
2220
tasks=all_tasks,
2321
activity_options=activity_options,
2422
)

langgraph_plugin/functional_api/hello_world/workflow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from langgraph.func import entrypoint as lg_entrypoint
99
from langgraph.func import task
1010
from temporalio import workflow
11-
from temporalio.contrib.langgraph import entrypoint
1211

1312

1413
@task
@@ -36,4 +35,4 @@ async def hello_entrypoint(query: str) -> dict:
3635
class HelloWorldFunctionalWorkflow:
3736
@workflow.run
3837
async def run(self, query: str) -> dict:
39-
return await entrypoint("hello-world").ainvoke(query)
38+
return await hello_entrypoint.ainvoke(query)

langgraph_plugin/functional_api/human_in_the_loop/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
ChatbotFunctionalWorkflow,
1212
activity_options,
1313
all_tasks,
14-
chatbot_entrypoint,
1514
)
1615

1716

1817
async def main() -> None:
1918
client = await Client.connect(os.environ.get("TEMPORAL_ADDRESS", "localhost:7233"))
2019
plugin = LangGraphPlugin(
21-
entrypoints={"chatbot": chatbot_entrypoint},
2220
tasks=all_tasks,
2321
activity_options=activity_options,
2422
)

langgraph_plugin/functional_api/human_in_the_loop/workflow.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from langgraph.func import task
1313
from langgraph.types import Command, interrupt
1414
from temporalio import workflow
15-
from temporalio.contrib.langgraph import entrypoint
1615

1716

1817
@task
@@ -67,22 +66,21 @@ def get_draft(self) -> str | None:
6766

6867
@workflow.run
6968
async def run(self, user_message: str) -> dict[str, Any]:
70-
app = entrypoint("chatbot")
71-
app.checkpointer = InMemorySaver()
69+
chatbot_entrypoint.checkpointer = InMemorySaver()
7270
config = RunnableConfig(
7371
{"configurable": {"thread_id": workflow.info().workflow_id}}
7472
)
7573

7674
# First invocation: runs until interrupt() pauses for human review
77-
result = await app.ainvoke(user_message, config, version="v2")
75+
result = await chatbot_entrypoint.ainvoke(user_message, config, version="v2")
7876

7977
self._draft = result.interrupts[0].value
8078

8179
# Wait for human feedback via Temporal signal
8280
await workflow.wait_condition(lambda: self._human_input is not None)
8381

8482
# Resume with the human's feedback
85-
resumed = await app.ainvoke(
83+
resumed = await chatbot_entrypoint.ainvoke(
8684
Command(resume=self._human_input), config, version="v2"
8785
)
8886
return resumed.value

langgraph_plugin/functional_api/langsmith_tracing/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
ChatFunctionalWorkflow,
1616
activity_options,
1717
all_tasks,
18-
chat_entrypoint,
1918
)
2019

2120

@@ -31,7 +30,6 @@ async def main() -> None:
3130
workflows=[ChatFunctionalWorkflow],
3231
plugins=[
3332
LangGraphPlugin(
34-
entrypoints={"chat": chat_entrypoint},
3533
tasks=all_tasks,
3634
activity_options=activity_options,
3735
)

langgraph_plugin/functional_api/langsmith_tracing/workflow.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from langgraph.func import task
1414
from langsmith import traceable
1515
from temporalio import workflow
16-
from temporalio.contrib.langgraph import entrypoint
1716

1817
from langchain.chat_models import init_chat_model
1918

@@ -45,4 +44,4 @@ async def chat_entrypoint(message: str) -> dict:
4544
class ChatFunctionalWorkflow:
4645
@workflow.run
4746
async def run(self, message: str) -> dict:
48-
return await entrypoint("chat").ainvoke(message)
47+
return await chat_entrypoint.ainvoke(message)

0 commit comments

Comments
 (0)