Skip to content

richietaylor/LongContextAnswerAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Long Context Answer Agent 🤖

Hi! Welcome to my Long Context Answer Agent.

This project is an intelligent question-answering agent that leverages the FinWeb semantic search engine to fetch and process a large volume of documents—up to 10,000 per query—to serve as context for answering user questions.


Index


Functionality

  1. User Input: The user provides a main question, and a date range (to filter by publication date).
  2. Slow Search: The system then uses these inputs to search the Finweb API's /slow- search/ endpoint. This endpoint returns an encrypted file (stored on S3) along with an encryption key.
  3. Generate Embeddings: Downloads and decrypts the file to obtain up to 10,000 search results, then uses the HuggingFace servers to embed the search results.
  4. USearch Index: Create a USearch index using the HuggingFace embeddings.
  5. Answer: When a user asks a question, the USearch index is used to retrieve relevant search results. The relevant search results, as well as the user's question, will be sent to a model on OpenRouter to answer the question. The answer generated includes citations that reference the original search results fetched from the slow search endpoint.
  6. Multi-turn Conversation: Allow the user to ask follow-up questions. The follow-up questions can use the same USearch index.

Tools

  • Finweb API will be used as the search engine to retrieve context for the user’s query.
  • USearch, which allows you to build small, single-file semantic search engines.
  • HuggingFace servers to generate the embeddings for the USearch index.
  • OpenRouter for LLM model access.

Usage

Before usage, you install dependencies:

pip install -r requirements.txt

You must also create a file called keys.env that will contain all your api keys as follows, make sure to remember to replace with your own keys:

FINWEB_V1_API_KEY=your_finweb_api_key_here
OPENROUTER_API_KEY=your_openrouter_api_key_here

From there all you need to do is run the code, either in your code editor environment, or through the command line:

python main.py

or

py main.py

From there you can use the script as you'd expect, you'll be prompted to put in your question and date range, and any follow up questions in the command line.

If you want a deeper look into the context returned by the FinWeb API, check the user_question.csv file that is created when you use the script.


Acknowledgements

Big thanks to Nosible, who set this project for me as a technical interview, I had a lot of fun! 🎉

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages