Spaces:
Running
Running
VIRTUS
commited on
Commit
·
ed7f758
1
Parent(s):
f086d4e
fix: general structure of the project
Browse files- .gitignore +2 -1
- app.py +0 -2
- tools/RetriveBooksDataTool.py +6 -9
- util/aws/__pycache__/S3Access.cpython-312.pyc +0 -0
- util/aws/__pycache__/__init__.cpython-312.pyc +0 -0
.gitignore
CHANGED
|
@@ -2,5 +2,6 @@
|
|
| 2 |
.idea/
|
| 3 |
data/
|
| 4 |
vector_stores/
|
| 5 |
-
*/__pycache__
|
| 6 |
.env
|
|
|
|
|
|
| 2 |
.idea/
|
| 3 |
data/
|
| 4 |
vector_stores/
|
| 5 |
+
*/__pycache__/
|
| 6 |
.env
|
| 7 |
+
__pycache__/
|
app.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
import time
|
| 3 |
-
|
| 4 |
import gradio as gr
|
| 5 |
from langchain.agents import create_agent
|
| 6 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from langchain.agents import create_agent
|
| 4 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
tools/RetriveBooksDataTool.py
CHANGED
|
@@ -1,17 +1,14 @@
|
|
| 1 |
from langchain.tools import tool
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
@tool
|
| 5 |
-
def retrieve_book_context(query: str
|
| 6 |
-
"""Search
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
query: Search terms to look for
|
| 10 |
-
limit: Maximum number of results to return
|
| 11 |
-
"""
|
| 12 |
-
retrieved_docs = vector_store.similarity_search(query, k=2)
|
| 13 |
serialized = "\n\n".join(
|
| 14 |
(f"Source: {doc.metadata}\nContent: {doc.page_content}")
|
| 15 |
for doc in retrieved_docs
|
| 16 |
)
|
| 17 |
-
return serialized
|
|
|
|
| 1 |
from langchain.tools import tool
|
| 2 |
+
from rag import get_books_vector_store
|
| 3 |
|
| 4 |
|
| 5 |
@tool
|
| 6 |
+
def retrieve_book_context(query: str):
|
| 7 |
+
"""Search for relevant book context for a given query."""
|
| 8 |
+
vector_store = get_books_vector_store()
|
| 9 |
+
retrieved_docs = vector_store.similarity_search(query, k=3)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
serialized = "\n\n".join(
|
| 11 |
(f"Source: {doc.metadata}\nContent: {doc.page_content}")
|
| 12 |
for doc in retrieved_docs
|
| 13 |
)
|
| 14 |
+
return serialized
|
util/aws/__pycache__/S3Access.cpython-312.pyc
DELETED
|
Binary file (1.15 kB)
|
|
|
util/aws/__pycache__/__init__.cpython-312.pyc
DELETED
|
Binary file (212 Bytes)
|
|
|