Skip to content

Commit

Permalink
hotfix(agents-api): Fix broken handler partial for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorrr committed Jan 10, 2025
1 parent dd4aa7d commit 1a0beab
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions agents-api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
notebooks/

# Local database files
temporal.db
*.bak
Expand Down
9 changes: 9 additions & 0 deletions agents-api/agents_api/activities/execute_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ async def execute_system(
system: SystemDef,
) -> Any:
"""Execute a system call with the appropriate handler and transformed arguments."""

connection_pool = getattr(container.state, "postgres_pool", None) or getattr(
app.state, "postgres_pool", None
)

# FIXME: Remove
assert connection_pool is not None

arguments: dict[str, Any] = system.arguments or {}

connection_pool = getattr(app.state, "postgres_pool", None)
Expand All @@ -55,6 +63,7 @@ async def execute_system(
arguments[field] = UUID(arguments[field])

try:
# Partial with connection pool
handler = get_handler(system)
handler = partial(handler, connection_pool=connection_pool)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ async def transition_step(
raise ValueError(msg)

# Create transition
# FIXME: Remove
assert container.state.postgres_pool is not None
try:
transition = await create_execution_transition(
developer_id=context.execution_input.developer_id,
Expand Down
2 changes: 2 additions & 0 deletions agents-api/agents_api/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ def get_handler(system: SystemDef) -> Callable:
from ..queries.users.get_user import get_user as get_user_query
from ..queries.users.list_users import list_users as list_users_query
from ..queries.users.update_user import update_user as update_user_query

# FIXME: Do not use routes directly;
from ..routers.docs.create_doc import create_agent_doc, create_user_doc
from ..routers.docs.search_docs import search_agent_docs, search_user_docs
from ..routers.sessions.chat import chat
Expand Down
3 changes: 2 additions & 1 deletion agents-api/agents_api/routers/docs/create_doc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated
from typing import Annotated, Any
from uuid import UUID

from fastapi import Depends
Expand All @@ -15,6 +15,7 @@ async def create_user_doc(
user_id: UUID,
data: CreateDocRequest,
x_developer_id: Annotated[UUID, Depends(get_developer_id)],
connection_pool: Any = None, # FIXME: Placeholder that should be removed
) -> ResourceCreatedResponse:
"""
Creates a new document for a user.
Expand Down
1 change: 1 addition & 0 deletions agents-api/agents_api/routers/docs/search_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async def search_user_docs(
x_developer_id: Annotated[UUID, Depends(get_developer_id)],
search_params: (TextOnlyDocSearchRequest | VectorDocSearchRequest | HybridDocSearchRequest),
user_id: UUID,
connection_pool: Any = None, # FIXME: Placeholder that should be removed
) -> DocSearchResponse:
"""
Searches for documents associated with a specific user.
Expand Down
3 changes: 2 additions & 1 deletion agents-api/agents_api/routers/sessions/chat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated
from typing import Annotated, Any
from uuid import UUID

from fastapi import BackgroundTasks, Depends, Header, HTTPException, status
Expand Down Expand Up @@ -40,6 +40,7 @@ async def chat(
chat_input: ChatInput,
background_tasks: BackgroundTasks,
x_custom_api_key: str | None = Header(None, alias="X-Custom-Api-Key"),
connection_pool: Any = None, # FIXME: Placeholder that should be removed
) -> ChatResponse:
"""
Initiates a chat session.
Expand Down

0 comments on commit 1a0beab

Please sign in to comment.