reconstruct object in rag node

This commit is contained in:
seehi 2024-03-07 12:07:27 +08:00 committed by betterwang
parent f37828c75e
commit 38e8adf9b4
2 changed files with 39 additions and 15 deletions

View file

@ -22,6 +22,18 @@ TRAVEL_QUESTION = "What does Bob like?"
LLM_TIP = "If you not sure, just answer I don't know"
class Player(BaseModel):
"""To demonstrate rag add objs"""
name: str = ""
goal: str = "Win The 100-meter Sprint"
tool: str = "Red Bull Energy Drink"
def rag_key(self) -> str:
"""For search"""
return self.goal
class RAGExample:
"""Show how to use RAG."""
@ -95,17 +107,6 @@ class RAGExample:
self._print_title("RAG Add Objs")
class Player(BaseModel):
"""Player"""
name: str = ""
goal: str = "Win The 100-meter Sprint"
tool: str = "Red Bull Energy Drink"
def rag_key(self) -> str:
"""For search"""
return self.goal
player = Player(name="Mike")
question = f"{player.rag_key()}{LLM_TIP}"
@ -118,7 +119,7 @@ class RAGExample:
print("[Object Detail]")
player: Player = nodes[0].metadata["obj"]
print(player)
print(player.name)
async def rag_chromadb(self):
"""This example show how to use chromadb. how to save and load index. will print something like: