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.
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:
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.
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.
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
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:
Ollama Model Integration
Dependency: We integrated the AI chatbot with API Dash using the
ollama_dart: ^0.2.2package.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, including
deepseek:r1:1.5b,llama3.2:3bandllama3.2:1bAmong these,
ollama3.2:3bdelivered the most accurate responses.Recommendation: Use
ollama3.2:3bor 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 dependency
ollama_dart: ^0.2.2To 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 in
lib/services/ollama_services.dartRecommendation: Use
llama3.2:3bor higher models for better accuracy.Developers need to switch models by modifying the "
model:''” parameter in/apidash/lib/services/ollama_service.dartto their local Ollama model to interact.There you go, now run “Flutter run” to use AI Chatbot in ApiDash.