Spaces:
Runtime error
Runtime error
Update retriever.py
Browse files- retriever.py +3 -4
retriever.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import datasets
|
| 2 |
from langchain.docstore.document import Document
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Load the dataset
|
| 5 |
games_dataset = datasets.load_dataset("nateraw/list-of-bestselling-pc-games", split="train")
|
|
@@ -21,9 +23,6 @@ docs = [
|
|
| 21 |
for game in games_dataset
|
| 22 |
]
|
| 23 |
|
| 24 |
-
from langchain_community.retrievers import BM25Retriever
|
| 25 |
-
from langchain.tools import Tool
|
| 26 |
-
|
| 27 |
bm25_retriever = BM25Retriever.from_documents(docs)
|
| 28 |
|
| 29 |
def extract_text(query: str) -> str:
|
|
@@ -34,7 +33,7 @@ def extract_text(query: str) -> str:
|
|
| 34 |
else:
|
| 35 |
return "No matching game information found."
|
| 36 |
|
| 37 |
-
|
| 38 |
name="game_info_retriever",
|
| 39 |
func=extract_text,
|
| 40 |
description="Retrieves detailed information about games based on their name or relation."
|
|
|
|
| 1 |
import datasets
|
| 2 |
from langchain.docstore.document import Document
|
| 3 |
+
from langchain_community.retrievers import BM25Retriever
|
| 4 |
+
from langchain.tools import Tool
|
| 5 |
|
| 6 |
# Load the dataset
|
| 7 |
games_dataset = datasets.load_dataset("nateraw/list-of-bestselling-pc-games", split="train")
|
|
|
|
| 23 |
for game in games_dataset
|
| 24 |
]
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
bm25_retriever = BM25Retriever.from_documents(docs)
|
| 27 |
|
| 28 |
def extract_text(query: str) -> str:
|
|
|
|
| 33 |
else:
|
| 34 |
return "No matching game information found."
|
| 35 |
|
| 36 |
+
game_info_tool = Tool(
|
| 37 |
name="game_info_retriever",
|
| 38 |
func=extract_text,
|
| 39 |
description="Retrieves detailed information about games based on their name or relation."
|