Skip to content

feat!: implement chat endpoint switch #905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6174b34
Attribute to choose between custom and byod conversation types
gaurarpit May 14, 2024
1ebdea0
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 14, 2024
34ecb33
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 15, 2024
f12ef32
add the /conversation binding to use the ChatConversationType as an i…
gaurarpit May 15, 2024
4774eeb
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 15, 2024
65a7688
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 15, 2024
7c20822
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 15, 2024
695f3ed
Merge remote-tracking branch 'origin/arpit/feature/implement-chat-end…
gaurarpit May 15, 2024
d95fd89
Merge remote-tracking branch 'origin/arpit/feature/implement-chat-end…
gaurarpit May 15, 2024
73e7fbd
Merge remote-tracking branch 'origin/arpit/feature/implement-chat-end…
gaurarpit May 15, 2024
e4ac540
fix typo
gaurarpit May 16, 2024
3f9fbd8
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 16, 2024
2a983dc
add the chat conversation type to main.json
gaurarpit May 16, 2024
7630b59
add bicep params and make changes to call the /conversation from the …
gaurarpit May 16, 2024
5f3209c
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 16, 2024
629339c
undo premature bindings removal
gaurarpit May 16, 2024
5b4221e
update var name to a better suggestion from CHAT_CONVERSATION_TYPE to…
gaurarpit May 16, 2024
2eecd7b
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 16, 2024
315a63d
Attribute to choose between custom and byod conversation types
gaurarpit May 14, 2024
03a8070
add the /conversation binding to use the ChatConversationType as an i…
gaurarpit May 15, 2024
e838b66
fix typo
gaurarpit May 16, 2024
130bfc4
add the chat conversation type to main.json
gaurarpit May 16, 2024
813c312
add bicep params and make changes to call the /conversation from the …
gaurarpit May 16, 2024
f0bd85e
undo premature bindings removal
gaurarpit May 16, 2024
2573a04
update var name to a better suggestion from CHAT_CONVERSATION_TYPE to…
gaurarpit May 16, 2024
ce99d31
Merge remote-tracking branch 'origin/arpit/feature/implement-chat-end…
gaurarpit May 16, 2024
d37946b
merged and ran pre-commit again.
gaurarpit May 16, 2024
d64a19f
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 17, 2024
f8cc67a
Merge branch 'main' into arpit/feature/implement-chat-endpoint-switch
gaurarpit May 21, 2024
2a25b69
chore: force poetry to use python 3.11
liammoat May 21, 2024
072a2f8
fix: use await when invoking conversation_custom
liammoat May 21, 2024
37b4f2d
test: added test for conversation flow
liammoat May 21, 2024
6e1a080
refactor: removing conversation flow specific endpoints
liammoat May 21, 2024
dea40fb
test: update test_app to use env_helper_mock, supporting new endpoint
liammoat May 21, 2024
d12b2dc
test: test for failure condition on conversation flow
liammoat May 21, 2024
7f0fd5f
Merge remote-tracking branch 'origin/main' into arpit/feature/impleme…
liammoat May 21, 2024
ea33999
Merge remote-tracking branch 'origin/main' into arpit/feature/impleme…
liammoat May 21, 2024
42257f0
Update merged test with new endpoints.
gaurarpit May 21, 2024
e9c860b
refactor: switch to Enum of conversation flow
liammoat May 22, 2024
496c553
refactor: pylint for couple of lines
liammoat May 22, 2024
7ffe361
docs: documentation for conversation flow options
liammoat May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ AZURE_SPEECH_SERVICE_REGION=
AZURE_AUTH_TYPE=keys
USE_KEY_VAULT=true
AZURE_KEY_VAULT_ENDPOINT=
# Chat conversation type to decide between custom or byod (bring your own data) conversation type
CHAT_CONVERSATION_TYPE=
4 changes: 4 additions & 0 deletions code/backend/batch/utilities/helpers/env_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def __load_config(self, **kwargs) -> None:
self.ORCHESTRATION_STRATEGY = os.getenv(
"ORCHESTRATION_STRATEGY", "openai_function"
)
# Conversation Type - which chooses between custom or byod
self.CHAT_CONVERSATION_TYPE = os.getenv(
"CHAT_CONVERSATION_TYPE", "custom"
)
# Speech Service
self.AZURE_SPEECH_SERVICE_NAME = os.getenv("AZURE_SPEECH_SERVICE_NAME", "")
self.AZURE_SPEECH_SERVICE_REGION = os.getenv("AZURE_SPEECH_SERVICE_REGION")
Expand Down
8 changes: 8 additions & 0 deletions code/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ async def conversation_custom():
500,
)

