Skip to content

EdRamos12/ai-insight-search-w-elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vector Search with ELSeR and Elasticsearch

This project allows users to perform searches on an Elasticsearch database containing vectorized documents using the ELSeR (Elasticsearch Learned Sparse Encoder Representations) model. The search process uses OpenAI or Groq to provide detailed responses based on the retrieved documents.

Features

  • Vectorized Search: Query documents stored in Elasticsearch using vector-based retrieval.
  • Integration with ELSeR: Leverages the ELSeR model for semantic search.
  • OpenAI/Groq Integration: Allows querying with OpenAI or Groq models for advanced responses.
  • Flask API: Provides a RESTful API interface for submitting queries.
  • CORS Enabled: Cross-origin resource sharing support for easier integration with web frontends.

Requirements

  • Docker: To run the application inside a container.
  • Elasticsearch: A running Elasticsearch instance with vectorized documents and the ELSeR model set up.
  • OpenAI or Groq API Key: For querying and generating responses based on retrieved documents.

Setup

  1. Clone the repository:
git clone https://github.com/EdRamos12/ai-insight-search-w-elasticsearch
cd ai-insight-search-w-elasticsearch
  1. Create a .env file by copying the .env.example:
cp .env.example .env

Update the .env file with your actual configuration:

ELASTICSEARCH_URI=<your_elasticsearch_uri>
ELASTICSEARCH_USER=<your_elasticsearch_user>
ELASTICSEARCH_PASSWORD=<your_elasticsearch_password>
GROQ_API_KEY=<your_groq_api_key>
OPENAI_API_KEY=<your_openai_api_key>
MODEL=<your_model_name>
PORT=5000
  1. Build and run the Docker image:
docker build -t ai-insight-search-w-elasticsearch .
docker run -p 5000:5000 ai-insight-search-w-elasticsearch

Endpoints

POST /

Submit a search query to the application, which will interact with Elasticsearch, retrieve vectorized documents, and return a detailed response.

Request Body:

{
  "prompt": "Your search query"
}

Response: The API will return a JSON response with the most relevant documents and a summary generated by OpenAI or Groq.

Example:

curl -X POST https://localhost:5000/ -H "Content-Type: application/json" -d '{"prompt": "What films did Jim Carrey participate in?"}'

GET /

Serves the homepage for your application.

Project Structure

.
├── app.py                  # Main Flask app
├── Dockerfile              # Docker configuration
├── requirements.txt        # Python dependencies
├── .env                    # Environment variables (not included in the repo)
├── .example.env            # Environment variables template
└── .dockerignore           # Files to ignore in Docker build

Notes

  • Make sure your Elasticsearch instance is properly set up with the necessary vectorized index and ELSeR model.
  • You can use either OpenAI or Groq as the backend for generating responses, depending on which API keys you provide.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published