feat: add core-chatbot test application with MCP integration#99
feat: add core-chatbot test application with MCP integration#99
Conversation
|
Caution Review failedThe pull request is closed. Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughA new CLI chatbot application was introduced in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChatSession
participant Bifrost
participant MCP_Tool
participant LLM_Provider
User->>ChatSession: Enter message/command
ChatSession->>ChatSession: Process command or add message to history
ChatSession->>LLM_Provider: Send chat completion request
LLM_Provider-->>ChatSession: Return response (may include tool calls)
alt Tool calls present
ChatSession->>User: Prompt for tool execution
User->>ChatSession: Approve tool
ChatSession->>MCP_Tool: Execute tool via Bifrost MCP
MCP_Tool-->>ChatSession: Return tool result
alt Agentic mode
ChatSession->>LLM_Provider: Synthesize tool results
LLM_Provider-->>ChatSession: Return synthesized response
else Non-agentic mode
ChatSession->>User: Show tool results
end
end
ChatSession->>User: Display assistant response / results
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/core-chatbot/go.sumis excluded by!**/*.sum
📒 Files selected for processing (2)
tests/core-chatbot/go.mod(1 hunks)tests/core-chatbot/main.go(1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.64.8)
tests/core-chatbot/main.go
721-721: SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
(staticcheck)
🔇 Additional comments (16)
tests/core-chatbot/go.mod (3)
5-7: LGTM: Proper local module configuration.The replace directive and require statement correctly configure the local dependency on the Bifrost core module.
9-60: Comprehensive dependency list for multi-provider support.The indirect dependencies appropriately cover the requirements for multiple AI providers (AWS SDK, Google Cloud, various HTTP libraries, JSON processing, etc.) and MCP integration.
3-3: Verify the Go version is valid.Go version 1.24.1 appears to be a future release that may not exist yet. Please verify this version is available and valid.
What is the latest stable version of Go as of early 2025?tests/core-chatbot/main.go (13)
3-18: Well-organized imports for comprehensive functionality.The import structure appropriately covers all necessary packages for CLI interaction, networking, concurrency, signal handling, and Bifrost integration.
20-37: Clean struct definitions with proper configuration management.The structs are well-designed with appropriate field types and clear separation of concerns between configuration, session state, and account management.
42-48: Good utility function for environment variable handling.The
getEnvWithDefaultfunction provides a clean way to handle optional environment variables with fallback values.
50-134: Comprehensive multi-provider support with proper key management.The provider configuration correctly handles API keys from environment variables and includes appropriate model lists for each provider. The keyless handling for Ollama is correctly implemented.
136-230: Robust provider configuration with proper network and concurrency settings.The configuration includes appropriate timeouts, retry logic, and provider-specific metadata configurations. The use of environment variables for provider-specific settings is well implemented.
232-295: Excellent MCP integration setup with proper tool configuration.The session initialization correctly configures MCP servers for web search and Context7 tools, with proper STDIO configuration and error handling.
297-318: Smart provider availability validation.The logic correctly validates provider availability based on API key presence, with proper handling of keyless providers like Ollama and Vertex.
329-396: Interactive provider switching with proper user experience.The provider switching logic includes clear user prompts, input validation, and automatic model selection when appropriate.
461-532: Comprehensive message handling with proper parameter configuration.The
SendMessagemethod correctly handles message history, model parameters, and response parsing with appropriate error handling.
534-612: Excellent tool execution workflow with user consent.The tool execution implementation includes proper user approval workflows, loading animations, and comprehensive error handling for each tool call.
614-696: Smart agentic mode with synthesis capability.The synthesis functionality appropriately sends tool results back to the LLM for natural language processing, with proper fallback handling when synthesis fails.
795-827: Nice loading animation implementation with proper concurrency.The spinner animation uses proper goroutine management with channels and WaitGroup for clean shutdown.
829-936: Comprehensive main function with proper CLI handling.The main function includes proper environment variable validation, graceful shutdown handling, command processing, and a clean interaction loop. The 3-second wait for MCP server initialization is appropriate.
4161031 to
f8a1882
Compare
Merge activity
|
f8a1882 to
49d87c9
Compare
There was a problem hiding this comment.
Bug: Clear Command Crashes on Empty History
The /clear command can panic due to an out-of-bounds access session.history[0]. This occurs because the initial system message is only added to session.history if session.systemPrompt is not empty, potentially leaving the history slice empty and causing a crash when history[0] is accessed.
tests/core-chatbot/main.go#L900-L902
bifrost/tests/core-chatbot/main.go
Lines 900 to 902 in 49d87c9
Bug: Ollama Provider Configuration Missing BaseURL
The Ollama provider configuration in tests/core-chatbot/main.go is inconsistent. The ComprehensiveTestAccount.GetConfigForProvider for Ollama uses schemas.DefaultNetworkConfig, but it should include a custom BaseURL (e.g., http://localhost:11434 configurable via OLLAMA_BASE_URL). This prevents the chatbot from connecting to Ollama servers running on non-default URLs.
tests/core-chatbot/main.go#L216-L221
bifrost/tests/core-chatbot/main.go
Lines 216 to 221 in 49d87c9
Bug: Error Handling Fails in SendMessage Function
A runtime panic occurs in the SendMessage function when handling errors returned by s.client.ChatCompletionRequest. The code attempts to access err.Error.Message, which incorrectly assumes the error object always has this specific field structure. If the bifrost client returns a standard Go error or another error type without this structure, the application will panic. The standard err.Error() method should be used for general error string representation.
tests/core-chatbot/main.go#L497-L498
bifrost/tests/core-chatbot/main.go
Lines 497 to 498 in 49d87c9
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
# Add Core Chatbot Test Application This PR introduces a new CLI-based chatbot application for testing the Bifrost core functionality. The chatbot provides a comprehensive testing environment with the following features: - Support for multiple AI providers including OpenAI, Anthropic, Bedrock, Cohere, Azure, Vertex, Ollama, and Mistral - Interactive CLI interface with commands to switch providers and models - Integration with MCP (Model Control Protocol) for tool execution - Support for web search and Context7 tools via MCP servers - Agentic mode for synthesizing tool results into natural responses - Manual approval workflow for tool execution - Conversation history management The implementation demonstrates real-world usage of the Bifrost core library, showcasing how to initialize the client, manage conversations, handle tool calls, and integrate with various AI providers.

Add Core Chatbot Test Application
This PR introduces a new CLI-based chatbot application for testing the Bifrost core functionality. The chatbot provides a comprehensive testing environment with the following features:
The implementation demonstrates real-world usage of the Bifrost core library, showcasing how to initialize the client, manage conversations, handle tool calls, and integrate with various AI providers.