Code Monkey home page Code Monkey logo

answer_engine's Introduction

Answer Engine

Answer Engine is a Python script that combines web search, Retrieval-Augmented Generation (RAG), reflection, summarization, and follow-up question generation to provide comprehensive answers to user queries. It leverages OpenAI embeddings, Brave search API, and Groq's Mixtral model for inference.

Features

  • Rephrases user queries using an LLM to optimize search results.
  • Performs web searches using the Brave search API.
  • Scrapes and parses the content of the searched web pages.
  • Embeds the scraped content into a Chroma database for efficient retrieval.
  • Retrieves relevant documents from the Chroma database based on the user query.
  • Generates an initial response using the Groq Mixtral model.
  • Performs reflection on the generated response to ensure its relevance to the user query.
  • Generates a refined response if the initial response is unsatisfactory.
  • Provides follow-up questions based on the user query and the generated response.

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/answer-engine.git
  2. Change into the project directory:

    cd answer-engine
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Set up the necessary environment variables:

    • Create a .env file in the project root directory.
    • Add the following variables to the .env file:
      OPENAI_API_KEY=your_openai_api_key
      BRAVE_API_KEY=your_brave_api_key
      GROQ_API_KEY=your_groq_api_key
      
    • Replace your_openai_api_key, your_brave_api_key, and your_groq_api_key with your actual API keys.

Usage

  1. Open the app.py file and modify the USER_PROMPT variable to specify your desired query.

  2. Run the script:

    python app.py
  3. The script will perform the following steps:

    • Rephrase the user query using an LLM.
    • Search for relevant web pages using the Brave search API.
    • Scrape and parse the content of the searched web pages.
    • Embed the scraped content into a Chroma database.
    • Retrieve relevant documents from the Chroma database based on the rephrased query.
    • Generate an initial response using the Groq Mixtral model.
    • Perform reflection on the generated response and refine it if necessary.
    • Generate follow-up questions based on the user query and the generated response.
  4. The script will output the following:

    • The rephrased query.
    • The final generated response.
    • The relevant sources used to generate the response.
    • The generated follow-up questions.

Dependencies

The Answer Engine relies on the following libraries and APIs:

  • OpenAI Embeddings: Used for generating embeddings of the scraped content.
  • Brave Search API: Used for performing web searches.
  • Groq Mixtral: Used for generating responses and follow-up questions.
  • Chroma: Used for storing and retrieving embedded documents.
  • BeautifulSoup: Used for web scraping and parsing HTML content.
  • Requests: Used for making HTTP requests to web pages.

Make sure to install the required dependencies and set up the necessary API keys before running the script.

License

This project is licensed under the MIT License.

answer_engine's People

Contributors

leemark avatar

Stargazers

 avatar jaewilson07 avatar Vince Fulco--Bighire.tools avatar  avatar

Watchers

 avatar Kostas Georgiou avatar

Forkers

juanpin99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.