updated local deepseek rag app
This commit is contained in:
parent
4cc031fd60
commit
7dc8d371a6
2 changed files with 19 additions and 15 deletions
|
|
@ -6,7 +6,7 @@ A powerful reasoning agent that combines local Deepseek models with RAG capabili
|
||||||
|
|
||||||
- **Dual Operation Modes**
|
- **Dual Operation Modes**
|
||||||
- Local Chat Mode: Direct interaction with Deepseek locally
|
- Local Chat Mode: Direct interaction with Deepseek locally
|
||||||
- RAG Mode: Enhanced reasoning with document context and web search integration - llama3.1:8b
|
- RAG Mode: Enhanced reasoning with document context and web search integration - llama3.2
|
||||||
|
|
||||||
- **Document Processing** (RAG Mode)
|
- **Document Processing** (RAG Mode)
|
||||||
- PDF document upload and processing
|
- PDF document upload and processing
|
||||||
|
|
@ -15,7 +15,6 @@ A powerful reasoning agent that combines local Deepseek models with RAG capabili
|
||||||
- Vector storage in Qdrant cloud
|
- Vector storage in Qdrant cloud
|
||||||
|
|
||||||
- **Intelligent Querying** (RAG Mode)
|
- **Intelligent Querying** (RAG Mode)
|
||||||
- Query rewriting using Gemini
|
|
||||||
- RAG-based document retrieval
|
- RAG-based document retrieval
|
||||||
- Similarity search with threshold filtering
|
- Similarity search with threshold filtering
|
||||||
- Automatic fallback to web search
|
- Automatic fallback to web search
|
||||||
|
|
@ -50,14 +49,10 @@ ollama pull deepseek-r1:7b
|
||||||
|
|
||||||
ollama pull snowflake-arctic-embed
|
ollama pull snowflake-arctic-embed
|
||||||
ollama run llama3.2
|
ollama run llama3.2
|
||||||
|
ollama pull llama3.2
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Google API Key (for RAG Mode)
|
### 2. Qdrant Cloud Setup (for RAG Mode)
|
||||||
1. Go to [Google AI Studio](https://aistudio.google.com/apikey)
|
|
||||||
2. Sign up or log in to your account
|
|
||||||
3. Create a new API key
|
|
||||||
|
|
||||||
### 3. Qdrant Cloud Setup (for RAG Mode)
|
|
||||||
1. Visit [Qdrant Cloud](https://cloud.qdrant.io/)
|
1. Visit [Qdrant Cloud](https://cloud.qdrant.io/)
|
||||||
2. Create an account or sign in
|
2. Create an account or sign in
|
||||||
3. Create a new cluster
|
3. Create a new cluster
|
||||||
|
|
@ -65,7 +60,7 @@ ollama run llama3.2
|
||||||
- Qdrant API Key: Found in API Keys section
|
- Qdrant API Key: Found in API Keys section
|
||||||
- Qdrant URL: Your cluster URL (format: `https://xxx-xxx.cloud.qdrant.io`)
|
- Qdrant URL: Your cluster URL (format: `https://xxx-xxx.cloud.qdrant.io`)
|
||||||
|
|
||||||
### 4. Exa AI API Key (Optional)
|
### 3. Exa AI API Key (Optional)
|
||||||
1. Visit [Exa AI](https://exa.ai)
|
1. Visit [Exa AI](https://exa.ai)
|
||||||
2. Sign up for an account
|
2. Sign up for an account
|
||||||
3. Generate an API key for web search capabilities
|
3. Generate an API key for web search capabilities
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@ import tempfile
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List
|
from typing import List
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import google.generativeai as genai
|
|
||||||
import bs4
|
import bs4
|
||||||
from agno.agent import Agent
|
from agno.agent import Agent
|
||||||
from agno.models.google import Gemini
|
|
||||||
from agno.models.ollama import Ollama
|
from agno.models.ollama import Ollama
|
||||||
from langchain_community.document_loaders import PyPDFLoader, WebBaseLoader
|
from langchain_community.document_loaders import PyPDFLoader, WebBaseLoader
|
||||||
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
||||||
|
|
@ -18,8 +16,14 @@ from agno.tools.exa import ExaTools
|
||||||
from agno.embedder.ollama import OllamaEmbedder
|
from agno.embedder.ollama import OllamaEmbedder
|
||||||
|
|
||||||
|
|
||||||
class OllamaEmbedderr(Embeddings):
|
class OllamaEmbedder(Embeddings):
|
||||||
def __init__(self, model_name="snowflake-arctic-embed"):
|
def __init__(self, model_name="snowflake-arctic-embed"):
|
||||||
|
"""
|
||||||
|
Initialize the OllamaEmbedderr with a specific model.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
model_name (str): The name of the model to use for embedding.
|
||||||
|
"""
|
||||||
self.embedder = OllamaEmbedder(id=model_name, dimensions=1024)
|
self.embedder = OllamaEmbedder(id=model_name, dimensions=1024)
|
||||||
|
|
||||||
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||||
|
|
@ -139,8 +143,13 @@ if st.session_state.use_web_search:
|
||||||
|
|
||||||
|
|
||||||
# Utility Functions
|
# Utility Functions
|
||||||
def init_qdrant():
|
def init_qdrant() -> QdrantClient | None:
|
||||||
"""Initialize Qdrant client with configured settings."""
|
"""Initialize Qdrant client with configured settings.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
QdrantClient: The initialized Qdrant client if successful.
|
||||||
|
None: If the initialization fails.
|
||||||
|
"""
|
||||||
if not all([st.session_state.qdrant_api_key, st.session_state.qdrant_url]):
|
if not all([st.session_state.qdrant_api_key, st.session_state.qdrant_url]):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
|
@ -234,7 +243,7 @@ def create_vector_store(client, texts):
|
||||||
vector_store = QdrantVectorStore(
|
vector_store = QdrantVectorStore(
|
||||||
client=client,
|
client=client,
|
||||||
collection_name=COLLECTION_NAME,
|
collection_name=COLLECTION_NAME,
|
||||||
embedding=OllamaEmbedderr()
|
embedding=OllamaEmbedder()
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add documents
|
# Add documents
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue