Skip to content

Commit

Permalink
Make messages optional
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Nov 20, 2023
1 parent d38fafe commit d0c86b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions backend/app/api/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from langserve.serialization import WellKnownLCSerializer
from langserve.server import _get_base_run_id_as_str, _unpack_input
from langsmith.utils import tracing_is_enabled
from pydantic import BaseModel
from pydantic import BaseModel, Field
from sse_starlette import EventSourceResponse

from app.schema import OpengptsUserId
Expand All @@ -33,7 +33,7 @@
class AgentInput(BaseModel):
"""An input into an agent."""

messages: Sequence[AnyMessage]
messages: Sequence[AnyMessage] = Field(default_factory=list)


class CreateRunPayload(BaseModel):
Expand All @@ -42,8 +42,7 @@ class CreateRunPayload(BaseModel):
assistant_id: str
thread_id: str
stream: bool
# TODO make optional
input: AgentInput
input: AgentInput = Field(default_factory=AgentInput)


@router.post("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_agent_executor(
def route_last_message(input: dict[str, bool | Sequence[AnyMessage]]) -> Runnable:
if not input["messages"]:
# no messages, do nothing
return RunnablePassthrough()
return agent_chain

message: AnyMessage = input["messages"][-1]
if isinstance(message.additional_kwargs.get("agent"), AgentFinish):
Expand Down
2 changes: 1 addition & 1 deletion backend/packages/gizmo-agent/gizmo_agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(


class AgentInput(BaseModel):
messages: Sequence[AnyMessage]
messages: Sequence[AnyMessage] = Field(default_factory=list)


class AgentOutput(BaseModel):
Expand Down

0 comments on commit d0c86b6

Please sign in to comment.