Added new demo

This commit is contained in:
ShubhamSaboo 2024-07-22 21:51:36 -05:00
parent e255f92b4c
commit d1a1215194
4 changed files with 99 additions and 0 deletions

View file

@ -31,6 +31,7 @@ A curated collection of awesome LLM apps built with RAG and AI agents. This repo
- [🛫 AI Travel Agent](#-ai-travel-agent)
- [🎬 AI Movie Production Agent](#-ai-movie-production-agent)
- [📰 Multi-Agent AI Researcher](#-multi-agent-ai-researcher)
- [📚 AI Research Agent with Memory](#-ai-research-agent-with-memory)
- [📄 Chat with PDF](#-chat-with-pdf)
- [💻 Web Scraping AI Agent](#-web-scraping-ai-agent)
- [📨 Chat with Gmail](#-chat-with-gmail)
@ -74,6 +75,9 @@ AI-powered movie production assistant that helps bring your movie ideas to life
### 📰 Multi-Agent AI Researcher
Use a team of AI agents to research top HackerNews stories and users with GPT-4 to generate blog posts, reports, and social media content on autopilot.
### 📚 AI Research Agent with Memory
AI Research Agent that helps user find research papers on Arxiv based on their interests and past interactions with LLMs. It maintains a memory of user interests and past interactions using Mem0 and Qdrant.
### 📄 Chat with PDF
Engage in intelligent conversation and question-answering based on the content of your PDF documents. Simply upload and start asking questions.

View file

@ -0,0 +1,39 @@
## 📚 AI Research Agent with Memory
This Streamlit app implements an AI-powered research assistant that helps users search for academic papers on arXiv while maintaining a memory of user interests and past interactions. It utilizes OpenAI's GPT-4o-mini model for processing search results, MultiOn for web browsing, and Mem0 with Qdrant for maintaining user context.
### Features
- Search interface for querying arXiv papers
- AI-powered processing of search results for improved readability
- Persistent memory of user interests and past searches
- Utilizes OpenAI's GPT-4o-mini model for intelligent processing
- Implements memory storage and retrieval using Mem0 and Qdrant
### 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. Ensure Qdrant is running:
The app expects Qdrant to be running on localhost:6333. Adjust the configuration in the code if your setup is different.
```bash
docker pull qdrant/qdrant
docker run -p 6333:6333 -p 6334:6334 \
-v $(pwd)/qdrant_storage:/qdrant/storage:z \
qdrant/qdrant
```
4. Run the Streamlit App
```bash
streamlit run ai_arxiv_agent_memory.py
```

View file

@ -0,0 +1,52 @@
import streamlit as st
import os
from mem0 import Memory
from multion.client import MultiOn
from openai import OpenAI
st.title("AI Research Agent with Memory 📚")
api_keys = {k: st.text_input(f"{k.capitalize()} API Key", type="password") for k in ['openai', 'multion']}
if all(api_keys.values()):
os.environ['OPENAI_API_KEY'] = api_keys['openai']
# Initialize Mem0 with Qdrant
config = {
"vector_store": {
"provider": "qdrant",
"config": {
"model": "gpt-4o-mini",
"host": "localhost",
"port": 6333,
}
},
}
memory, multion, openai_client = Memory.from_config(config), MultiOn(api_key=api_keys['multion']), OpenAI(api_key=api_keys['openai'])
user_id = st.sidebar.text_input("Enter your Username")
#user_interests = st.text_area("Research interests and background")
search_query = st.text_input("Research paper search query")
def process_with_gpt4(result):
prompt = f"""
Based on the following arXiv search result, provide a proper structured output in markdown that is readable by the users.
Each paper should have a title, authors, abstract, and link.
Search Result: {result}
Output Format: Table with the following columns: [{{"title": "Paper Title", "authors": "Author Names", "abstract": "Brief abstract", "link": "arXiv link"}}, ...]
"""
response = openai_client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], temperature=0.2)
return response.choices[0].message.content
if st.button('Search for Papers'):
with st.spinner('Searching and Processing...'):
relevant_memories = memory.search(search_query, user_id=user_id, limit=3)
prompt = f"Search for arXiv papers: {search_query}\nUser background: {' '.join(mem['text'] for mem in relevant_memories)}"
result = process_with_gpt4(multion.browse(cmd=prompt, url="https://arxiv.org/"))
st.markdown(result)
if st.sidebar.button("View Memory"):
st.sidebar.write("\n".join([f"- {mem['text']}" for mem in memory.get_all(user_id=user_id)]))
else:
st.warning("Please enter your API keys to use this app.")

View file

@ -0,0 +1,4 @@
streamlit
openai
mem0ai
multion