Skip to content

Commit

Permalink
fix: Apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Aug 10, 2024
1 parent 0ee50d4 commit 4e6656c
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 113 deletions.
2 changes: 1 addition & 1 deletion agents-api/agents_api/autogen/Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Annotated, Literal
from uuid import UUID

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field
from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel

from .Docs import DocReference
from .Entries import ChatMLMessage
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/autogen/Entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Annotated, Literal
from uuid import UUID

from pydantic import AnyUrl, AwareDatetime, BaseModel, ConfigDict, Field
from pydantic import AnyUrl, AwareDatetime, BaseModel, ConfigDict, Field, RootModel

from .Tools import ChosenToolCall, Tool, ToolResponse

Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/models/agent/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_agent(
if isinstance(data.instructions, list)
else [data.instructions]
)
data.default_settings = data.default_settings or {}
data.default_settings = data.default_settings

agent_data = data.model_dump(exclude_unset=True)
default_settings = agent_data.pop("default_settings")
Expand Down
6 changes: 5 additions & 1 deletion agents-api/agents_api/models/agent/update_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def update_agent(
Returns:
ResourceUpdatedResponse: The updated agent data.
"""
default_settings = data.default_settings.model_dump(exclude_none=True)
default_settings = (
data.default_settings.model_dump(exclude_none=True)
if data.default_settings
else {}
)
update_data = data.model_dump()

# Remove default settings from the agent update data
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/routers/agents/create_agent_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ async def create_agent_tool(
developer_id=x_developer_id,
agent_id=agent_id,
data=[data],
)
)[0]

return ResourceCreatedResponse(id=tool.id, created_at=tool.created_at)
1 change: 1 addition & 0 deletions agents-api/agents_api/routers/sessions/create_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ async def create_session(
return ResourceCreatedResponse(
id=session.id,
created_at=session.created_at,
jobs=[],
)
4 changes: 2 additions & 2 deletions agents-api/agents_api/routers/sessions/get_session_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import Depends
from pydantic import UUID4

from ...autogen.openapi_model import Session
from ...autogen.openapi_model import History
from ...dependencies.developer_id import get_developer_id
from ...models.entry.get_history import get_history as get_history_query
from .router import router
Expand All @@ -12,5 +12,5 @@
@router.get("/sessions/{session_id}/history", tags=["sessions"])
async def get_session_history(
session_id: UUID4, x_developer_id: Annotated[UUID4, Depends(get_developer_id)]
) -> Session:
) -> History:
return get_history_query(developer_id=x_developer_id, session_id=session_id)
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ async def create_or_update_user(
data=data,
)

return ResourceCreatedResponse(id=user.id, created_at=user.created_at)
return ResourceCreatedResponse(id=user.id, created_at=user.created_at, jobs=[])
2 changes: 1 addition & 1 deletion agents-api/agents_api/routers/users/update_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ async def update_user(
return update_user_query(
developer_id=x_developer_id,
user_id=user_id,
data=data,
update_user=data,
)
16 changes: 13 additions & 3 deletions agents-api/agents_api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sentry_sdk
import uvicorn
from fastapi import Depends, FastAPI, Request, status
from fastapi.exceptions import RequestValidationError
from fastapi.exceptions import HTTPException, RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from litellm.exceptions import APIError
Expand All @@ -21,6 +21,8 @@
from agents_api.exceptions import PromptTooBigError
from agents_api.routers import (
agents,
jobs,
sessions,
tasks,
users,
)
Expand Down Expand Up @@ -88,12 +90,20 @@ def register_exceptions(app: FastAPI):
register_exceptions(app)

app.include_router(agents.router)
# app.include_router(sessions.router)
app.include_router(sessions.router)
app.include_router(users.router)
# app.include_router(jobs.router)
app.include_router(jobs.router)
app.include_router(tasks.router)


@app.exception_handler(HTTPException)
async def http_exception_handler(request, exc: HTTPException): # pylint: disable=unused-argument
return JSONResponse(
status_code=exc.status_code,
content={"error": {"message": str(exc)}},
)


@app.exception_handler(RPCError)
async def validation_error_handler(request: Request, exc: RPCError):
return JSONResponse(
Expand Down
22 changes: 11 additions & 11 deletions agents-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/generate_openapi_code.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd typespec/ && \
tsp compile .
cd -

fern generate --local
fern generate

cd sdks/python && \
poetry update && \
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/julep/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@
ToolsChosenToolCall_Function,
ToolsFunctionCallOption,
ToolsFunctionDef,
ToolsFunctionDefUpdate,
ToolsFunctionTool,
ToolsNamedFunctionChoice,
ToolsNamedToolChoice,
Expand Down Expand Up @@ -412,7 +411,6 @@
"ToolsChosenToolCall_Function",
"ToolsFunctionCallOption",
"ToolsFunctionDef",
"ToolsFunctionDefUpdate",
"ToolsFunctionTool",
"ToolsNamedFunctionChoice",
"ToolsNamedToolChoice",
Expand Down
9 changes: 4 additions & 5 deletions sdks/python/julep/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
from .types.tasks_task_tool import TasksTaskTool
from .types.tasks_update_task_request_main_item import TasksUpdateTaskRequestMainItem
from .types.tools_function_def import ToolsFunctionDef
from .types.tools_function_def_update import ToolsFunctionDefUpdate
from .types.tools_tool_type import ToolsToolType
from .types.user_docs_route_list_request_direction import (
UserDocsRouteListRequestDirection,
Expand Down Expand Up @@ -1585,7 +1584,7 @@ def agent_tools_route_patch(
*,
type: typing.Optional[ToolsToolType] = OMIT,
name: typing.Optional[CommonValidPythonIdentifier] = OMIT,
function: typing.Optional[ToolsFunctionDefUpdate] = OMIT,
function: typing.Optional[ToolsFunctionDef] = OMIT,
integration: typing.Optional[typing.Any] = OMIT,
system: typing.Optional[typing.Any] = OMIT,
api_call: typing.Optional[typing.Any] = OMIT,
Expand All @@ -1608,7 +1607,7 @@ def agent_tools_route_patch(
name : typing.Optional[CommonValidPythonIdentifier]
Name of the tool (must be unique for this agent and a valid python identifier string )
function : typing.Optional[ToolsFunctionDefUpdate]
function : typing.Optional[ToolsFunctionDef]
integration : typing.Optional[typing.Any]
Expand Down Expand Up @@ -5177,7 +5176,7 @@ async def agent_tools_route_patch(
*,
type: typing.Optional[ToolsToolType] = OMIT,
name: typing.Optional[CommonValidPythonIdentifier] = OMIT,
function: typing.Optional[ToolsFunctionDefUpdate] = OMIT,
function: typing.Optional[ToolsFunctionDef] = OMIT,
integration: typing.Optional[typing.Any] = OMIT,
system: typing.Optional[typing.Any] = OMIT,
api_call: typing.Optional[typing.Any] = OMIT,
Expand All @@ -5200,7 +5199,7 @@ async def agent_tools_route_patch(
name : typing.Optional[CommonValidPythonIdentifier]
Name of the tool (must be unique for this agent and a valid python identifier string )
function : typing.Optional[ToolsFunctionDefUpdate]
function : typing.Optional[ToolsFunctionDef]
integration : typing.Optional[typing.Any]
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/julep/api/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ client.agent_tools_route_patch(
<dl>
<dd>

**function:** `typing.Optional[ToolsFunctionDefUpdate]`
**function:** `typing.Optional[ToolsFunctionDef]`

</dd>
</dl>
Expand Down
2 changes: 0 additions & 2 deletions sdks/python/julep/api/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
from .tools_chosen_tool_call import ToolsChosenToolCall, ToolsChosenToolCall_Function
from .tools_function_call_option import ToolsFunctionCallOption
from .tools_function_def import ToolsFunctionDef
from .tools_function_def_update import ToolsFunctionDefUpdate
from .tools_function_tool import ToolsFunctionTool
from .tools_named_function_choice import ToolsNamedFunctionChoice
from .tools_named_tool_choice import ToolsNamedToolChoice, ToolsNamedToolChoice_Function
Expand Down Expand Up @@ -467,7 +466,6 @@
"ToolsChosenToolCall_Function",
"ToolsFunctionCallOption",
"ToolsFunctionDef",
"ToolsFunctionDefUpdate",
"ToolsFunctionTool",
"ToolsNamedFunctionChoice",
"ToolsNamedToolChoice",
Expand Down
11 changes: 4 additions & 7 deletions sdks/python/julep/api/types/tools_function_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@
from ..core.datetime_utils import serialize_datetime
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from .common_identifier_safe_unicode import CommonIdentifierSafeUnicode
from .common_valid_python_identifier import CommonValidPythonIdentifier


class ToolsFunctionDef(pydantic_v1.BaseModel):
"""
Function definition
"""

name: typing.Optional[CommonValidPythonIdentifier] = pydantic_v1.Field(default=None)
"""
DO NOT USE: This will be overriden by the tool name. Here only for compatibility reasons.
"""

name: typing.Optional[typing.Any] = None
description: typing.Optional[CommonIdentifierSafeUnicode] = pydantic_v1.Field(
default=None
)
"""
Description of the function
"""

parameters: typing.Dict[str, typing.Any] = pydantic_v1.Field()
parameters: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(
default=None
)
"""
The parameters the function accepts
"""
Expand Down
65 changes: 0 additions & 65 deletions sdks/python/julep/api/types/tools_function_def_update.py

This file was deleted.

Loading

0 comments on commit 4e6656c

Please sign in to comment.