Spaces:
Configuration error
Configuration error
AI Search Assistant
A web-based AI assistant that can search the internet to answer questions using LangChain, OpenAI, and Tavily Search.
Features
- Interactive web interface built with Streamlit
- Powered by OpenAI's language models
- Real-time web search capabilities using Tavily Search
- Conversation history tracking
- Customizable search parameters
- Deployment-ready with in-app API key management
How to run locally
Create and activate a conda environment:
conda create -n llmapp python=3.11 -y conda activate llmappInstall the required packages:
pip install -r requirements.txt(Optional) Set up your API keys in a
.envfile:OPENAI_API_KEY=your_openai_api_key TAVILY_API_KEY=your_tavily_api_keyNote: You can also enter API keys directly in the app interface.
Run the Streamlit app:
streamlit run app.pyOpen your browser and navigate to the URL shown in the terminal (typically http://localhost:8501)
Deployment Options
Deploy to Streamlit Cloud
- Fork this repository to your GitHub account
- Sign up for Streamlit Cloud
- Create a new app and connect it to your GitHub repository
- Deploy the app (no environment variables needed as users will input their API keys)
Deploy to Heroku
- Create a Heroku account and install the Heroku CLI
- Create a new Heroku app:
heroku create your-app-name - Add a
Procfilewith the following content:web: streamlit run app.py --server.port=$PORT - Deploy to Heroku:
git push heroku main
Deploy to Hugging Face using Docker
- Create a Hugging Face account at huggingface.co
- Install the Hugging Face CLI:
pip install huggingface_hub - Login to Hugging Face:
huggingface-cli login - Create a new Space on Hugging Face:
huggingface-cli repo create ai-search-assistant --type space - Clone your repository:
git clone https://huggingface.co/spaces/YOUR_USERNAME/ai-search-assistant - Copy your project files to the cloned repository
- Add a
.gitattributesfile with the following content:*.7z filter=lfs diff=lfs merge=lfs -text *.arrow filter=lfs diff=lfs merge=lfs -text *.bin filter=lfs diff=lfs merge=lfs -text *.bz2 filter=lfs diff=lfs merge=lfs -text *.ckpt filter=lfs diff=lfs merge=lfs -text *.ftz filter=lfs diff=lfs merge=lfs -text *.gz filter=lfs diff=lfs merge=lfs -text *.h5 filter=lfs diff=lfs merge=lfs -text *.joblib filter=lfs diff=lfs merge=lfs -text *.lfs.* filter=lfs diff=lfs merge=lfs -text *.mlmodel filter=lfs diff=lfs merge=lfs -text *.model filter=lfs diff=lfs merge=lfs -text *.msgpack filter=lfs diff=lfs merge=lfs -text *.npy filter=lfs diff=lfs merge=lfs -text *.npz filter=lfs diff=lfs merge=lfs -text *.onnx filter=lfs diff=lfs merge=lfs -text *.ot filter=lfs diff=lfs merge=lfs -text *.parquet filter=lfs diff=lfs merge=lfs -text *.pb filter=lfs diff=lfs merge=lfs -text *.pickle filter=lfs diff=lfs merge=lfs -text *.pkl filter=lfs diff=lfs merge=lfs -text *.pt filter=lfs diff=lfs merge=lfs -text *.pth filter=lfs diff=lfs merge=lfs -text *.rar filter=lfs diff=lfs merge=lfs -text *.safetensors filter=lfs diff=lfs merge=lfs -text *.tar.* filter=lfs diff=lfs merge=lfs -text *.tflite filter=lfs diff=lfs merge=lfs -text *.tgz filter=lfs diff=lfs merge=lfs -text *.wasm filter=lfs diff=lfs merge=lfs -text *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text *tfevents* filter=lfs diff=lfs merge=lfs -text - Create a
Dockerfilein your repository (already provided in this project) - Add a
README.mdfile with a description of your app - Commit and push your changes:
git add . git commit -m "Initial commit" git push - Configure your Space on the Hugging Face website:
- Go to your Space settings
- Set the Space SDK to "Docker"
- Set the Hardware to your preferred option (CPU is sufficient for this app)
- Save your changes
- Your app will be built and deployed automatically. You can access it at
https://huggingface.co/spaces/YOUR_USERNAME/ai-search-assistant
Usage
- Enter your OpenAI and Tavily API keys in the sidebar
- Configure search settings (model and number of results)
- Enter your question in the text input field
- Click the "Search" button
- View the AI's response with information sourced from the web
- Continue the conversation with follow-up questions
Requirements
- Python 3.11+
- OpenAI API key (Get one here)
- Tavily API key (Get one here)