mirror of
https://github.com/Shubhamsaboo/awesome-llm-apps.git
synced 2026-03-11 17:48:31 -05:00
New Demo
This commit is contained in:
43
web_search_ai_agent/README.md
Normal file
43
web_search_ai_agent/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
## 🎯 Generative AI Search Assistant
|
||||
This Streamlit app combines the power of search engines and LLMs to provide you with pinpointed answers to your queries. By leveraging OpenAI's GPT-4o and the DuckDuckGo search engine, this AI search assistant delivers accurate and concise responses to your questions.
|
||||
|
||||
### Features
|
||||
- Get pinpointed answers to your queries
|
||||
- Utilize DuckDuckGo search engine for web searching
|
||||
- Use OpenAI GPT-4o for intelligent answer generation
|
||||
|
||||
### How to get Started?
|
||||
|
||||
1. Clone the GitHub repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
|
||||
```
|
||||
2. Install the required dependencies:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
3. Get your OpenAI API Key
|
||||
|
||||
- Sign up for an [OpenAI account](https://platform.openai.com/) (or the LLM provider of your choice) and obtain your API key.
|
||||
|
||||
4. Run the Streamlit App
|
||||
```bash
|
||||
streamlit run ai_webagent.py
|
||||
```
|
||||
|
||||
### How It Works?
|
||||
|
||||
- Upon running the app, you will be prompted to enter your OpenAI API key. This key is used to authenticate and access the OpenAI language models.
|
||||
|
||||
- Once you provide a valid API key, an instance of the Assistant class is created. This assistant utilizes the GPT-4 language model from OpenAI and the DuckDuckGo search engine tool.
|
||||
|
||||
- Enter your search query in the provided text input field.
|
||||
|
||||
- The assistant will perform the following steps:
|
||||
- Conduct a web search using DuckDuckGo based on your query
|
||||
- Analyze the search results and extract relevant information
|
||||
- Generate a concise and targeted answer using the GPT-4 language model
|
||||
|
||||
- The pinpointed answer will be displayed in the app, providing you with the information you need.
|
||||
31
web_search_ai_agent/ai_webagent.py
Normal file
31
web_search_ai_agent/ai_webagent.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# Import the required libraries
|
||||
import streamlit as st
|
||||
from phi.assistant import Assistant
|
||||
from phi.tools.duckduckgo import DuckDuckGo
|
||||
from phi.llm.openai import OpenAIChat
|
||||
|
||||
# Set up the Streamlit app
|
||||
st.title("AI Search Assistant 🤖")
|
||||
st.caption("This app allows you to search the web using AI")
|
||||
|
||||
# Get OpenAI API key from user
|
||||
openai_access_token = st.text_input("OpenAI API Key", type="password")
|
||||
|
||||
# If OpenAI API key is provided, create an instance of Assistant
|
||||
if openai_access_token:
|
||||
# Create an instance of the Assistant
|
||||
assistant = Assistant(
|
||||
llm=OpenAIChat(
|
||||
model="gpt-4o",
|
||||
max_tokens=1024,
|
||||
temperature=0.9,
|
||||
api_key=openai_access_token) , tools=[DuckDuckGo()], show_tool_calls=True
|
||||
)
|
||||
|
||||
# Get the search query from the user
|
||||
query= st.text_input("Enter the Search Query", type="default")
|
||||
|
||||
if query:
|
||||
# Search the web using the AI Assistant
|
||||
response = assistant.run(query, stream=False)
|
||||
st.write(response)
|
||||
4
web_search_ai_agent/requirements.txt
Normal file
4
web_search_ai_agent/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
streamlit
|
||||
openai
|
||||
phidata
|
||||
duckduckgo-search
|
||||
Reference in New Issue
Block a user