removing the tools calls
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 1m33s

This commit is contained in:
2025-02-04 13:39:34 -08:00
parent 65c981f889
commit 82fc9ea5f9
3 changed files with 1 additions and 131 deletions

View File

@@ -61,35 +61,10 @@ async def get_chat_history(channel, limit=100):
messages.append(content)
return "\n".join(reversed(messages))
async def get_available_tools() -> List[Dict[str, Any]]:
"""Fetch available tools from OpenWebUI API."""
try:
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {OPENAI_API_KEY}"
}
async with aiohttp.ClientSession() as session:
async with session.get(
f"{OPENWEBUI_API_BASE}/v1/tools/list",
headers=headers
) as response:
if response.status == 200:
tools = await response.json()
return tools
else:
print(f"Error fetching tools: {await response.text()}")
return []
except Exception as e:
print(f"Error fetching tools: {str(e)}")
return []
async def get_ai_response(context, user_message, image_urls=None):
# Fetch available tools
tools = await get_available_tools()
tools_json = json.dumps(tools, indent=2)
system_message = f"\"\"\"Previous conversation context:{context}\nAvailable Tools: {tools_json}\nReturn an empty string if no tools match the query." + """If a function tool matches, construct and return a JSON object in the format {"name": "functionName", "parameters": {"requiredFunctionParamKey": "requiredFunctionParamValue\"}} using the appropriate tool and its parameters. Only return the object and limit the response to the JSON object without additional text."""
system_message = f"\"\"\"Previous conversation context:{context}"""
messages = [
{"role": "system", "content": system_message},