Skip to content

Commit

Permalink
embedding model name changes (#335)
Browse files Browse the repository at this point in the history
Co-authored-by: David Moses <[email protected]>
  • Loading branch information
davidm00 and David Moses committed Oct 23, 2023
1 parent 29085b6 commit 310bf7c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
3 changes: 1 addition & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ AZURE_OPENAI_SYSTEM_MESSAGE=You are an AI assistant that helps people find infor
AZURE_OPENAI_PREVIEW_API_VERSION=2023-06-01-preview
AZURE_OPENAI_STREAM=True
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_EMBEDDING_ENDPOINT=
AZURE_OPENAI_EMBEDDING_KEY=
AZURE_OPENAI_EMBEDDING_NAME=
AZURE_COSMOSDB_ACCOUNT=
AZURE_COSMOSDB_DATABASE=
AZURE_COSMOSDB_CONVERSATIONS_CONTAINER=
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ Please see the [section below](#add-an-identity-provider) for important informat
- `AZURE_SEARCH_QUERY_TYPE`
- `AZURE_SEARCH_PERMITTED_GROUPS_COLUMN`
- `AZURE_SEARCH_STRICTNESS`
- `AZURE_OPENAI_EMBEDDING_ENDPOINT`
- `AZURE_OPENAI_EMBEDDING_KEY`
- `AZURE_OPENAI_EMBEDDING_NAME`

3. Start the app with `start.cmd`. This will build the frontend, install backend dependencies, and then start the app.
4. You can see the local running app at http://127.0.0.1:5000.
Expand Down Expand Up @@ -198,8 +197,7 @@ Note: settings starting with `AZURE_SEARCH` are only needed when using Azure Ope
|AZURE_OPENAI_SYSTEM_MESSAGE|You are an AI assistant that helps people find information.|A brief description of the role and tone the model should use|
|AZURE_OPENAI_PREVIEW_API_VERSION|2023-06-01-preview|API version when using Azure OpenAI on your data|
|AZURE_OPENAI_STREAM|True|Whether or not to use streaming for the response|
|AZURE_OPENAI_EMBEDDING_ENDPOINT||The endpoint for your Ada embedding model deployment if using vector search.
|AZURE_OPENAI_EMBEDDING_KEY||The key for the Azure OpenAI resource with the Ada deployment to use with vector search.|
|AZURE_OPENAI_EMBEDDING_NAME||The name of your embedding model deployment if using vector search.


## Contributing
Expand Down
10 changes: 5 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def assets(path):
AZURE_OPENAI_MODEL_NAME = os.environ.get("AZURE_OPENAI_MODEL_NAME", "gpt-35-turbo-16k") # Name of the model, e.g. 'gpt-35-turbo-16k' or 'gpt-4'
AZURE_OPENAI_EMBEDDING_ENDPOINT = os.environ.get("AZURE_OPENAI_EMBEDDING_ENDPOINT")
AZURE_OPENAI_EMBEDDING_KEY = os.environ.get("AZURE_OPENAI_EMBEDDING_KEY")
AZURE_OPENAI_EMBEDDING_NAME = os.environ.get("AZURE_OPENAI_EMBEDDING_NAME", "")


SHOULD_STREAM = True if AZURE_OPENAI_STREAM.lower() == "true" else False
Expand Down Expand Up @@ -186,8 +187,9 @@ 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,
"embeddingEndpoint": AZURE_OPENAI_EMBEDDING_ENDPOINT,
"embeddingKey": AZURE_OPENAI_EMBEDDING_KEY,
"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)
}
Expand Down Expand Up @@ -346,11 +348,9 @@ def conversation_with_data(request_body):
result['history_metadata'] = history_metadata
return Response(format_as_ndjson(result), status=status_code)


else:
return Response(stream_with_data(body, headers, endpoint, history_metadata), mimetype='text/event-stream')


def stream_without_data(response, history_metadata={}):
responseText = ""
for line in response:
Expand Down Expand Up @@ -707,4 +707,4 @@ def generate_title(conversation_messages):
return messages[-2]['content']

if __name__ == "__main__":
app.run()
app.run()
3 changes: 1 addition & 2 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ output AZURE_OPENAI_MODEL string = openAIModel
output AZURE_OPENAI_MODEL_NAME string = openAIModelName
output AZURE_OPENAI_SKU_NAME string = openAi.outputs.skuName
output AZURE_OPENAI_KEY string = openAi.outputs.key
output AZURE_OPENAI_EMBEDDING_KEY string = openAi.outputs.key
output AZURE_OPENAI_EMBEDDING_ENDPOINT string = '${openAi.outputs.endpoint}/openai/deployments/${embeddingDeploymentName}/embeddings?api-version=2023-06-01-preview'
output AZURE_OPENAI_EMBEDDING_NAME string = '${embeddingDeploymentName}'
output AZURE_OPENAI_TEMPERATURE int = openAITemperature
output AZURE_OPENAI_TOP_P int = openAITopP
output AZURE_OPENAI_MAX_TOKENS int = openAIMaxTokens
Expand Down
19 changes: 4 additions & 15 deletions infrastructure/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,11 @@
"description": "Azure Search Strictness"
}
},
"AzureOpenAIEmbeddingEndpoint": {
"AzureOpenAIEmbeddingName": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Azure OpenAI Embedding Endpoint"
}
},
"AzureOpenAIEmbeddingKey": {
"type": "securestring",
"defaultValue": "",
"metadata": {
"description": "Azure OpenAI Embedding Key"
"description": "Azure OpenAI Embedding Deployment Name"
}
},
"WebAppEnableChatHistory": {
Expand Down Expand Up @@ -417,12 +410,8 @@
"value": "[parameters('AzureSearchStrictness')]"
},
{
"name": "AZURE_OPENAI_EMBEDDING_ENDPOINT",
"value": "[parameters('AzureOpenAIEmbeddingEndpoint')]"
},
{
"name": "AZURE_OPENAI_EMBEDDING_KEY",
"value": "[parameters('AzureOpenAIEmbeddingKey')]"
"name": "AZURE_OPENAI_EMBEDDING_NAME",
"value": "[parameters('AzureOpenAIEmbeddingName')]"
},
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
Expand Down

0 comments on commit 310bf7c

Please sign in to comment.