Commit Graph

32 Commits

Author SHA1 Message Date
94651b6ec1 Rewrite to use chat.completions with manual MCP tool execution
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 55s
Major refactor to fix Bedrock + MCP compatibility issues:

- Removed Responses API approach (doesn't work with Bedrock)
- Added execute_mcp_tool() to manually call tools via /mcp/call_tool
- Rewrote get_available_mcp_tools() to return OpenAI function format
- Implemented manual tool execution loop with max 5 iterations
- Tool results are sent back to model in standard tool response format
- Removed query_needs_tools() function (no longer needed)

How it works:
1. Fetch MCP tools from /v1/mcp/tools and convert to OpenAI format
2. Call chat.completions.create() with tools array
3. When model requests tool calls, execute via POST /mcp/call_tool
4. Send results back to model with role="tool"
5. Loop until model provides final response

This bypasses the broken Responses API and uses working endpoints
that are compatible with AWS Bedrock + LiteLLM MCP integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 11:34:24 -08:00
aca70dbd0b Add intelligent tool_choice parameter for MCP tools
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 54s
Implements smart tool selection based on query content:
- Adds query_needs_tools() function to detect tool-requiring queries
- Sets tool_choice="required" for queries needing GitHub/time/weather/search
- Sets tool_choice="auto" for general conversation
- Adds debug logging for tool choice decisions

This fixes the issue where MCP tools were configured but not being used
because tool_choice defaulted to "auto" and the model opted not to use them.

Query detection keywords include:
- Time/date operations (time, clock, date, now, current)
- Weather queries (weather, temperature, forecast)
- GitHub operations (repo, code, file, commit, PR, issue)
- Search/lookup operations (search, find, get, fetch, retrieve)
- File operations (read, open, check, list, contents)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 11:08:09 -08:00
394e4ccf24 Fix Discord bot to use LiteLLM Responses API v2 with MCP tools
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 53s
Key changes:
- Upgrade OpenAI SDK from 1.x to 2.x (required for responses API)
- Update get_ai_response to use developer role for system prompts
- Improve response extraction with output_text shorthand
- Add enhanced debug logging for troubleshooting
- Add traceback logging for better error diagnostics

This fixes the "'OpenAI' object has no attribute 'responses'" error
and enables proper MCP tool auto-execution through LiteLLM.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 10:58:10 -08:00
240330cf3b Refactor to use LiteLLM Responses API for automatic MCP tool execution
Major refactoring to properly integrate with LiteLLM's Responses API, which handles
MCP tool execution automatically instead of requiring manual tool call loops.

Key changes:
- Switched from chat.completions.create() to client.responses.create()
- Use "server_url": "litellm_proxy" to leverage LiteLLM as MCP gateway
- Set "require_approval": "never" for fully automatic tool execution
- Simplified get_available_mcp_tools() to get_available_mcp_servers()
- Removed manual OpenAI tool format conversion (LiteLLM handles this)
- Updated response extraction to use output[0].content[0].text format
- Convert system prompts to user role for Responses API compatibility

Technical improvements:
- LiteLLM now handles the complete tool calling loop automatically
- No more placeholder responses - actual MCP tools will execute
- Cleaner code with ~100 fewer lines
- Better separation between tools-enabled and tools-disabled paths
- Proper error handling for Responses API format

Responses API benefits:
- Single API call returns final response with tool results integrated
- Automatic tool discovery, execution, and result formatting
- No manual tracking of tool_call_ids or conversation state
- Native MCP support via server_label configuration

Documentation:
- Added comprehensive litellm-mcp-research.md with API examples
- Documented Responses API vs chat.completions differences
- Included Discord bot migration patterns
- Covered authentication, streaming, and tool restrictions

Next steps:
- Test with actual Discord interactions
- Verify GitHub MCP tools execute correctly
- Monitor response extraction for edge cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 10:32:04 -08:00
408028c36e Add MCP tools integration for Discord bot
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 1m2s
Major improvements to LiteLLM Discord bot with MCP (Model Context Protocol) tools support:

Features added:
- MCP tools discovery and integration with LiteLLM proxy
- Fetch and convert 40+ GitHub MCP tools to OpenAI format
- Tool calling flow with placeholder execution (pending MCP endpoint confirmation)
- Dynamic tool injection based on LiteLLM MCP server configuration
- Enhanced system prompt with tool usage guidance
- Added ENABLE_TOOLS environment variable for easy toggle
- Comprehensive debug logging for troubleshooting

Technical changes:
- Added httpx>=0.25.0 dependency for async MCP API calls
- Implemented get_available_mcp_tools() to query /v1/mcp/server and /v1/mcp/tools endpoints
- Convert MCP tool schemas to OpenAI function calling format
- Detect and handle tool_calls in model responses
- Added system_prompt.txt for customizable bot behavior
- Updated README with better documentation and setup instructions
- Created claude.md with detailed development notes and upgrade roadmap

Configuration:
- New ENABLE_TOOLS flag in .env to control MCP integration
- DEBUG_LOGGING for detailed execution logs
- System prompt file support for easy customization

Known limitations:
- Tool execution currently uses placeholders (MCP execution endpoint needs verification)
- Limited to 50 tools to avoid overwhelming the model
- Requires LiteLLM proxy with MCP server configured

Next steps:
- Verify correct LiteLLM MCP tool execution endpoint
- Implement actual tool execution via MCP proxy
- Test end-to-end GitHub operations through Discord

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-10 11:26:01 -08:00
82fc9ea5f9 removing the tools calls
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 1m33s
2025-02-04 13:39:34 -08:00
65c981f889 pushing changes 2025-01-06 19:44:47 -08:00
1d390685a6 Update required for new modules 2025-01-02 20:02:12 -08:00
4fbbf89afe Update required for new modules 2025-01-02 20:00:38 -08:00
d8e22a9773 Updating bot and removing .env file 2025-01-02 19:47:54 -08:00
8144971707 update the discord main bot to allow it to be packaged with Docker 2025-01-02 19:41:08 -08:00
45249174ba pushing updates for bot 2025-01-02 19:38:42 -08:00
9d6541ce75 upgrading script to v2 with history 2025-01-02 17:53:16 -08:00
37b363b317 adding V2
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 1m0s
2025-01-02 17:22:32 -08:00
43f40981db Include History for Chatbot
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 59s
2024-12-31 19:18:31 -08:00
35839395f4 adding back the dm chat
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 58s
2024-12-30 21:52:32 -08:00
jknapp
aa9d6e9765 Merge pull request 'Adding the ability to look at history but not including it every time' (#2) from set-message-history into main
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 1m0s
Reviewed-on: #2
2024-12-31 05:46:22 +00:00
ff48937482 fixing changes from merge 2024-12-30 21:45:37 -08:00
41b0173680 Merge branch 'main' into set-message-history 2024-12-30 21:42:23 -08:00
b0258d2a1f Adding the ability to look at history but not including it every time 2024-12-30 21:37:29 -08:00
jknapp
365abd25ad Merge pull request 'updates-123024' (#1) from updates-123024 into main
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 59s
Reviewed-on: #1
2024-12-31 05:01:00 +00:00
e7f59ce55d Adding Chat history review 2024-12-30 21:00:17 -08:00
7046eb2576 Responding to DMs 2024-12-30 19:54:17 -08:00
jknapp
e38a7532c3 Update .gitea/workflows/build-push.yaml
All checks were successful
OpenWebUI Discord Bot / Build-and-Push (push) Successful in 58s
2024-12-21 04:42:52 +00:00
jknapp
3f631bfc9f Update .gitea/workflows/build-push.yaml
Some checks failed
OpenWebUI Discord Bot / Build-and-Push (push) Failing after 7s
2024-12-21 04:42:13 +00:00
jknapp
e1437b4edc Update .gitea/workflows/build-push.yaml
Some checks failed
OpenWebUI Discord Bot / Build-and-Push (push) Failing after 7s
2024-12-21 04:41:05 +00:00
5c341c5ff4 Update container path
Some checks failed
OpenWebUI Discord Bot / Build-and-Push (push) Failing after 1m35s
2024-12-19 21:30:29 -08:00
8dea7daad4 fix formatting
Some checks failed
OpenWebUI Discord Bot / Build-and-Push (push) Failing after 1m19s
2024-12-19 21:16:50 -08:00
f969aa9c69 Add CICD
Some checks failed
OpenWebUI Discord Bot / Build-and-Push (push) Failing after 7s
2024-12-19 21:11:12 -08:00
059dbd307f Adding Docker Support and updating README.md 2024-12-19 17:53:34 -08:00
1d8572e12b Getting the initial Bot Code Pushed 2024-12-19 17:19:06 -08:00
jknapp
81a2e16cf9 Initial commit 2024-12-20 00:27:48 +00:00