Spaces:
Paused
Paused
debug
Browse files- app.py +7 -2
- retriever.py +0 -11
app.py
CHANGED
|
@@ -13,7 +13,6 @@ import datasets
|
|
| 13 |
from langchain.docstore.document import Document
|
| 14 |
from langgraph.graph import START, StateGraph
|
| 15 |
from langchain_community.retrievers import BM25Retriever
|
| 16 |
-
from retriever import extract_text
|
| 17 |
|
| 18 |
HUGGINGFACEHUB_API_TOKEN = os.environ["HUGGINGFACEHUB_API_TOKEN"]
|
| 19 |
login(token=HUGGINGFACEHUB_API_TOKEN)
|
|
@@ -38,6 +37,13 @@ docs = [
|
|
| 38 |
|
| 39 |
bm25_retriever = BM25Retriever.from_documents(docs)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
llm = HuggingFaceEndpoint(
|
| 43 |
repo_id="HuggingFaceH4/zephyr-7b-beta",
|
|
@@ -76,7 +82,6 @@ guest_info_tool = Tool(
|
|
| 76 |
tools = [guest_info_tool]
|
| 77 |
chat_with_tools = model.bind_tools(tools)
|
| 78 |
|
| 79 |
-
|
| 80 |
# Generate the AgentState and Agent graph
|
| 81 |
class AgentState(TypedDict):
|
| 82 |
messages: Annotated[list[AnyMessage], add_messages]
|
|
|
|
| 13 |
from langchain.docstore.document import Document
|
| 14 |
from langgraph.graph import START, StateGraph
|
| 15 |
from langchain_community.retrievers import BM25Retriever
|
|
|
|
| 16 |
|
| 17 |
HUGGINGFACEHUB_API_TOKEN = os.environ["HUGGINGFACEHUB_API_TOKEN"]
|
| 18 |
login(token=HUGGINGFACEHUB_API_TOKEN)
|
|
|
|
| 37 |
|
| 38 |
bm25_retriever = BM25Retriever.from_documents(docs)
|
| 39 |
|
| 40 |
+
def extract_text(query: str) -> str:
|
| 41 |
+
"""Retrieves detailed information about gala guests based on their name or relation."""
|
| 42 |
+
results = bm25_retriever.invoke(query)
|
| 43 |
+
if results:
|
| 44 |
+
return "\n\n".join([doc.page_content for doc in results[:3]])
|
| 45 |
+
else:
|
| 46 |
+
return "No matching guest information found."
|
| 47 |
|
| 48 |
llm = HuggingFaceEndpoint(
|
| 49 |
repo_id="HuggingFaceH4/zephyr-7b-beta",
|
|
|
|
| 82 |
tools = [guest_info_tool]
|
| 83 |
chat_with_tools = model.bind_tools(tools)
|
| 84 |
|
|
|
|
| 85 |
# Generate the AgentState and Agent graph
|
| 86 |
class AgentState(TypedDict):
|
| 87 |
messages: Annotated[list[AnyMessage], add_messages]
|
retriever.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
from langchain_community.retrievers import BM25Retriever
|
| 2 |
-
from langchain.tools import Tool
|
| 3 |
-
|
| 4 |
-
def extract_text(query: str) -> str:
|
| 5 |
-
"""Retrieves detailed information about gala guests based on their name or relation."""
|
| 6 |
-
results = bm25_retriever.invoke(query)
|
| 7 |
-
if results:
|
| 8 |
-
return "\n\n".join([doc.page_content for doc in results[:3]])
|
| 9 |
-
else:
|
| 10 |
-
return "No matching guest information found."
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|