-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.py
27 lines (21 loc) · 1.07 KB
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from constants import store
from langchain.schema import SystemMessage
from langchain.chat_models import ChatOpenAI
from langchain.chains import RetrievalQA
chat_bot = ChatOpenAI(model_name="gpt-3.5-turbo-0613", temperature=0.8)
chat_bot(
[
SystemMessage(content='''The context I have you is about the "Legend of Zelda" series. The questions I am about to ask you are about this game series. Use the context given and your knowledge about the games to answer my questions.''')
]
)
retriever = store.as_retriever()
retriever.search_kwargs = {"where_str": "embedding IS NOT NULL", "k": 13}
qa_chain = RetrievalQA.from_chain_type(
chat_bot,
retriever=retriever
)
def ask(question):
return qa_chain({"query": f"""The context given relates to the "Legend of Zelda" game series. Answer my question based on the given context and be sure to make your answer as long as possible. If you don't know how to respond, please ask me to be more specific. Question: {question}"""})["result"]
if __name__ == "__main__":
while True:
print(ask(input("question: ")))