Skip to content

Commit

Permalink
Fix ruff code style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Jun 23, 2023
1 parent 386d99d commit 131aed4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions python/src/handlers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handler(event, context):
headers = event.get("headers")
token = headers.get("authorization", headers.get("Authorization", None))
print(f"TOKEN: {token}")
if token == None:
if token is None:
for cookie in event.get("cookies", []):
print(f"HAVE A COOKIE: {cookie}")
[k, v] = cookie.split("=", 1)
Expand All @@ -35,8 +35,11 @@ def handler(event, context):
text_key = params.get("text_key", "title")
attributes = params.get("attributes", "identifier,title").split(",")

weaviate = setup.weaviate_vector_store(index_name=index_name, text_key=text_key, attributes=attributes)
result = weaviate.similarity_search_by_text(query=question, additional="certainty")
weaviate = setup.weaviate_vector_store(index_name=index_name,
text_key=text_key,
attributes=attributes)
result = weaviate.similarity_search_by_text(query=question,
additional="certainty")

return {
"statusCode": 200,
Expand Down
10 changes: 6 additions & 4 deletions python/src/setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from langchain.chat_models import AzureChatOpenAI
from langchain.vectorstores import Weaviate
from typing import List
import openai
import os
import jwt
import weaviate

def openai_chat_client():
deployment = os.getenv("AZURE_OPENAI_LLM_DEPLOYMENT_ID")
resource = os.getenv("AZURE_OPENAI_RESOURCE_NAME")
api_key = os.getenv("AZURE_OPENAI_API_KEY")
os.getenv("AZURE_OPENAI_RESOURCE_NAME")
os.getenv("AZURE_OPENAI_API_KEY")

return AzureChatOpenAI(deployment_name=deployment)

Expand All @@ -27,7 +26,10 @@ def weaviate_vector_store(index_name: str, text_key: str, attributes: List[str]
"X-OpenAI-Api-Key": openai_api_key
}
)
return Weaviate(client=client, index_name=index_name, text_key=text_key, attributes=attributes)
return Weaviate(client=client,
index_name=index_name,
text_key=text_key,
attributes=attributes)


def validate_token(token):
Expand Down

0 comments on commit 131aed4

Please sign in to comment.