mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-28 10:49:56 +02:00
Fix tests to run in py 3.9
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
FROM python:3.9-slim
|
||||
FROM python:3.9
|
||||
|
||||
# Set the working directory to /app
|
||||
WORKDIR /app
|
||||
@@ -7,6 +7,6 @@ WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Install any needed packages specified in requirements.txt
|
||||
RUN pip install poetry && poetry config virtualenvs.create false && poetry install --with test,lint,typing
|
||||
RUN pip install poetry && poetry config virtualenvs.create false && poetry install --with test,lint,typing,dev
|
||||
|
||||
RUN poetry run pytest
|
||||
|
||||
@@ -2,7 +2,7 @@ import operator
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from contextlib import contextmanager
|
||||
from typing import Annotated, Generator, TypedDict
|
||||
from typing import Annotated, Generator, Optional, TypedDict, Union
|
||||
|
||||
import pytest
|
||||
from langchain_core.runnables import RunnablePassthrough
|
||||
@@ -584,7 +584,7 @@ def test_conditional_graph() -> None:
|
||||
]
|
||||
)
|
||||
|
||||
def agent_parser(input: str) -> AgentFinish | AgentAction:
|
||||
def agent_parser(input: str) -> Union[AgentAction, AgentFinish]:
|
||||
if input.startswith("finish"):
|
||||
_, answer = input.split(":")
|
||||
return AgentFinish(return_values={"answer": answer}, log=input)
|
||||
@@ -786,7 +786,7 @@ def test_conditional_graph_state() -> None:
|
||||
|
||||
class AgentState(TypedDict):
|
||||
input: str
|
||||
agent_outcome: AgentAction | AgentFinish | None
|
||||
agent_outcome: Optional[Union[AgentAction, AgentFinish]]
|
||||
intermediate_steps: Annotated[list[tuple[AgentAction, str]], operator.add]
|
||||
|
||||
# Assemble the tools
|
||||
@@ -808,7 +808,7 @@ def test_conditional_graph_state() -> None:
|
||||
]
|
||||
)
|
||||
|
||||
def agent_parser(input: str) -> AgentFinish | AgentAction:
|
||||
def agent_parser(input: str) -> Union[AgentAction, AgentFinish]:
|
||||
if input.startswith("finish"):
|
||||
_, answer = input.split(":")
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
import asyncio
|
||||
import operator
|
||||
from contextlib import asynccontextmanager, contextmanager
|
||||
from typing import Annotated, Any, AsyncGenerator, AsyncIterator, Generator, TypedDict
|
||||
from typing import (
|
||||
Annotated,
|
||||
Any,
|
||||
AsyncGenerator,
|
||||
AsyncIterator,
|
||||
Generator,
|
||||
Optional,
|
||||
TypedDict,
|
||||
Union,
|
||||
)
|
||||
|
||||
import pytest
|
||||
from langchain_core.runnables import RunnablePassthrough
|
||||
@@ -621,7 +630,7 @@ async def test_conditional_graph() -> None:
|
||||
]
|
||||
)
|
||||
|
||||
async def agent_parser(input: str) -> AgentFinish | AgentAction:
|
||||
async def agent_parser(input: str) -> Union[AgentAction, AgentFinish]:
|
||||
if input.startswith("finish"):
|
||||
_, answer = input.split(":")
|
||||
return AgentFinish(return_values={"answer": answer}, log=input)
|
||||
@@ -831,7 +840,7 @@ async def test_conditional_graph_state() -> None:
|
||||
|
||||
class AgentState(TypedDict):
|
||||
input: str
|
||||
agent_outcome: AgentAction | AgentFinish | None
|
||||
agent_outcome: Optional[Union[AgentAction, AgentFinish]]
|
||||
intermediate_steps: Annotated[list[tuple[AgentAction, str]], operator.add]
|
||||
|
||||
# Assemble the tools
|
||||
@@ -853,7 +862,7 @@ async def test_conditional_graph_state() -> None:
|
||||
]
|
||||
)
|
||||
|
||||
def agent_parser(input: str) -> AgentFinish | AgentAction:
|
||||
def agent_parser(input: str) -> Union[AgentAction, AgentFinish]:
|
||||
if input.startswith("finish"):
|
||||
_, answer = input.split(":")
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user