Skip to content

Commit

Permalink
Only add embedding parameters for vector query types (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Widder <sawidder@microsoft.com>
  • Loading branch information
sarah-widder and sarah-widder committed Oct 24, 2023
1 parent 310bf7c commit 354b62b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,21 @@ def prepare_body_headers_with_data(request):
"queryType": query_type,
"semanticConfiguration": AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG if AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG else "",
"roleInformation": AZURE_OPENAI_SYSTEM_MESSAGE,
"embeddingDeploymentName": AZURE_OPENAI_EMBEDDING_NAME,
"embeddingEndpoint": AZURE_OPENAI_EMBEDDING_ENDPOINT if len(AZURE_OPENAI_EMBEDDING_NAME) == 0 else "",
"embeddingKey": AZURE_OPENAI_EMBEDDING_KEY if len(AZURE_OPENAI_EMBEDDING_NAME) == 0 else "",
"filter": filter,
"strictness": int(AZURE_SEARCH_STRICTNESS)
}
}
]
}

if "vector" in query_type.lower():
if AZURE_OPENAI_EMBEDDING_NAME:
body["dataSources"][0]["parameters"]["embeddingDeploymentName"] = AZURE_OPENAI_EMBEDDING_NAME
else:
body["dataSources"][0]["parameters"]["embeddingEndpoint"] = AZURE_OPENAI_EMBEDDING_ENDPOINT
body["dataSources"][0]["parameters"]["embeddingKey"] = AZURE_OPENAI_EMBEDDING_KEY


headers = {
'Content-Type': 'application/json',
'api-key': AZURE_OPENAI_KEY,
Expand Down

0 comments on commit 354b62b

Please sign in to comment.