fix: patch bug in pydantic request model for /v1/tools/run (#2152)
This commit is contained in:
@@ -209,7 +209,7 @@ class ToolRun(LettaBase):
|
||||
|
||||
|
||||
class ToolRunFromSource(LettaBase):
|
||||
source_code: str = Field(..., description="The source code of the function.")
|
||||
args: str = Field(..., description="The arguments to pass to the tool (as stringified JSON).")
|
||||
name: Optional[str] = Field(..., description="The name of the tool to run.")
|
||||
source_code: str = Field(None, description="The source code of the function.")
|
||||
name: Optional[str] = Field(None, description="The name of the tool to run.")
|
||||
source_type: Optional[str] = Field(None, description="The type of the source code.")
|
||||
|
||||
@@ -186,13 +186,27 @@ def run_tool_from_source(
|
||||
"""
|
||||
actor = server.get_user_or_default(user_id=user_id)
|
||||
|
||||
return server.run_tool_from_source(
|
||||
tool_source=request.source_code,
|
||||
tool_source_type=request.source_type,
|
||||
tool_args=request.args,
|
||||
tool_name=request.name,
|
||||
user_id=actor.id,
|
||||
)
|
||||
try:
|
||||
return server.run_tool_from_source(
|
||||
tool_source=request.source_code,
|
||||
tool_source_type=request.source_type,
|
||||
tool_args=request.args,
|
||||
tool_name=request.name,
|
||||
user_id=actor.id,
|
||||
)
|
||||
except LettaToolCreateError as e:
|
||||
# HTTP 400 == Bad Request
|
||||
print(f"Error occurred during tool creation: {e}")
|
||||
# print the full stack trace
|
||||
import traceback
|
||||
|
||||
print(traceback.format_exc())
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
except Exception as e:
|
||||
# Catch other unexpected errors and raise an internal server error
|
||||
print(f"Unexpected error occurred: {e}")
|
||||
raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
|
||||
|
||||
|
||||
# Specific routes for Composio
|
||||
|
||||
Reference in New Issue
Block a user