Skip to content

feat: add core-chatbot test application with MCP integration#99

Merged
akshaydeo merged 1 commit intomainfrom
06-18-tests_bifrost_chatbot_added_for_tests
Jun 20, 2025
Merged

feat: add core-chatbot test application with MCP integration#99
akshaydeo merged 1 commit intomainfrom
06-18-tests_bifrost_chatbot_added_for_tests

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 19, 2025

Caution

Review failed

The pull request is closed.

Summary by CodeRabbit

  • New Features

    • Introduced a command-line chatbot application with support for multiple AI providers, interactive configuration, tool integrations, and agentic mode for synthesized responses.
    • Added commands for viewing help, switching providers or models, managing conversation history, and displaying current settings.
  • Chores

    • Added dependency management for the chatbot CLI application.
  • Refactor

    • Updated Ollama provider configuration to allow custom base URL and improved network settings.

Summary by CodeRabbit

  • New Features
    • Introduced a fully interactive CLI chatbot supporting multiple AI providers and models.
    • Enabled integration with external tools for enhanced responses, including agentic mode for synthesized answers.
    • Added commands for managing conversation history, switching providers/models, viewing configuration, and accessing help.
    • Provided visual feedback with loading animations during asynchronous operations.
  • Tests
    • Added module configuration for chatbot testing with all required dependencies.
  • Improvements
    • Updated Ollama provider configuration to use explicit network settings including base URL from environment variable.

Walkthrough

A new CLI chatbot application was introduced in the tests/core-chatbot directory, featuring a Go module definition and a comprehensive main.go implementation. The chatbot supports multiple AI providers, tool integrations, agentic mode, and interactive configuration via the command line, leveraging Bifrost's multi-client plugin infrastructure. Additionally, the Ollama provider network configuration was enhanced with explicit timeout, retry, and base URL settings.

Changes

File(s) Change Summary
tests/core-chatbot/go.mod Added Go module file with dependencies, replace directive, and provider libraries.
tests/core-chatbot/main.go Added full-featured CLI chatbot: provider/model selection, tool integration, agentic mode, etc.
tests/core-providers/config/account.go Modified Ollama provider config to use explicit network settings including base URL environment variable.

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
Loading

Possibly related PRs

Suggested reviewers

  • danpiths

Poem

A chatbot hops into the scene,
With models galore and tools so keen.
Providers switch with a flick of a paw,
Agentic mode leaves us in awe!
CLI adventures, history to show—
Bifrost’s magic, in Go we grow.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4161031 and 49d87c9.

⛔ Files ignored due to path filters (1)
  • tests/core-chatbot/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • tests/core-chatbot/go.mod (1 hunks)
  • tests/core-chatbot/main.go (1 hunks)
  • tests/core-providers/config/account.go (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch 06-18-tests_bifrost_chatbot_added_for_tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

Pratham-Mishra04 commented Jun 19, 2025

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ff7a3e and 4161031.

⛔ Files ignored due to path filters (1)
  • tests/core-chatbot/go.sum is 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 getEnvWithDefault function 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 SendMessage method 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.

Comment thread tests/core-chatbot/main.go
@Pratham-Mishra04 Pratham-Mishra04 marked this pull request as ready for review June 19, 2025 12:40
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 06-18-tests_bifrost_chatbot_added_for_tests branch from 4161031 to f8a1882 Compare June 19, 2025 17:19
Copy link
Copy Markdown
Contributor

akshaydeo commented Jun 20, 2025

Merge activity

  • Jun 20, 4:40 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 20, 4:42 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 20, 4:43 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo changed the base branch from 06-18-feat_added_mcp_support to graphite-base/99 June 20, 2025 16:40
@akshaydeo akshaydeo changed the base branch from graphite-base/99 to main June 20, 2025 16:40
@akshaydeo akshaydeo force-pushed the 06-18-tests_bifrost_chatbot_added_for_tests branch from f8a1882 to 49d87c9 Compare June 20, 2025 16:42
@akshaydeo akshaydeo merged commit 6820c37 into main Jun 20, 2025
1 of 2 checks passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

// Keep system prompt but clear conversation history
systemPrompt := session.history[0] // Assuming first message is system
session.history = []schemas.BifrostMessage{systemPrompt}

Fix in Cursor


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

}, nil
case schemas.Ollama:
return &schemas.ProviderConfig{
NetworkConfig: schemas.DefaultNetworkConfig,
ConcurrencyAndBufferSize: schemas.DefaultConcurrencyAndBufferSize,
}, nil

Fix in Cursor


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

if err != nil {
return "", fmt.Errorf("chat completion failed: %s", err.Error.Message)

Fix in Cursor


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 👎

@akshaydeo akshaydeo deleted the 06-18-tests_bifrost_chatbot_added_for_tests branch August 31, 2025 17:28
akshaydeo added a commit that referenced this pull request Nov 17, 2025
# 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants