Skip to content

Commit bef76b7

Browse files
docs(langgraph): Fix docstring code examples of task function (#6410)
Hi all, I found out that the sync and async code examples of the `task` function in `libs/langgraph/langgraph/func/__init__.py` have a typo: ``` Example: Sync Task ```python from langgraph.func import entrypoint, task @task def add_one(a: int) -> int: return a + 1 @entrypoint() def add_one(numbers: list[int]) -> list[int]: futures = [add_one(n) for n in numbers] results = [f.result() for f in futures] return results # Call the entrypoint add_one.invoke([1, 2, 3]) # Returns [2, 3, 4] ``` ``` Both task and entrypoint functions have the same name which gives an error. This is a small PR to fix this
1 parent a1b34ef commit bef76b7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libs/langgraph/langgraph/func/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ def task(
151151
152152
153153
@task
154-
def add_one(a: int) -> int:
154+
def add_one_task(a: int) -> int:
155155
return a + 1
156156
157157
158158
@entrypoint()
159159
def add_one(numbers: list[int]) -> list[int]:
160-
futures = [add_one(n) for n in numbers]
160+
futures = [add_one_task(n) for n in numbers]
161161
results = [f.result() for f in futures]
162162
return results
163163
@@ -173,13 +173,13 @@ def add_one(numbers: list[int]) -> list[int]:
173173
174174
175175
@task
176-
async def add_one(a: int) -> int:
176+
async def add_one_task(a: int) -> int:
177177
return a + 1
178178
179179
180180
@entrypoint()
181181
async def add_one(numbers: list[int]) -> list[int]:
182-
futures = [add_one(n) for n in numbers]
182+
futures = [add_one_task(n) for n in numbers]
183183
return asyncio.gather(*futures)
184184
185185

0 commit comments

Comments
 (0)