Add ChatBot for API Assistance #605

Implemented a ChatBot in API Dash with capabilities to explain APIs, debug requests, generate test cases, and provide sample codes, integrated using Ollama models and a dynamic UI widget.
Description
Issues / PRs
Team Members

Add ChatBot for API Assistance #605

What we planned to do:

We aim to implement a ChatBot feature in API Dash with the following capabilities:

  1. Explain API:

    • Description: Analyze API responses and provide explanations in natural language.

    • Features:

      Generate clear descriptions of the API, including:

    • Purpose of the API.

    • Key parameters and their roles.

    • Response structure and fields.

    • Useful for documentation and understanding API behavior.

  2. Debug requests based on status codes & error messages:

    • Description: Provide structured debugging suggestions for failed API requests.

    • Features:

      • Analyze status codes (e.g., 4xx, 5xx) and error messages.

      • Offer step-by-step guidance to resolve issues.

  3. Generate Test Cases:

    • Description: Automatically generate test cases for API endpoints.

    • Features:

      • Includes:

        • Valid input scenarios.

        • Edge cases (e.g., invalid inputs, boundary values).

        • Expected responses and status codes.

    • Ensure test cases are ready to use in testing frameworks

  4. Generate Sample Codes:

    • Description: Generate ready-to-run code snippets for various programming languages (e.g., Dart, Python, JavaScript, React, Flutter).

    • Features:

      • Includes:

        • API integration code.

        • Error handling.

        • UI components for frontend frameworks (e.g., React).

    • Ensure the code is directly usable with minimal modifications.

What we built:

  1. Ollama Model Integration

  • Dependency: We integrated the AI chatbot with API Dash using the ollama_dart: ^0.2.2 package.

  • System Requirements: To use the Ollama model, the system must have the Ollama application installed locally with a compatible model.

    Implementation:

  • The interaction with the Ollama model is handled in.lib/services/ollama_services.dart

  • We tested multiple models, includingdeepseek:r1:1.5b,llama3.2:3bandllama3.2:1b

  • Among these, ollama3.2:3b delivered the most accurate responses.

  • Recommendation: Use ollama3.2:3b or higher models for better accuracy.

  • Customization: Developers can switch models by modifying the model:parameter in /apidash/lib/services/ollama_service.dart

2. Dynamic UI: ChatBot Widget

  • Design:

    • A mini widget (?) is placed at the bottom right of the response panel.

    • When clicked, it expands into an AI chatbot interface.

  • Features:

    • Default Features:

      • Explain API: provides explanations for API functionalities.

      • Debug API: assists in debugging API-related issues.

      • Test Cases: Generates test cases for APIs.

      • Generate Code: Helps in generating code snippets for API integration.

      • General Questions: Users can ask general questions about ApiDash.

  • Markdown Support:

    We used the “package:flutter_markdown/flutter_markdown.dart”package to format and display responses in a clean, readable manner.

Setup Guide

  • Install the updated dependencyollama_dart: ^0.2.2

  • To use the Ollama model, the system must have the Ollama application installed locally with a compatible model.

  • The interaction with the Ollama model is handled inlib/services/ollama_services.dart

  • Recommendation: Use llama3.2:3b or higher models for better accuracy.

  • Developers need to switch models by modifying the      "model:''” parameter in/apidash/lib/services/ollama_service.dart to their local Ollama model to interact.

  • There you go, now run “Flutter run” to use AI Chatbot in ApiDash.

Issues, PRs and Discussions
Srinath Reddy Vennapusa
Srinath Reddy Vennapusa
srinath_reddy_vennapusa
Bavitha reddy Yaragudala
Bavitha reddy Yaragudala
bavitha_reddy_yaragudala
Prasad Dhumale
Prasad Dhumale
prasad_dhumale