Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion validator_api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import json
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, model_validator


class CompletionsRequest(BaseModel):
"""Request model for the /v1/chat/completions endpoint."""

@model_validator(mode="after")
def add_tools(self):
if self.tools:
self.messages.append({"role": "tool", "content": json.dumps(self.tools)})
return self

uids: Optional[List[int]] = Field(
default=None,
description="List of specific miner UIDs to query. If not provided, miners will be selected automatically.",
Expand Down Expand Up @@ -59,6 +66,21 @@ class CompletionsRequest(BaseModel):
)
json_format: bool = Field(default=False, description="Enable JSON format for the response.", example=True)
stream: bool = Field(default=False, description="Enable streaming for the response.", example=True)
tools: Optional[List[Dict[str, Any]]] = Field(
default=None,
description="List of tools to use for the task.",
# TODO: Add example that's not just from claude
example=[
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Get the current time",
"parameters": {"timezone": {"type": "string", "description": "The timezone to get the time in"}},
},
}
],
)


class WebRetrievalRequest(BaseModel):
Expand Down