/celeste-mvp-back

Celeste chat bot's backend

Primary LanguagePython

celeste-mvp-back

API to interact with a Chatbot to answer questions about a markdown file or a web page using ChatGPT from OPenAI.

  • Status: In progress

How to run

  1. Set environment variables in .env

    # Mandatory
    OPENAI_API_KEY="openai_api_key"
    
    # For Monitoring (Optional)
    LANGCHAIN_API_KEY="langchain_api_key"
    LANGCHAIN_TRACING_V2='true'
    LANGCHAIN_ENDPOINT='https://api.smith.langchain.com'
  2. Set confing in .config.json

    {
      "cache_path": "Directory path where will be the embeddings stored",
      "files": ["file1.md", "./my_knowledge_file2.md"],
      "pages": [
        {"url": "https://example.com", "tag": "div", "class": "my-class", "id": "my-id"},
        {"url": "https://other_example.com", "tag": "body", "class": "your-class", "id": "your-id"}
      ]
    }
    • Either files or pages must be in the configuration.
    • url is mandatory to define pages.
  3. Set virtual environment

    python -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
  4. Run service

    python app/serve.py

How to call

  • Using request

    import requests
    
    response = requests.post(
        "http://localhost:8000/markdown/invoke",
        json={'input': {"input": "Are Paper Checks processed any day?"}}
    )
    print(response.json()["output"]["answer"])
  • Using RemoteRunnable

    from langserve import RemoteRunnable
    
     
    def main():
        """Client to interact with the served chain as if it were running client-side"""
        remote_chain = RemoteRunnable("http://localhost:8000/markdown")
        response = remote_chain.invoke({"input": "What is a billpay?"})
        print(response)
        
    if __name__ == "__main__":
        main()
  • Using the Navigator

    Open http://localhost:8000/rag/playground in the navigator.

How to contribute

TODOs

  • MVP-001: Load documents from page
  • MVP-002: Test basic base of knowledge
  • MVP-003: Expand the base of knowledge
  • MVP-004: Enable a chat mode
  • MVP-005: Use an open source model

Tests cases

  • Markdown base of knowledge - basic
  • HTML base of knowledge - basic
  • Expanded base of knowledge