Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bmquinn committed Jun 26, 2023
1 parent c81d392 commit a172b05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
14 changes: 9 additions & 5 deletions python/src/handlers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ def handler(event, context):
}
question = get_query(event)
index_name = get_param(event, "index", "Work")
text_key = get_param(event, "text_key", "title")
attributes = get_param(event, "attributes", "identifier,title").split(",")
attributes.append("source")
text_key = get_param(event, "text_key", "title")
attributes = get_param(event,
"attributes",
"identifier,title,source,alternate_title,contributor,create_date,creator,date_created,description,genre,keywords,language,location,physical_description_material,physical_description_size,scope_and_contents,style_period,subject,table_of_contents,technique").split(",")

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())
retriever=weaviate.as_retriever(),
return_source_documents=True)

response = chain({"question": question})

Expand All @@ -44,7 +48,7 @@ def handler(event, context):
"headers": {
"Content-Type": "application/json"
},
"body": json.dumps(response)
"body": response
}


Expand Down
5 changes: 1 addition & 4 deletions python/src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ def weaviate_vector_store(index_name: str, text_key: str, attributes: List[str]

client = weaviate.Client(
url=weaviate_url,
auth_client_secret=auth_config,
additional_headers={
"X-OpenAI-Api-Key": openai_api_key
}
auth_client_secret=auth_config
)
return Weaviate(client=client,
index_name=index_name,
Expand Down

0 comments on commit a172b05

Please sign in to comment.