@app.route("/api/conversation", methods=["POST"])
async def conversation():
conversation_type = env_helper.CHAT_CONVERSATION_TYPE
if conversation_type == 'custom':
return conversation_custom()
else:
return conversation_azure_byod()

@app.route("/api/speech", methods=["GET"])
def speech_config():
try:
Expand Down
4 changes: 3 additions & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ module web './app/web.bicep' = if (hostingModel == 'code') {
AZURE_SPEECH_SERVICE_REGION: location
AZURE_SPEECH_RECOGNIZER_LANGUAGES: recognizedLanguages
ORCHESTRATION_STRATEGY: orchestrationStrategy
CHAT_CONVERSATION_TYPE: chatConversationType
LOGLEVEL: logLevel
}
}
Expand Down Expand Up @@ -596,6 +597,7 @@ module web_docker './app/web.bicep' = if (hostingModel == 'container') {
AZURE_SPEECH_SERVICE_REGION: location
AZURE_SPEECH_RECOGNIZER_LANGUAGES: recognizedLanguages
ORCHESTRATION_STRATEGY: orchestrationStrategy
CHAT_CONVERSATION_TYPE: chatConversationType
LOGLEVEL: logLevel
}
}
Expand Down Expand Up @@ -662,7 +664,6 @@ module adminweb './app/adminweb.bicep' = if (hostingModel == 'code') {
BACKEND_URL: 'https://${functionName}.azurewebsites.net'
DOCUMENT_PROCESSING_QUEUE_NAME: queueName
FUNCTION_KEY: clientKey
ORCHESTRATION_STRATEGY: orchestrationStrategy
LOGLEVEL: logLevel
}
}
Expand Down Expand Up @@ -1042,3 +1043,4 @@ output USE_KEY_VAULT bool = useKeyVault
output FRONTEND_WEBSITE_NAME string = hostingModel == 'code' ? web.outputs.FRONTEND_API_URI : web_docker.outputs.FRONTEND_API_URI
output ADMIN_WEBSITE_NAME string = hostingModel == 'code' ? adminweb.outputs.WEBSITE_ADMIN_URI : adminweb_docker.outputs.WEBSITE_ADMIN_URI
output LOGLEVEL string = logLevel
output CHAT_CONVERSATION_TYPE string = chatConversationType
1 change: 1 addition & 0 deletions infra/main.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ param azureSearchUseSemanticSearch = readEnvironmentVariable('AZURE_SEARCH_USE_S
param orchestrationStrategy = readEnvironmentVariable('ORCHESTRATION_STRATEGY', 'openai_function')
param logLevel = readEnvironmentVariable('LOGLEVEL', 'INFO')
param recognizedLanguages = readEnvironmentVariable('AZURE_SPEECH_RECOGNIZER_LANGUAGES', 'en-US,fr-FR,de-DE,it-IT')
param chatConversationType = readEnvironmentVariable('CHAT_CONVERSATION_TYPE', 'custom')

// OpenAI parameters
param azureOpenAIApiVersion = readEnvironmentVariable('AZURE_OPENAI_API_VERSION', '2024-02-01')
Expand Down
Loading