API-Agentic-Chat

An agentic chatbot designed to assist users in navigating API documentation.

The API-Agentic-Chat is an intelligent chatbot designed to help users navigate API documentation effortlessly. By leveraging agents, embeddings, FAISS, and Large Language Models (LLMs), the system retrieves relevant API references and provides step-by-step explanations to user queries in plain language.

Interactive Chatbot Interface

Key Features

  • Natural Language Query: Users can ask API-related questions in plain language.
  • Intelligent Retrieval: Identifies the most relevant API documentation using embeddings and FAISS indexing.
  • Step-by-Step Explanations: Combines multiple results into coherent responses generated by LLMs.
  • Contextual Understanding: Maintains conversation context to improve accuracy and relevance.
  • API Body Display: Displays detailed API request and response structures from the documentation.

Technologies Used

  • Python: Implementing core logic and backend operations.
  • FAISS: Handles vector-based search for embeddings.
  • LangChain: Simplifies LLM orchestration and integrates document retrieval.
  • Streamlit: Build web interface.
  • OpenAI: Generates embeddings and explanations.

How It Works

  1. Process API Documentation:

    • Users upload API documentation PDFs to the reference_docs/ folder.
    • The system processes the documents into manageable chunks.
  2. Generate Embeddings:

    • Embeddings are generated for the document chunks using OpenAI.
    • The chunks are indexed using FAISS for fast and accurate retrieval.
  3. Ask Questions:

    • Users input natural language queries (e.g., “How do I fetch user data?”).
    • The system identifies relevant chunks, retrieves API details, and combines them into coherent explanations.
  4. Streamlit Interface:

    • Users interact with the chatbot through an intuitive interface.
    • Responses include API descriptions, parameters, and even request/response structures.

Project Workflow

  1. Setup:

    • Clone the repository and install dependencies.
    • Create a .env file and add your OpenAI API key.
  2. Document Processing:

    • Upload API documentation and process it using process_docs.py.
  3. Embedding Creation:

    • Generate embeddings and create a FAISS index with store_embeddings.py.
  4. Chatbot Interaction:

    • Launch the Streamlit app and ask API-related questions for step-by-step guidance.

Agents in Action

1. API Selector Agent
  • File: src/api_selector.py
  • Purpose: Matches user queries to the most relevant API documentation using embeddings and FAISS.
  • Key Features:
    • Embeds user queries and searches the FAISS index.
    • Retrieves the most relevant API endpoints along with their descriptions and parameters.
2. Explanation Agent
  • File: src/construct_prompt.py
  • Purpose: Generates natural language explanations using OpenAI’s LLM.
  • Key Features:
    • Combines retrieved chunks into coherent and detailed step-by-step answers.
    • Maintains conversational context for multi-turn interactions.

Installation

Follow the steps in this file to set up the API-Agentic-Chat on your local machine: Getting-started

Use Cases

  • API Documentation Exploration: Users can quickly search and retrieve information about APIs without manually browsing documentation.
  • Developer Assistance: Offers step-by-step guidance for implementing specific API functionalities.
  • Educational Tool: Helps new developers learn how to use APIs effectively.

Conclusion

The API-Agentic-Chat is able to process, retrieve, and explain APIs in natural language makes it an indispensable tool for developers, educators, and learners.

For more details, visit the API-Agentic-Chat GitHub Repository.