Fix tests to run in py 3.9

This commit is contained in:
Nuno Campos
2024-01-15 13:18:32 -08:00
parent f6894fb5dd
commit 23f84c9ac9
3 changed files with 19 additions and 10 deletions
+2 -2
View File
@@ -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
+4 -4
View File
@@ -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 {
+13 -4
View File
@@ -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 {