Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Jun 23, 2023
1 parent 6441b82 commit c81d392
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions python/src/handlers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import os
import setup
from langchain.chains import RetrievalQAWithSourcesChain


from langchain.agents.agent_toolkits import (
create_vectorstore_agent,
Expand All @@ -28,17 +30,14 @@ def handler(event, context):
weaviate = setup.weaviate_vector_store(index_name=index_name,
text_key=text_key,
attributes=attributes)

client = setup.openai_chat_client()
chain = RetrievalQAWithSourcesChain.from_chain_type(
client,
chain_type="stuff",
retriever=weaviate.as_retriever())

vectorstore_info = VectorStoreInfo(
name=index_name,
description="NULDC Works",
vectorstore=weaviate,
)
llm = setup.openai_chat_client()
toolkit = VectorStoreToolkit(vectorstore_info=vectorstore_info, llm=llm)
agent_executor = create_vectorstore_agent(llm=llm, toolkit=toolkit, verbose=True)
print(f"QUESTION: {question}")
response = agent_executor.run(question)
response = chain({"question": question})

return {
"statusCode": 200,
Expand Down

0 comments on commit c81d392

Please sign in to comment.