embedder
Browse files
rag.py
CHANGED
@@ -21,7 +21,13 @@ from sentence_transformers import SentenceTransformer
|
|
21 |
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", device="cpu")
|
22 |
embedder = dspy.Embedder(model.encode)
|
23 |
"""
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
class RecommendProduct(dspy.Signature):
|
26 |
"""
|
27 |
Recommend RBC financial product based on verbatim
|
|
|
21 |
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", device="cpu")
|
22 |
embedder = dspy.Embedder(model.encode)
|
23 |
"""
|
24 |
+
|
25 |
+
import numpy as np
|
26 |
+
def my_embedder(texts):
|
27 |
+
return np.random.rand(len(texts), 10)
|
28 |
+
|
29 |
+
embedder = dspy.Embedder(my_embedder)
|
30 |
+
#embedder = dspy.Embedder('huggingface/BAAI/bge-small-en-v1.5')
|
31 |
class RecommendProduct(dspy.Signature):
|
32 |
"""
|
33 |
Recommend RBC financial product based on verbatim
|
tool.py
CHANGED
@@ -14,7 +14,7 @@ search_client = TavilyClient(api_key=os.environ["T_TOKEN"])
|
|
14 |
|
15 |
INST="""Recommend banking financial product based on verbatim"""
|
16 |
def web_search(query: str) -> list[str]:
|
17 |
-
"""Run a web search
|
18 |
response = search_client.search(query)
|
19 |
return [r["content"] for r in response["results"]]
|
20 |
|
@@ -23,5 +23,5 @@ agent = dspy.ReAct("verbatim -> product", tools=[Tool(web_search)])
|
|
23 |
customer="Low APR and great customer service. I would highly recommend if you’re looking for a great credit card company and looking to rebuild your credit. I have had my credit limit increased annually and the annual fee is very low."
|
24 |
|
25 |
def rival_product(customer:str):
|
26 |
-
prediction = agent(verbatim=f"Which banking product best serve this customer needs
|
27 |
return prediction.product
|
|
|
14 |
|
15 |
INST="""Recommend banking financial product based on verbatim"""
|
16 |
def web_search(query: str) -> list[str]:
|
17 |
+
"""Run a web search to return the top 3 personal banking product that satisfy the query"""
|
18 |
response = search_client.search(query)
|
19 |
return [r["content"] for r in response["results"]]
|
20 |
|
|
|
23 |
customer="Low APR and great customer service. I would highly recommend if you’re looking for a great credit card company and looking to rebuild your credit. I have had my credit limit increased annually and the annual fee is very low."
|
24 |
|
25 |
def rival_product(customer:str):
|
26 |
+
prediction = agent(verbatim=f"Which banking product name best serve this customer needs: {customer}")
|
27 |
return prediction.product
|