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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import requests
|
| 4 |
+
import logging
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
from dotenv import load_dotenv
|
| 7 |
+
from typing_extensions import List, TypedDict
|
| 8 |
+
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
+
from langchain_core.documents import Document
|
| 12 |
+
from langchain_core.tools import tool
|
| 13 |
+
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 14 |
+
from langchain_community.vectorstores import FAISS
|
| 15 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 16 |
+
from langchain_community.tools import DuckDuckGoSearchResults
|
| 17 |
+
|
| 18 |
+
# ---------------- ENV & LOGGING ----------------
|
| 19 |
+
|
| 20 |
+
load_dotenv()
|
| 21 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 22 |
+
os.environ["USER_AGENT"] = "my-custom-agent"
|
| 23 |
+
|
| 24 |
+
logging.basicConfig(
|
| 25 |
+
level=logging.INFO,
|
| 26 |
+
format="%(asctime)s [%(levelname)s] %(message)s",
|
| 27 |
+
handlers=[
|
| 28 |
+
logging.FileHandler("assistant.log"),
|
| 29 |
+
logging.StreamHandler()
|
| 30 |
+
]
|
| 31 |
+
)
|
| 32 |
+
logger = logging.getLogger(__name__)
|
| 33 |
+
|
| 34 |
+
# ---------------- EMBEDDINGS & VECTOR STORE ----------------
|
| 35 |
+
|
| 36 |
+
embedding_model_name = "sentence-transformers/all-MiniLM-L6-v2"
|
| 37 |
+
embeddings = HuggingFaceEmbeddings(model_name=embedding_model_name)
|
| 38 |
+
|
| 39 |
+
vector_store_path = "faiss_index"
|
| 40 |
+
if Path(vector_store_path).exists():
|
| 41 |
+
logger.info("π Loading existing vector store...")
|
| 42 |
+
vector_store = FAISS.load_local(vector_store_path, embeddings, allow_dangerous_deserialization=True)
|
| 43 |
+
else:
|
| 44 |
+
logger.info("π¦ Initializing new vector store...")
|
| 45 |
+
dummy_doc = Document(page_content="Init doc")
|
| 46 |
+
vector_store = FAISS.from_documents([dummy_doc], embedding=embeddings)
|
| 47 |
+
vector_store.index.reset()
|
| 48 |
+
vector_store.docstore._dict.clear()
|
| 49 |
+
vector_store.index_to_docstore_id.clear()
|
| 50 |
+
|
| 51 |
+
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200, add_start_index=True)
|
| 52 |
+
|
| 53 |
+
# ---------------- GROQ LLM ----------------
|
| 54 |
+
|
| 55 |
+
def query_groq_llm(prompt: str) -> str:
|
| 56 |
+
url = "https://api.groq.com/openai/v1/chat/completions"
|
| 57 |
+
headers = {
|
| 58 |
+
"Authorization": f"Bearer {GROQ_API_KEY}",
|
| 59 |
+
"Content-Type": "application/json"
|
| 60 |
+
}
|
| 61 |
+
payload = {
|
| 62 |
+
"model": "llama3-8b-8192", # You can change to "mixtral-8x7b-32768" or others
|
| 63 |
+
"messages": [
|
| 64 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 65 |
+
{"role": "user", "content": prompt}
|
| 66 |
+
],
|
| 67 |
+
"temperature": 0.7
|
| 68 |
+
}
|
| 69 |
+
response = requests.post(url, headers=headers, json=payload)
|
| 70 |
+
response.raise_for_status()
|
| 71 |
+
return response.json()['choices'][0]['message']['content']
|
| 72 |
+
|
| 73 |
+
# ---------------- DUCKDUCKGO TOOL ----------------
|
| 74 |
+
|
| 75 |
+
@tool
|
| 76 |
+
def search_tool(query: str) -> str:
|
| 77 |
+
"""Search the web using DuckDuckGo."""
|
| 78 |
+
search = DuckDuckGoSearchResults()
|
| 79 |
+
return search.run(query)
|
| 80 |
+
|
| 81 |
+
# ---------------- UTILS ----------------
|
| 82 |
+
|
| 83 |
+
def is_vague(text: str) -> bool:
|
| 84 |
+
if not text.strip():
|
| 85 |
+
return True
|
| 86 |
+
vague_phrases = [
|
| 87 |
+
"i don't know", "not sure", "cannot answer", "no context", "not enough info",
|
| 88 |
+
"uncertain", "please provide", "you haven't", "unknown", "not found"
|
| 89 |
+
]
|
| 90 |
+
return any(phrase in text.lower() for phrase in vague_phrases)
|
| 91 |
+
|
| 92 |
+
def is_realtime_query(text: str) -> bool:
|
| 93 |
+
keywords = ["current", "today", "latest", "now", "who is", "trending", "new", "recent"]
|
| 94 |
+
return any(k in text.lower() for k in keywords)
|
| 95 |
+
|
| 96 |
+
# ---------------- FALLBACK WEB SEARCH ----------------
|
| 97 |
+
|
| 98 |
+
def use_tool_only(question: str) -> str:
|
| 99 |
+
logger.info(f"Real-time query detected: '{question}'")
|
| 100 |
+
result = search_tool.invoke({"query": question})
|
| 101 |
+
prompt = f"Here is information from the web:\n\n{result}\n\nAnswer this question: {question}"
|
| 102 |
+
response = query_groq_llm(prompt)
|
| 103 |
+
|
| 104 |
+
# Store new info if not already in memory
|
| 105 |
+
new_doc = Document(page_content=result)
|
| 106 |
+
chunks = splitter.split_documents([new_doc])
|
| 107 |
+
existing = vector_store.similarity_search(result, k=5)
|
| 108 |
+
already_exists = any(c.page_content.strip() == result.strip() for c in existing)
|
| 109 |
+
|
| 110 |
+
if not already_exists:
|
| 111 |
+
logger.info("Adding new content to vector store.")
|
| 112 |
+
vector_store.add_documents(chunks)
|
| 113 |
+
vector_store.save_local(vector_store_path)
|
| 114 |
+
else:
|
| 115 |
+
logger.info("Content already exists. Skipping add.")
|
| 116 |
+
|
| 117 |
+
return f"[From Web Search]\n\n{response}"
|
| 118 |
+
|
| 119 |
+
# ---------------- ASK FUNCTION ----------------
|
| 120 |
+
|
| 121 |
+
def ask(question: str) -> str:
|
| 122 |
+
logger.info(f"New Question: {question}")
|
| 123 |
+
|
| 124 |
+
# Use FAISS with score
|
| 125 |
+
retrieved_docs = vector_store.similarity_search_with_score(question, k=5)
|
| 126 |
+
threshold = 0.25 # adjust as needed
|
| 127 |
+
filtered_docs = [doc for doc, score in retrieved_docs if score < threshold]
|
| 128 |
+
|
| 129 |
+
if not filtered_docs:
|
| 130 |
+
logger.info("No relevant memory found. Using web search.")
|
| 131 |
+
return use_tool_only(question)
|
| 132 |
+
|
| 133 |
+
context = "\n\n".join(doc.page_content for doc in filtered_docs)
|
| 134 |
+
prompt_text = f"""You are a helpful assistant.
|
| 135 |
+
|
| 136 |
+
Context:
|
| 137 |
+
{context}
|
| 138 |
+
|
| 139 |
+
Question: {question}"""
|
| 140 |
+
|
| 141 |
+
response = query_groq_llm(prompt_text)
|
| 142 |
+
|
| 143 |
+
if not is_vague(response):
|
| 144 |
+
logger.info("Answered using memory.")
|
| 145 |
+
return f"[From Memory]\n\n{response}"
|
| 146 |
+
|
| 147 |
+
logger.info("Memory response vague. Using web search.")
|
| 148 |
+
return use_tool_only(question)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
# ---------------- GRADIO UI ----------------
|
| 152 |
+
|
| 153 |
+
with gr.Blocks(title="RAG + Groq LLM Assistant") as iface:
|
| 154 |
+
gr.Markdown(
|
| 155 |
+
"""
|
| 156 |
+
# π€ RAG + Real-Time AI Assistant (Groq + HuggingFace Embeddings)
|
| 157 |
+
Ask anything. The assistant uses memory or searches the web if needed.
|
| 158 |
+
"""
|
| 159 |
+
)
|
| 160 |
+
with gr.Row():
|
| 161 |
+
with gr.Column(scale=1):
|
| 162 |
+
chatbot = gr.Chatbot(label="Assistant", height=400)
|
| 163 |
+
with gr.Column(scale=1):
|
| 164 |
+
msg = gr.Textbox(label="Your message", placeholder="Ask a question...", show_label=False)
|
| 165 |
+
submit_btn = gr.Button("Submit")
|
| 166 |
+
|
| 167 |
+
def user_message_handler(message, history):
|
| 168 |
+
logger.info(f"User: {message}")
|
| 169 |
+
response = ask(message)
|
| 170 |
+
history.append((message, response))
|
| 171 |
+
return "", history
|
| 172 |
+
|
| 173 |
+
submit_btn.click(user_message_handler, [msg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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-05-04 23:17:54,437 [INFO] Loading faiss.
|
| 2 |
+
2025-05-04 23:17:54,461 [INFO] Successfully loaded faiss.
|
| 3 |
+
2025-05-04 23:17:54,466 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 4 |
+
2025-05-04 23:17:54,726 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 5 |
+
2025-05-04 23:17:54,747 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 6 |
+
2025-05-04 23:17:54,893 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 7 |
+
2025-05-04 23:17:55,058 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 8 |
+
2025-05-04 23:18:03,030 [INFO] New Question: who does a pen work
|
| 9 |
+
2025-05-04 23:18:03,812 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 10 |
+
2025-05-04 23:18:24,777 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 11 |
+
2025-05-04 23:18:24,791 [INFO] Answered using memory.
|
| 12 |
+
2025-05-04 23:20:32,691 [INFO] New Question: Who is Prashanth Reddy Varanganti
|
| 13 |
+
2025-05-04 23:20:34,828 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 14 |
+
2025-05-04 23:20:35,852 [INFO] response: https://html.duckduckgo.com/html 200
|
| 15 |
+
2025-05-04 23:20:43,926 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 16 |
+
2025-05-04 23:20:44,863 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 17 |
+
2025-05-04 23:20:44,867 [INFO] Adding new content to vector store.
|
| 18 |
+
2025-05-04 23:20:45,271 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 19 |
+
2025-05-04 23:20:58,838 [INFO] New Question: Who is Prashanth Reddy Varanganti
|
| 20 |
+
2025-05-04 23:21:01,146 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 21 |
+
2025-05-04 23:21:02,168 [INFO] response: https://lite.duckduckgo.com/lite/ 200
|
| 22 |
+
2025-05-04 23:21:13,843 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 23 |
+
2025-05-04 23:21:14,153 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 24 |
+
2025-05-04 23:21:14,157 [INFO] Adding new content to vector store.
|
| 25 |
+
2025-05-04 23:21:14,766 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 26 |
+
2025-05-04 23:23:04,507 [INFO] Loading faiss.
|
| 27 |
+
2025-05-04 23:23:04,529 [INFO] Successfully loaded faiss.
|
| 28 |
+
2025-05-04 23:23:04,533 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 29 |
+
2025-05-04 23:23:04,810 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 30 |
+
2025-05-04 23:23:04,832 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 31 |
+
2025-05-04 23:23:04,996 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 32 |
+
2025-05-04 23:23:05,134 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 33 |
+
2025-05-04 23:23:14,324 [INFO] New Question: Who is prashanth reddy varanganti
|
| 34 |
+
2025-05-04 23:23:15,089 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 35 |
+
2025-05-04 23:23:19,977 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 36 |
+
2025-05-04 23:23:19,992 [INFO] Answered using memory.
|
| 37 |
+
2025-05-04 23:24:25,078 [INFO] Loading faiss.
|
| 38 |
+
2025-05-04 23:24:25,097 [INFO] Successfully loaded faiss.
|
| 39 |
+
2025-05-04 23:24:25,101 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 40 |
+
2025-05-04 23:24:25,362 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 41 |
+
2025-05-04 23:24:25,375 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 42 |
+
2025-05-04 23:24:25,604 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 43 |
+
2025-05-04 23:24:25,681 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 44 |
+
2025-05-04 23:24:30,150 [INFO] New message: HI
|
| 45 |
+
2025-05-04 23:24:30,151 [INFO] New Question: HI
|
| 46 |
+
2025-05-04 23:24:30,998 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 47 |
+
2025-05-04 23:24:32,099 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 48 |
+
2025-05-04 23:24:32,110 [INFO] Answered using memory.
|
| 49 |
+
2025-05-04 23:24:39,429 [INFO] New message: What is todays date
|
| 50 |
+
2025-05-04 23:24:39,430 [INFO] New Question: What is todays date
|
| 51 |
+
2025-05-04 23:24:40,901 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 52 |
+
2025-05-04 23:25:04,899 [INFO] New message: what is today..?
|
| 53 |
+
2025-05-04 23:25:04,900 [INFO] New Question: what is today..?
|
| 54 |
+
2025-05-04 23:25:08,551 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 55 |
+
2025-05-04 23:25:31,300 [INFO] New message: what is todya
|
| 56 |
+
2025-05-04 23:25:31,300 [INFO] New Question: what is todya
|
| 57 |
+
2025-05-04 23:25:31,562 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 58 |
+
2025-05-04 23:25:34,050 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 59 |
+
2025-05-04 23:25:34,053 [INFO] Answered using memory.
|
| 60 |
+
2025-05-04 23:25:39,609 [INFO] New message: stoday
|
| 61 |
+
2025-05-04 23:25:39,610 [INFO] New Question: stoday
|
| 62 |
+
2025-05-04 23:25:41,626 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 63 |
+
2025-05-04 23:25:49,224 [INFO] New message: what is today
|
| 64 |
+
2025-05-04 23:25:49,224 [INFO] New Question: what is today
|
| 65 |
+
2025-05-04 23:25:51,902 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 66 |
+
2025-05-04 23:26:13,965 [INFO] New message: ok ,what do you mean by ai engineering..?
|
| 67 |
+
2025-05-04 23:26:13,965 [INFO] New Question: ok ,what do you mean by ai engineering..?
|
| 68 |
+
2025-05-04 23:26:14,805 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 69 |
+
2025-05-04 23:26:29,245 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 70 |
+
2025-05-04 23:26:29,250 [INFO] Answered using memory.
|
| 71 |
+
2025-05-04 23:27:17,887 [INFO] New message: Long note book
|
| 72 |
+
2025-05-04 23:27:17,887 [INFO] New Question: Long note book
|
| 73 |
+
2025-05-04 23:27:18,398 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"
|
| 74 |
+
2025-05-04 23:27:41,336 [INFO] HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
|
| 75 |
+
2025-05-04 23:27:41,341 [INFO] Answered using memory.
|
| 76 |
+
2025-05-04 23:28:53,480 [INFO] Loading faiss.
|
| 77 |
+
2025-05-04 23:28:53,499 [INFO] Successfully loaded faiss.
|
| 78 |
+
2025-05-04 23:28:53,503 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 79 |
+
2025-05-04 23:28:53,707 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 80 |
+
2025-05-04 23:28:53,720 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 81 |
+
2025-05-04 23:28:53,833 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 82 |
+
2025-05-04 23:28:54,010 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 83 |
+
2025-05-04 23:28:58,676 [INFO] New message: HI
|
| 84 |
+
2025-05-04 23:28:58,677 [INFO] New Question: HI
|
| 85 |
+
2025-05-04 23:28:59,676 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 429 Too Many Requests"
|
| 86 |
+
2025-05-04 23:28:59,677 [INFO] Retrying request to /embeddings in 0.423430 seconds
|
| 87 |
+
2025-05-04 23:29:00,509 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 429 Too Many Requests"
|
| 88 |
+
2025-05-04 23:29:00,510 [INFO] Retrying request to /embeddings in 0.900636 seconds
|
| 89 |
+
2025-05-04 23:29:01,926 [INFO] HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 429 Too Many Requests"
|
| 90 |
+
2025-05-04 23:36:05,589 [INFO] Use pytorch device_name: mps
|
| 91 |
+
2025-05-04 23:36:05,590 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 92 |
+
2025-05-04 23:36:07,140 [WARNING] Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
|
| 93 |
+
2025-05-04 23:36:12,372 [INFO] π Loading existing vector store...
|
| 94 |
+
2025-05-04 23:36:12,374 [INFO] Loading faiss.
|
| 95 |
+
2025-05-04 23:36:12,556 [INFO] Successfully loaded faiss.
|
| 96 |
+
2025-05-04 23:36:12,561 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 97 |
+
2025-05-04 23:36:12,891 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 98 |
+
2025-05-04 23:36:12,906 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 99 |
+
2025-05-04 23:36:13,154 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 100 |
+
2025-05-04 23:36:13,189 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 101 |
+
2025-05-04 23:36:23,475 [INFO] User: Hey
|
| 102 |
+
2025-05-04 23:36:23,475 [INFO] New Question: Hey
|
| 103 |
+
2025-05-04 23:36:49,116 [INFO] Use pytorch device_name: mps
|
| 104 |
+
2025-05-04 23:36:49,117 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 105 |
+
2025-05-04 23:36:50,429 [INFO] π Loading existing vector store...
|
| 106 |
+
2025-05-04 23:36:50,437 [INFO] Loading faiss.
|
| 107 |
+
2025-05-04 23:36:50,771 [INFO] Successfully loaded faiss.
|
| 108 |
+
2025-05-04 23:36:50,776 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 109 |
+
2025-05-04 23:36:51,009 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 110 |
+
2025-05-04 23:36:51,024 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 111 |
+
2025-05-04 23:36:51,121 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 112 |
+
2025-05-04 23:36:51,336 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 113 |
+
2025-05-04 23:36:55,939 [INFO] User: Hey
|
| 114 |
+
2025-05-04 23:36:55,940 [INFO] New Question: Hey
|
| 115 |
+
2025-05-04 23:37:44,053 [INFO] Use pytorch device_name: mps
|
| 116 |
+
2025-05-04 23:37:44,054 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 117 |
+
2025-05-04 23:37:45,359 [INFO] π¦ Initializing new vector store...
|
| 118 |
+
2025-05-04 23:37:46,731 [INFO] Loading faiss.
|
| 119 |
+
2025-05-04 23:37:46,997 [INFO] Successfully loaded faiss.
|
| 120 |
+
2025-05-04 23:37:47,003 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 121 |
+
2025-05-04 23:37:47,293 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 122 |
+
2025-05-04 23:37:47,310 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 123 |
+
2025-05-04 23:37:47,461 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 124 |
+
2025-05-04 23:37:47,614 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 125 |
+
2025-05-04 23:37:51,102 [INFO] User: HEy
|
| 126 |
+
2025-05-04 23:37:51,103 [INFO] New Question: HEy
|
| 127 |
+
2025-05-04 23:37:51,869 [INFO] Answered using memory.
|
| 128 |
+
2025-05-04 23:38:10,664 [INFO] User: What US did to India..?
|
| 129 |
+
2025-05-04 23:38:10,664 [INFO] New Question: What US did to India..?
|
| 130 |
+
2025-05-04 23:38:12,346 [INFO] Memory insufficient. Falling back to real-time web search.
|
| 131 |
+
2025-05-04 23:38:12,347 [INFO] Real-time query detected: 'What US did to India..?'
|
| 132 |
+
2025-05-04 23:38:13,584 [INFO] response: https://html.duckduckgo.com/html 200
|
| 133 |
+
2025-05-04 23:38:14,931 [INFO] Adding new content to vector store.
|
| 134 |
+
2025-05-04 23:38:37,643 [INFO] User: What US did to india..?
|
| 135 |
+
2025-05-04 23:38:37,644 [INFO] New Question: What US did to india..?
|
| 136 |
+
2025-05-04 23:38:38,397 [INFO] Answered using memory.
|
| 137 |
+
2025-05-04 23:47:16,450 [INFO] Use pytorch device_name: mps
|
| 138 |
+
2025-05-04 23:47:16,451 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 139 |
+
2025-05-04 23:47:17,944 [INFO] π Loading existing vector store...
|
| 140 |
+
2025-05-04 23:47:17,955 [INFO] Loading faiss.
|
| 141 |
+
2025-05-04 23:47:18,165 [INFO] Successfully loaded faiss.
|
| 142 |
+
2025-05-04 23:47:18,172 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 143 |
+
2025-05-04 23:47:18,692 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 144 |
+
2025-05-04 23:48:14,916 [INFO] Use pytorch device_name: mps
|
| 145 |
+
2025-05-04 23:48:14,917 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 146 |
+
2025-05-04 23:48:16,180 [INFO] π Loading existing vector store...
|
| 147 |
+
2025-05-04 23:48:16,186 [INFO] Loading faiss.
|
| 148 |
+
2025-05-04 23:48:16,358 [INFO] Successfully loaded faiss.
|
| 149 |
+
2025-05-04 23:48:16,362 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 150 |
+
2025-05-04 23:48:16,629 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 151 |
+
2025-05-04 23:48:16,649 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 152 |
+
2025-05-04 23:48:16,708 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 153 |
+
2025-05-04 23:48:16,947 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 154 |
+
2025-05-04 23:49:06,536 [INFO] Use pytorch device_name: mps
|
| 155 |
+
2025-05-04 23:49:06,536 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 156 |
+
2025-05-04 23:49:08,344 [INFO] π Loading existing vector store...
|
| 157 |
+
2025-05-04 23:49:08,347 [INFO] Loading faiss.
|
| 158 |
+
2025-05-04 23:49:08,532 [INFO] Successfully loaded faiss.
|
| 159 |
+
2025-05-04 23:49:08,536 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 160 |
+
2025-05-04 23:49:08,755 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 161 |
+
2025-05-04 23:49:08,770 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 162 |
+
2025-05-04 23:49:08,960 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 163 |
+
2025-05-04 23:49:09,077 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 164 |
+
2025-05-05 00:50:13,159 [INFO] Use pytorch device_name: mps
|
| 165 |
+
2025-05-05 00:50:13,159 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 166 |
+
2025-05-05 00:50:14,497 [INFO] π Loading existing vector store...
|
| 167 |
+
2025-05-05 00:50:14,503 [INFO] Loading faiss.
|
| 168 |
+
2025-05-05 00:50:14,738 [INFO] Successfully loaded faiss.
|
| 169 |
+
2025-05-05 00:50:14,744 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 170 |
+
2025-05-05 00:50:15,026 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 171 |
+
2025-05-05 00:50:15,044 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 172 |
+
2025-05-05 00:50:15,174 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 173 |
+
2025-05-05 00:50:15,343 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 174 |
+
2025-05-05 00:50:39,936 [INFO] User: Hey , HI
|
| 175 |
+
2025-05-05 00:50:39,936 [INFO] New Question: Hey , HI
|
| 176 |
+
2025-05-05 00:50:41,481 [INFO] Answered using memory.
|
| 177 |
+
2025-05-05 00:51:02,253 [INFO] User: WHt is th current staus of the indian army..?
|
| 178 |
+
2025-05-05 00:51:02,254 [INFO] New Question: WHt is th current staus of the indian army..?
|
| 179 |
+
2025-05-05 00:51:03,216 [INFO] Answered using memory.
|
| 180 |
+
2025-05-05 00:51:43,085 [INFO] User: I cant understand why we use RAG
|
| 181 |
+
2025-05-05 00:51:43,086 [INFO] New Question: I cant understand why we use RAG
|
| 182 |
+
2025-05-05 00:51:44,973 [INFO] Answered using memory.
|
| 183 |
+
2025-05-05 00:52:23,974 [INFO] Use pytorch device_name: mps
|
| 184 |
+
2025-05-05 00:52:23,974 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 185 |
+
2025-05-05 00:52:25,419 [INFO] π Loading existing vector store...
|
| 186 |
+
2025-05-05 00:52:25,423 [INFO] Loading faiss.
|
| 187 |
+
2025-05-05 00:52:25,657 [INFO] Successfully loaded faiss.
|
| 188 |
+
2025-05-05 00:52:25,661 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 189 |
+
2025-05-05 00:52:25,898 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 190 |
+
2025-05-05 00:52:25,911 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 191 |
+
2025-05-05 00:52:26,117 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 192 |
+
2025-05-05 00:52:26,189 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 193 |
+
2025-05-05 00:52:30,627 [INFO] User: HEY
|
| 194 |
+
2025-05-05 00:52:30,627 [INFO] New Question: HEY
|
| 195 |
+
2025-05-05 00:52:31,308 [INFO] Answered using memory.
|
| 196 |
+
2025-05-05 00:52:43,194 [INFO] User: I DONT WNAT THAT
|
| 197 |
+
2025-05-05 00:52:43,195 [INFO] New Question: I DONT WNAT THAT
|
| 198 |
+
2025-05-05 00:52:44,776 [INFO] Answered using memory.
|
| 199 |
+
2025-05-05 00:56:20,576 [INFO] Use pytorch device_name: mps
|
| 200 |
+
2025-05-05 00:56:20,576 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 201 |
+
2025-05-05 00:56:21,926 [INFO] π Loading existing vector store...
|
| 202 |
+
2025-05-05 00:56:21,932 [INFO] Loading faiss.
|
| 203 |
+
2025-05-05 00:56:22,197 [INFO] Successfully loaded faiss.
|
| 204 |
+
2025-05-05 00:56:22,202 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 205 |
+
2025-05-05 00:56:22,435 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 206 |
+
2025-05-05 00:56:22,449 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 207 |
+
2025-05-05 00:56:22,768 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 208 |
+
2025-05-05 00:56:22,768 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
| 209 |
+
2025-05-05 00:56:30,876 [INFO] User: Hey
|
| 210 |
+
2025-05-05 00:56:30,877 [INFO] New Question: Hey
|
| 211 |
+
2025-05-05 00:56:31,308 [INFO] No relevant memory found. Using web search.
|
| 212 |
+
2025-05-05 00:56:31,309 [INFO] Real-time query detected: 'Hey'
|
| 213 |
+
2025-05-05 00:56:32,679 [INFO] response: https://lite.duckduckgo.com/lite/ 200
|
| 214 |
+
2025-05-05 00:56:33,208 [INFO] Adding new content to vector store.
|
| 215 |
+
2025-05-05 00:56:54,640 [INFO] User: Hey, hi
|
| 216 |
+
2025-05-05 00:56:54,641 [INFO] New Question: Hey, hi
|
| 217 |
+
2025-05-05 00:56:54,796 [INFO] No relevant memory found. Using web search.
|
| 218 |
+
2025-05-05 00:56:54,796 [INFO] Real-time query detected: 'Hey, hi'
|
| 219 |
+
2025-05-05 00:56:55,660 [INFO] response: https://html.duckduckgo.com/html 200
|
| 220 |
+
2025-05-05 00:56:56,238 [INFO] Adding new content to vector store.
|
| 221 |
+
2025-05-05 01:02:28,907 [INFO] User: HEY , HI ASSISTANT
|
| 222 |
+
2025-05-05 01:02:28,908 [INFO] New Question: HEY , HI ASSISTANT
|
| 223 |
+
2025-05-05 01:02:30,049 [INFO] No relevant memory found. Using web search.
|
| 224 |
+
2025-05-05 01:02:30,050 [INFO] Real-time query detected: 'HEY , HI ASSISTANT'
|
| 225 |
+
2025-05-05 01:02:31,033 [INFO] response: https://html.duckduckgo.com/html 200
|
| 226 |
+
2025-05-05 01:02:31,521 [INFO] Adding new content to vector store.
|
| 227 |
+
2025-05-05 01:10:07,943 [INFO] Use pytorch device_name: mps
|
| 228 |
+
2025-05-05 01:10:07,944 [INFO] Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
|
| 229 |
+
2025-05-05 01:10:09,436 [INFO] π Loading existing vector store...
|
| 230 |
+
2025-05-05 01:10:09,439 [INFO] Loading faiss.
|
| 231 |
+
2025-05-05 01:10:09,622 [INFO] Successfully loaded faiss.
|
| 232 |
+
2025-05-05 01:10:09,627 [INFO] Failed to load GPU Faiss: name 'GpuIndexIVFFlat' is not defined. Will not load constructor refs for GPU indexes. This is only an error if you're trying to use GPU Faiss.
|
| 233 |
+
2025-05-05 01:10:09,889 [INFO] HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
|
| 234 |
+
2025-05-05 01:10:09,904 [INFO] HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
|
| 235 |
+
2025-05-05 01:10:10,025 [INFO] HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
|
| 236 |
+
2025-05-05 01:10:10,190 [INFO] HTTP Request: GET https://api.gradio.app/v3/tunnel-request "HTTP/1.1 200 OK"
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
python-dotenv
|
| 2 |
+
langchain-core
|
| 3 |
+
langchain-community
|
| 4 |
+
faiss
|