Fix ContentVariantTool to implement required SimpleTool abstract methods
- Add get_tool_fields() stub method (required by SimpleTool ABC) - Add prepare_prompt() implementation using chat-style prompt - Tool now successfully instantiates and can be registered - All 4 tools (chat, contentvariant, listmodels, version) working
This commit is contained in:
parent
00ab8c64b8
commit
5494b6f802
1 changed files with 19 additions and 14 deletions
|
|
@ -72,8 +72,22 @@ class ContentVariantTool(SimpleTool):
|
|||
def get_request_model(self):
|
||||
return ContentVariantRequest
|
||||
|
||||
def format_request_for_model(self, request: ContentVariantRequest) -> dict:
|
||||
"""Format the content variant request for the AI model"""
|
||||
def get_tool_fields(self) -> dict:
|
||||
"""
|
||||
Tool-specific field definitions for ContentVariant.
|
||||
|
||||
Note: This method isn't used since we override get_input_schema(),
|
||||
but it's required by the SimpleTool abstract base class.
|
||||
"""
|
||||
return {
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "Base content or topic to create variations from",
|
||||
}
|
||||
}
|
||||
|
||||
async def prepare_prompt(self, request: ContentVariantRequest) -> str:
|
||||
"""Prepare the content variant prompt"""
|
||||
prompt_parts = [f"Generate {request.variation_count} variations of this content:"]
|
||||
prompt_parts.append(f"\n**Base Content:**\n{request.content}")
|
||||
|
||||
|
|
@ -94,18 +108,9 @@ class ContentVariantTool(SimpleTool):
|
|||
"testing angles, and predicted audience responses."
|
||||
)
|
||||
|
||||
formatted_request = {
|
||||
"prompt": "\n".join(prompt_parts),
|
||||
"files": request.files or [],
|
||||
"images": request.images or [],
|
||||
"continuation_id": request.continuation_id,
|
||||
"model": request.model,
|
||||
"temperature": request.temperature,
|
||||
"thinking_mode": request.thinking_mode,
|
||||
"use_websearch": request.use_websearch,
|
||||
}
|
||||
|
||||
return formatted_request
|
||||
# Use SimpleTool's chat-style prompt preparation
|
||||
request.prompt = "\n".join(prompt_parts)
|
||||
return self.prepare_chat_style_prompt(request)
|
||||
|
||||
def get_input_schema(self) -> dict:
|
||||
"""Return the JSON schema for this tool's input"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue