Testing with qwen and updating tools
This commit is contained in:
@@ -11,7 +11,8 @@ class BaseTelegramInferenceBot(ABC):
|
|||||||
self.processing_status = {}
|
self.processing_status = {}
|
||||||
self.system_prompt = self.load_system_prompt()
|
self.system_prompt = self.load_system_prompt()
|
||||||
self.tools, self.functions = self.load_functions()
|
self.tools, self.functions = self.load_functions()
|
||||||
print(f'Github Token: {os.environ.get("GITHUB_TOKEN")}')
|
print(f'System Prompt: {os.environ.get("SYSTEM_PROMPT_PATH")}')
|
||||||
|
print(f'Github Repository: {os.environ.get("GITHUB_REPOSITORY")}')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_system_prompt():
|
def load_system_prompt():
|
||||||
@@ -59,9 +60,11 @@ class BaseTelegramInferenceBot(ABC):
|
|||||||
function_name = function_call_name
|
function_name = function_call_name
|
||||||
function_args = json.loads(function_call_arguments if function_call_arguments is not None else "{}")
|
function_args = json.loads(function_call_arguments if function_call_arguments is not None else "{}")
|
||||||
for tool in self.tools:
|
for tool in self.tools:
|
||||||
if function_name in [f["name"] for f in tool.get_functions()]:
|
for function in tool.get_functions():
|
||||||
|
if function["function"]["name"] == function_name:
|
||||||
return tool.execute(function_name, **function_args)
|
return tool.execute(function_name, **function_args)
|
||||||
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def start(self):
|
async def start(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -8,16 +8,16 @@ from openai import OpenAI
|
|||||||
class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
|
class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
self.client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"), base_url="http://localhost:1234/v1")
|
||||||
self.model = "gpt-4o-mini"
|
self.model = "qwen3-1.7b"
|
||||||
self.max_tokens = 16384
|
self.max_tokens = 32768
|
||||||
|
|
||||||
def get_chat_response(self, messages):
|
def get_chat_response(self, messages):
|
||||||
response = self.client.chat.completions.create(
|
response = self.client.chat.completions.create(
|
||||||
model=self.model,
|
model=self.model,
|
||||||
messages=[{"role": "system", "content": self.system_prompt}] + messages,
|
messages=[{"role": "system", "content": self.system_prompt}] + messages,
|
||||||
functions=self.functions,
|
tools=self.functions,
|
||||||
function_call="auto",
|
tool_choice = "auto",
|
||||||
max_tokens=self.max_tokens
|
max_tokens=self.max_tokens
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
@@ -34,8 +34,8 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
|
|||||||
tool_calls = []
|
tool_calls = []
|
||||||
|
|
||||||
for message_part in response.choices:
|
for message_part in response.choices:
|
||||||
if message_part.finish_reason == "function_call":
|
if message_part.finish_reason == "tool_calls":
|
||||||
tool_calls.append(message_part.message.function_call)
|
tool_calls.extend(message_part.message.tool_calls)
|
||||||
|
|
||||||
messages.append(response.choices[0].message)
|
messages.append(response.choices[0].message)
|
||||||
|
|
||||||
@@ -44,9 +44,13 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
|
|||||||
tool_use_results = []
|
tool_use_results = []
|
||||||
|
|
||||||
while len(tool_calls) > 0:
|
while len(tool_calls) > 0:
|
||||||
tool_call = tool_calls.pop(0)
|
tool_call = tool_calls.pop(0).function
|
||||||
tool_response = self.call_tool(tool_call.name, tool_call.arguments)
|
tool_response = self.call_tool(tool_call.name, tool_call.arguments)
|
||||||
tool_use_results.append({"role": "function", "name": tool_call.name, "content": json.dumps(tool_response)})
|
try:
|
||||||
|
tool_use_results.append({"role": "tool", "name": tool_call.name, "content": tool_response})
|
||||||
|
except (TypeError, ValueError) as e:
|
||||||
|
logging.error(f"Failed to serialize tool response: {e}")
|
||||||
|
tool_use_results.append({"role": "function", "name": tool_call.name, "content": "Serialization error"})
|
||||||
|
|
||||||
messages.extend(tool_use_results)
|
messages.extend(tool_use_results)
|
||||||
|
|
||||||
@@ -84,12 +88,12 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
|
|||||||
return "No active processing to abort."
|
return "No active processing to abort."
|
||||||
|
|
||||||
async def switch_model(self):
|
async def switch_model(self):
|
||||||
if self.model == "gpt-4o-mini":
|
if self.model == "qwen3-4b":
|
||||||
self.model = "gpt-4o"
|
self.model = "qwen3-30b-a3b"
|
||||||
self.max_tokens = 4096
|
# self.max_tokens = 4096
|
||||||
else:
|
else:
|
||||||
self.model = "gpt-4o-mini"
|
self.model = "qwen3-4b"
|
||||||
self.max_tokens = 16384
|
# self.max_tokens = 16384
|
||||||
logging.info(f"Switched to model: {self.model}")
|
logging.info(f"Switched to model: {self.model}")
|
||||||
return f"Switched to model: {self.model}"
|
return f"Switched to model: {self.model}"
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -63,7 +63,9 @@ class TelegramHelper:
|
|||||||
|
|
||||||
await context.bot.delete_message(chat_id=update.effective_chat.id, message_id=status_message.message_id)
|
await context.bot.delete_message(chat_id=update.effective_chat.id, message_id=status_message.message_id)
|
||||||
del self.bot.processing_status[user_id]
|
del self.bot.processing_status[user_id]
|
||||||
await update.message.reply_text(response)
|
response = response.replace("<think>", "<blockquote expandable><b>Thinking...</b>").replace("</think>", "</blockquote>")
|
||||||
|
# Return response as html message
|
||||||
|
await update.message.reply_html(response)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"An error occurred: {str(e)}")
|
logging.error(f"An error occurred: {str(e)}")
|
||||||
|
|||||||
+90
-5
@@ -47,6 +47,8 @@ class GitHubTool(BaseTool):
|
|||||||
def get_functions(self):
|
def get_functions(self):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "read_file",
|
"name": "read_file",
|
||||||
"description": "Read a file from the repository",
|
"description": "Read a file from the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -59,8 +61,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["path"]
|
"required": ["path"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "list_files",
|
"name": "list_files",
|
||||||
"description": "List files in a directory of the repository",
|
"description": "List files in a directory of the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -73,8 +78,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["path"]
|
"required": ["path"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "search_code",
|
"name": "search_code",
|
||||||
"description": "Search for code in the repository",
|
"description": "Search for code in the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -87,8 +95,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["query"]
|
"required": ["query"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_branch",
|
"name": "create_branch",
|
||||||
"description": "Create a new branch in the repository",
|
"description": "Create a new branch in the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -106,8 +117,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["branch_name"]
|
"required": ["branch_name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "commit_file",
|
"name": "commit_file",
|
||||||
"description": "Commit a file to a branch (not main)",
|
"description": "Commit a file to a branch (not main)",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -128,8 +142,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["file_path", "commit_message", "content"]
|
"required": ["file_path", "commit_message", "content"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_pull_request",
|
"name": "create_pull_request",
|
||||||
"description": "Create a pull request",
|
"description": "Create a pull request",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -151,8 +168,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["title", "body"]
|
"required": ["title", "body"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_commit_history",
|
"name": "get_commit_history",
|
||||||
"description": "Get commit history for a file",
|
"description": "Get commit history for a file",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -170,8 +190,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["file_path"]
|
"required": ["file_path"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_branch_sha",
|
"name": "get_branch_sha",
|
||||||
"description": "Get the SHA of the latest commit on a branch",
|
"description": "Get the SHA of the latest commit on a branch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -184,13 +207,19 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["branch"]
|
"required": ["branch"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_current_branch",
|
"name": "get_current_branch",
|
||||||
"description": "Get the name of the current branch",
|
"description": "Get the name of the current branch",
|
||||||
"parameters": {}
|
"parameters": { "type": "object", "properties": {} }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "set_current_branch",
|
"name": "set_current_branch",
|
||||||
"description": "Set the current branch",
|
"description": "Set the current branch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -203,8 +232,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["branch_name"]
|
"required": ["branch_name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_file_at_commit",
|
"name": "get_file_at_commit",
|
||||||
"description": "Get the contents of a file at a specific commit",
|
"description": "Get the contents of a file at a specific commit",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -221,8 +253,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["file_path", "commit_sha"]
|
"required": ["file_path", "commit_sha"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "list_branches",
|
"name": "list_branches",
|
||||||
"description": "List all branches in the repository",
|
"description": "List all branches in the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -240,8 +275,11 @@ class GitHubTool(BaseTool):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "approve_pull_request",
|
"name": "approve_pull_request",
|
||||||
"description": "Approve a pull request",
|
"description": "Approve a pull request",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -254,8 +292,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["pull_number"]
|
"required": ["pull_number"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "close_pull_request",
|
"name": "close_pull_request",
|
||||||
"description": "Close a pull request",
|
"description": "Close a pull request",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -268,8 +309,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["pull_number"]
|
"required": ["pull_number"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "merge_pull_request",
|
"name": "merge_pull_request",
|
||||||
"description": "Merge a pull request",
|
"description": "Merge a pull request",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -298,8 +342,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["pull_number"]
|
"required": ["pull_number"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "delete_branch",
|
"name": "delete_branch",
|
||||||
"description": "Delete a branch",
|
"description": "Delete a branch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -312,8 +359,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["branch_name"]
|
"required": ["branch_name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_issue_details",
|
"name": "get_issue_details",
|
||||||
"description": "Get details of a specific issue",
|
"description": "Get details of a specific issue",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -326,8 +376,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["issue_number"]
|
"required": ["issue_number"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_issue",
|
"name": "create_issue",
|
||||||
"description": "Create a new issue in the repository",
|
"description": "Create a new issue in the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -351,8 +404,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["title", "body"]
|
"required": ["title", "body"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "list_issues",
|
"name": "list_issues",
|
||||||
"description": "List issues in the repository",
|
"description": "List issues in the repository",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -376,8 +432,11 @@ class GitHubTool(BaseTool):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "add_issue_comment",
|
"name": "add_issue_comment",
|
||||||
"description": "Add a comment to an issue",
|
"description": "Add a comment to an issue",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -394,8 +453,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["issue_number", "comment"]
|
"required": ["issue_number", "comment"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_issue_comments",
|
"name": "get_issue_comments",
|
||||||
"description": "Get comments for an issue",
|
"description": "Get comments for an issue",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -408,8 +470,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["issue_number"]
|
"required": ["issue_number"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_project_board",
|
"name": "create_project_board",
|
||||||
"description": "Create a new project board",
|
"description": "Create a new project board",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -426,8 +491,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["name"]
|
"required": ["name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_project_column",
|
"name": "create_project_column",
|
||||||
"description": "Create a new column in a project board",
|
"description": "Create a new column in a project board",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -444,8 +512,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["project_id", "column_name"]
|
"required": ["project_id", "column_name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "create_project_card",
|
"name": "create_project_card",
|
||||||
"description": "Create a new card in a project column",
|
"description": "Create a new card in a project column",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -462,8 +533,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["column_id", "note"]
|
"required": ["column_id", "note"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "move_project_card",
|
"name": "move_project_card",
|
||||||
"description": "Move a card to a new position",
|
"description": "Move a card to a new position",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -484,8 +558,11 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["card_id", "position", "column_id"]
|
"required": ["card_id", "position", "column_id"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "link_issue_to_project_card",
|
"name": "link_issue_to_project_card",
|
||||||
"description": "Link an issue or pull request to a project card",
|
"description": "Link an issue or pull request to a project card",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -506,13 +583,19 @@ class GitHubTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["card_id", "content_id", "content_type"]
|
"required": ["card_id", "content_id", "content_type"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "list_project_boards",
|
"name": "list_project_boards",
|
||||||
"description": "List project boards associated with the repository",
|
"description": "List project boards associated with the repository",
|
||||||
"parameters": {}
|
"parameters": { "type": "object", "properties": {} }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "view_project_board_items",
|
"name": "view_project_board_items",
|
||||||
"description": "View items (columns and cards) in a specific project board",
|
"description": "View items (columns and cards) in a specific project board",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -526,6 +609,7 @@ class GitHubTool(BaseTool):
|
|||||||
"required": ["project_id"]
|
"required": ["project_id"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -712,10 +796,11 @@ class GitHubTool(BaseTool):
|
|||||||
url = f"{self.base_url}/repos/{self.repo}/contents/{path}"
|
url = f"{self.base_url}/repos/{self.repo}/contents/{path}"
|
||||||
response = requests.get(url, headers=self.headers, params={"ref": self.current_branch})
|
response = requests.get(url, headers=self.headers, params={"ref": self.current_branch})
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
files = [item["name"] for item in response.json() if item["type"] == "file"]
|
files = [{"type": "file", "name": item["name"]} for item in response.json() if item["type"] == "file"]
|
||||||
directories = [item["name"] for item in response.json() if item["type"] == "dir"]
|
directories = [{"type": "directory", "name": item["name"]} for item in response.json() if item["type"] == "dir"]
|
||||||
self.logger.info(f"Successfully listed files and directories in {path}")
|
self.logger.info(f"Successfully listed files and directories in {path}")
|
||||||
return {"files": files, "directories": directories}
|
files.extend(directories)
|
||||||
|
return files
|
||||||
else:
|
else:
|
||||||
error_message = f"Error listing files: {response.status_code}"
|
error_message = f"Error listing files: {response.status_code}"
|
||||||
self.logger.error(error_message)
|
self.logger.error(error_message)
|
||||||
|
|||||||
@@ -33,8 +33,11 @@ class LogTool(BaseTool):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_functions(self):
|
def get_functions(self):
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_log_contents",
|
"name": "get_log_contents",
|
||||||
"description": "Get the contents of the log file.",
|
"description": "Get the contents of the log file.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -48,6 +51,7 @@ class LogTool(BaseTool):
|
|||||||
"required": []
|
"required": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@metrics.measure
|
@metrics.measure
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class MetricsTool(BaseTool):
|
|||||||
def get_functions(self):
|
def get_functions(self):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_function_metrics",
|
"name": "get_function_metrics",
|
||||||
"description": "Get metrics for all measured functions.",
|
"description": "Get metrics for all measured functions.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -20,8 +22,11 @@ class MetricsTool(BaseTool):
|
|||||||
"properties": {},
|
"properties": {},
|
||||||
"required": []
|
"required": []
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_specific_function_metrics",
|
"name": "get_specific_function_metrics",
|
||||||
"description": "Get metrics for a specific function.",
|
"description": "Get metrics for a specific function.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -34,8 +39,11 @@ class MetricsTool(BaseTool):
|
|||||||
},
|
},
|
||||||
"required": ["function_name"]
|
"required": ["function_name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "function",
|
||||||
|
"function": {
|
||||||
"name": "get_top_n_functions",
|
"name": "get_top_n_functions",
|
||||||
"description": "Get the top N functions by total execution time.",
|
"description": "Get the top N functions by total execution time.",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -49,6 +57,7 @@ class MetricsTool(BaseTool):
|
|||||||
"required": ["n"]
|
"required": ["n"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@metrics.measure
|
@metrics.measure
|
||||||
|
|||||||
Reference in New Issue
Block a user