|
| 1 | +# Add ChatBot for API Assistance |
| 2 | + |
| 3 | +Link - https://fossunited.org/hack/fosshack25/p/7e6upj6f19 |
| 4 | + |
| 5 | +### What we planned to do: |
| 6 | + |
| 7 | +We aim to implement a **ChatBot feature** in API Dash with the following capabilities: |
| 8 | + |
| 9 | +1. **Explain API**: |
| 10 | + - **Description**: Analyze API responses and provide explanations in natural language. |
| 11 | + - **Features**: Generate clear descriptions of the API, including: |
| 12 | + - Purpose of the API. |
| 13 | + - Key parameters and their roles. |
| 14 | + - Response structure and fields. |
| 15 | + - Useful for **documentation** and **understanding API behavior**. |
| 16 | +2. **Debug Requests Based on Status Codes & Error Messages**: |
| 17 | + - **Description**: Provide **structured debugging suggestions** for failed API requests. |
| 18 | + - **Features**: |
| 19 | + - Analyze status codes (e.g., 4xx, 5xx) and error messages. |
| 20 | + - Offer step-by-step guidance to resolve issues. |
| 21 | +3. **Generate Test Cases**: |
| 22 | + - **Description**: Automatically generate **test cases** for API endpoints. |
| 23 | + - **Features**: Includes |
| 24 | + - Valid input scenarios. |
| 25 | + - Edge cases (e.g., invalid inputs, boundary values). |
| 26 | + - Expected responses and status codes. |
| 27 | + - Ensure test cases are **ready to use** in testing frameworks |
| 28 | +4. **Generate Sample Codes**: |
| 29 | + - **Description**: Generate **ready-to-run code snippets** for various programming languages (e.g., Dart, Python, JavaScript, React, Flutter). |
| 30 | + - **Features:** Includes |
| 31 | + - API integration code. |
| 32 | + - Error handling. |
| 33 | + - UI components for frontend frameworks (e.g: React). |
| 34 | + - Ensure the code is **directly usable** with minimal modifications. |
| 35 | + |
| 36 | +## What we built |
| 37 | + |
| 38 | +### **1. Ollama Model Integration** |
| 39 | + |
| 40 | +- **Dependency**: We integrated the AI chatbot with API Dash using the `ollama_dart: ^0.2.2` package. |
| 41 | +- **System Requirements**: To use the Ollama model, the system must have the Ollama application installed locally with a compatible model. |
| 42 | +- **Implementation**: |
| 43 | + - The interaction with the Ollama model is handled in `lib/services/ollama_services.dart`. |
| 44 | + - We tested multiple models, including `deepseek:r1:1.5b`, `ollama3.2:3b`, and `llama3.2:1b`. |
| 45 | + - Among these, `ollama3.2:3b` delivered the most accurate responses. |
| 46 | + - **Recommendation**: Use `ollama3.2:3b` or higher models for better accuracy. |
| 47 | + - **Customization**: Developers can switch models by modifying the “`model:''`” parameter in `/apidash/lib/services/ollama_service.dart`. |
| 48 | + |
| 49 | +### **2. Dynamic UI: ChatBot Widget** |
| 50 | + |
| 51 | +- **Design**: |
| 52 | + - A mini widget (`?`) is placed at the bottom right of the response panel. |
| 53 | + - When clicked, it expands into an AI chatbot interface. |
| 54 | +- **Features**: |
| 55 | + - **Explain API**: Provides explanations for API functionalities. |
| 56 | + - **Debug API**: Assists in debugging API-related issues. |
| 57 | + - **Test Cases**: Generates test cases for APIs. |
| 58 | + - **Generate Code**: Helps in generating code snippets for API integration. |
| 59 | + - **General Questions**: Users can ask general questions about ApiDash. |
| 60 | +- **Markdown Support**: |
| 61 | + - We used the `“package:flutter_markdown/flutter_markdown.dart”`package to format and display responses in a clean, readable manner. |
| 62 | + |
| 63 | + |
| 64 | +### Setup Guide |
| 65 | + |
| 66 | +- Install the updated dependency`ollama_dart: ^0.2.2` |
| 67 | +- To use the Ollama model, the system must have the Ollama application installed locally with a compatible model. |
| 68 | +- The interaction with the Ollama model is handled in `lib/services/ollama_services.dart`. |
| 69 | +- **Recommendation**: Use `ollama3.2:3b` or higher models for better accuracy. |
| 70 | +- Developers need to switch models by modifying the “`model:''`” parameter in `/apidash/lib/services/ollama_service.dart` to their local Ollama model to interact. |
| 71 | +- There you go now run `flutter run` to use AI Chatbot in ApiDash. |
| 72 | + |
| 73 | + |
| 74 | +## Issues |
| 75 | +1. **Enhance Response Formatting**: Improve the AI to ensure consistent markdown formatting in responses, eliminating plain text outputs. |
| 76 | +2. **Optimize Structured Outputs**: Fine-tune the AI to generate more organized and structured responses for better usability and clarity. |
| 77 | + |
| 78 | + |
| 79 | +## Future Enhancements: |
| 80 | +1. Enable users to integrate their local Ollama models seamlessly through the ChatBot interface for enhanced customization. |
| 81 | +2. Enable one-click downloading and copying of test codes, ensuring a seamless workflow for developers. |
| 82 | +3. Implementing a feature to generate test codes dynamically based on API endpoints and user inputs. |
| 83 | +4. A feature to Integrate with complete system architecture |
| 84 | +5. Suggesting the best practices from selected type of requests. |
0 commit comments