|
from langchain.agents import tool |
|
from langchain_openai import OpenAIEmbeddings |
|
from langchain_community.vectorstores.faiss import FAISS |
|
from langchain.chains import RetrievalQA |
|
from langchain_openai import OpenAI |
|
|
|
|
|
@tool |
|
def FAQ(input: str): |
|
"""Provides answers to questions that students might have about Rise and Futureme. Please add ### to the beginning of your answer""" |
|
|
|
|
|
embeddings = OpenAIEmbeddings() |
|
persisted_vectorstore = FAISS.load_local("_rise_faq_db", embeddings) |
|
|
|
|
|
qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=persisted_vectorstore.as_retriever()) |
|
result = qa.invoke(input) |
|
return result |
|
|
|
@tool |
|
def recommend_activity(question: str): |
|
"""Recommends an activity from Rise catalogue.""" |
|
|
|
|
|
embeddings = OpenAIEmbeddings() |
|
persisted_vectorstore = FAISS.load_local("_rise_product_db", embeddings) |
|
|
|
|
|
qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=persisted_vectorstore.as_retriever()) |
|
result = qa.invoke(input) |
|
return result |
|
|
|
@tool |
|
def placeholder_tool(): |
|
"""This is just a placeholder function""" |
|
return "placeholder" |
|
|
|
tools = [placeholder_tool, FAQ] |