Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eyurtsev committed Jan 29, 2025
1 parent 005dde7 commit 22721fa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions backend/app/api/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import langsmith.client
from fastapi import APIRouter, BackgroundTasks, HTTPException
from fastapi.exceptions import RequestValidationError
from pydantic import ValidationError
from langchain_core.messages import AnyMessage
from langchain_core.runnables import RunnableConfig
from langsmith.utils import tracing_is_enabled
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, ValidationError
from sse_starlette import EventSourceResponse

from app.agent import agent, chat_retrieval, chatbot
Expand Down
2 changes: 1 addition & 1 deletion backend/app/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def setup(self) -> None:
pool = AsyncConnectionPool(
conninfo=conninfo,
kwargs={"autocommit": True, "prepare_threshold": 0},
open=False # Don't open in constructor
open=False, # Don't open in constructor
)
await pool.open()

Expand Down
1 change: 1 addition & 0 deletions backend/app/lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import orjson
import structlog
from fastapi import FastAPI

from app.checkpoint import AsyncPostgresCheckpoint

_pg_pool = None
Expand Down
7 changes: 4 additions & 3 deletions backend/app/message_types.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
from typing import Any

from langchain_core.messages import (
FunctionMessage,
MessageLikeRepresentation,
ToolMessage,
_message_from_dict,
)
from langgraph.graph.message import Messages, add_messages
from langchain_core.messages import _message_from_dict
from pydantic import Field


class LiberalFunctionMessage(FunctionMessage):
content: Any = Field(default="")
content: Any = Field(default="")


class LiberalToolMessage(ToolMessage):
content: Any = Field(default="")


def _convert_pydantic_dict_to_message(
data: MessageLikeRepresentation
data: MessageLikeRepresentation,
) -> MessageLikeRepresentation:
"""Convert a dictionary to a message object if it matches message format."""
if (
Expand Down
10 changes: 6 additions & 4 deletions backend/app/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def get_thread_state(*, user_id: str, thread_id: str, assistant: Assistant
)
# Keep original format - return values as is
values = state.values if state.values else None

return {
"values": values,
"next": state.next,
Expand All @@ -151,7 +151,7 @@ async def update_thread_state(
}
}
)

# If current state is a dict (retrieval agent), maintain dict structure
if current_state.values and isinstance(current_state.values, dict):
if isinstance(values, dict):
Expand All @@ -161,8 +161,10 @@ async def update_thread_state(
state_values = {**current_state.values, "messages": values}
else:
# For message-only states (tools_agent, chatbot), just use the messages
state_values = values if isinstance(values, dict) and "messages" in values else values

state_values = (
values if isinstance(values, dict) and "messages" in values else values
)

await agent.aupdate_state(
{
"configurable": {
Expand Down

0 comments on commit 22721fa

Please sign in to comment.