feat: Initial commit of LLM Tool Proxy

This commit is contained in:
Vertex-AI-Step-Builder
2025-12-31 06:35:08 +00:00
commit 0d14c98cf4
11 changed files with 775 additions and 0 deletions

41
app/models.py Normal file
View File

@@ -0,0 +1,41 @@
from pydantic import BaseModel, Field
from typing import List, Dict, Any, Optional
# Models for incoming requests
class ChatMessage(BaseModel):
"""Represents a single message in the chat history."""
role: str
content: str
class Tool(BaseModel):
"""Represents a tool definition provided by the user."""
type: str
function: Dict[str, Any]
class IncomingRequest(BaseModel):
"""Defines the structure of the request from the client."""
messages: List[ChatMessage]
tools: Optional[List[Tool]] = None
stream: Optional[bool] = False
# Models for outgoing responses
class ToolCallFunction(BaseModel):
"""Function call details within a tool call."""
name: str
arguments: str # JSON string of arguments
class ToolCall(BaseModel):
"""Represents a tool call requested by the LLM."""
id: str
type: str = "function"
function: ToolCallFunction
class ResponseMessage(BaseModel):
"""The message part of the response from the proxy."""
role: str = "assistant"
content: Optional[str] = None
tool_calls: Optional[List[ToolCall]] = None
class ProxyResponse(BaseModel):
"""Defines the final structured response sent back to the client."""
message: ResponseMessage