Skip to content

Commit

Permalink
Merge pull request #91 from hunterjam/main
Browse files Browse the repository at this point in the history
PR - Speech to Text and Teams Extension
  • Loading branch information
gmndrg authored Dec 13, 2023
2 parents 3a3b699 + a8f227d commit f39bd47
Show file tree
Hide file tree
Showing 111 changed files with 6,585 additions and 523 deletions.
5 changes: 3 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ AZURE_CONTENT_SAFETY_ENDPOINT=
AZURE_CONTENT_SAFETY_KEY=
# Orchestration strategy. Use Azure OpenAI Functions (openai_functions) or LangChain (langchain) for messages orchestration. If you are using a new model version 0613 select "openai_functions" (or "langchain"), if you are using a 0314 model version select "langchain"
ORCHESTRATION_STRATEGY=openai_functions
AZURE_CONTENT_SAFETY_ENDPOINT=
AZURE_CONTENT_SAFETY_KEY=
#Speech-to-text feature
AZURE_SPEECH_SERVICE_KEY=
AZURE_SPEECH_SERVICE_REGION=
2 changes: 1 addition & 1 deletion .github/workflows/AdminWebApp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
docker build . --file docker/AdminWebApp.Dockerfile --cache-from fruoccopublic.azurecr.io/rag-adminwebapp:latest --tag fruoccopublic.azurecr.io/rag-adminwebapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker tag fruoccopublic.azurecr.io/rag-adminwebapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER fruoccopublic.azurecr.io/rag-adminwebapp:latest;
docker push fruoccopublic.azurecr.io/rag-adminwebapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker push fruoccopublic.azurecr.io/rag-adminwebapp:latest;
docker push fruoccopublic.azurecr.io/rag-adminwebapp:latest;
30 changes: 30 additions & 0 deletions .github/workflows/CwyodBackend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CWYOD Backend Docker Image

on:
push:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:

- name: Docker Login
uses: docker/login-action@v2.2.0
with:
registry: fruoccopublic.azurecr.io
username: fruoccopublic
password: ${{ secrets.DOCKER_PASSWORD }}

- uses: actions/checkout@v3
- name: Build the Docker image
run:
docker pull fruoccopublic.azurecr.io/cwyod_backend:latest || true;
docker build . --file extensions/docker/Backend.Dockerfile --cache-from fruoccopublic.azurecr.io/cwyod_backend:latest --tag fruoccopublic.azurecr.io/cwyod_backend:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker tag fruoccopublic.azurecr.io/cwyod_backend:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER fruoccopublic.azurecr.io/cwyod_backend:latest;
docker push fruoccopublic.azurecr.io/cwyod_backend:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker push fruoccopublic.azurecr.io/cwyod_backend:latest;

2 changes: 1 addition & 1 deletion .github/workflows/WebApp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
docker build . --file docker/WebApp.Dockerfile --cache-from fruoccopublic.azurecr.io/rag-webapp:latest --tag fruoccopublic.azurecr.io/rag-webapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker tag fruoccopublic.azurecr.io/rag-webapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER fruoccopublic.azurecr.io/rag-webapp:latest;
docker push fruoccopublic.azurecr.io/rag-webapp:$(date +'%Y-%m-%d')_$GITHUB_RUN_NUMBER;
docker push fruoccopublic.azurecr.io/rag-webapp:latest;
docker push fruoccopublic.azurecr.io/rag-webapp:latest;
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectLanguageModel": 2
"azureFunctions.projectLanguageModel": 2,
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
362 changes: 148 additions & 214 deletions README.md

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions code/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
def static_file(path):
return app.send_static_file(path)

@app.route('/api/config', methods=['GET'])
def get_config():
# Retrieve the environment variables or other configuration data
azure_speech_key = os.getenv('AZURE_SPEECH_SERVICE_KEY')
azure_speech_region = os.getenv('AZURE_SPEECH_SERVICE_REGION')

# Return the configuration data as JSON
return jsonify({
'azureSpeechKey': azure_speech_key,
'azureSpeechRegion': azure_speech_region
})

# ACS Integration Settings
AZURE_SEARCH_SERVICE = os.environ.get("AZURE_SEARCH_SERVICE")
AZURE_SEARCH_INDEX = os.environ.get("AZURE_SEARCH_INDEX")
Expand Down Expand Up @@ -251,9 +263,9 @@ def conversation_azure_byod():
else:
return conversation_without_data(request)
except Exception as e:
logging.exception("Exception in /api/conversation/azure_byod")
return jsonify({"error": str(e)}), 500

errorMessage = str(e)
logging.exception(f"Exception in /api/conversation/azure_byod | {errorMessage}")
return jsonify({"error": "Exception in /api/conversation/azure_byod. See log for more details."}), 500

@app.route("/api/conversation/custom", methods=["GET","POST"])
def conversation_custom():
Expand All @@ -263,11 +275,11 @@ def conversation_custom():
try:
user_message = request.json["messages"][-1]['content']
conversation_id = request.json["conversation_id"]
user_assistent_messages = list(filter(lambda x: x['role'] in ('user','assistant'), request.json["messages"][0:-1]))
user_assistant_messages = list(filter(lambda x: x['role'] in ('user','assistant'), request.json["messages"][0:-1]))
chat_history = []
for i,k in enumerate(user_assistent_messages):
for i,k in enumerate(user_assistant_messages):
if i % 2 == 0:
chat_history.append((user_assistent_messages[i]['content'],user_assistent_messages[i+1]['content']))
chat_history.append((user_assistant_messages[i]['content'],user_assistant_messages[i+1]['content']))
from utilities.helpers.ConfigHelper import ConfigHelper
messages = message_orchestrator.handle_message(user_message=user_message, chat_history=chat_history, conversation_id=conversation_id, orchestrator=ConfigHelper.get_active_config_or_default().orchestrator)

Expand All @@ -284,8 +296,8 @@ def conversation_custom():
return jsonify(response_obj), 200

except Exception as e:
logging.exception("Exception in /api/conversation/custom")
return jsonify({"error": str(e)}), 500

errorMessage = str(e)
logging.exception(f"Exception in /api/conversation/custom | {errorMessage}")
return jsonify({"error": "Exception in /api/conversation/custom. See log for more details."}), 500
if __name__ == "__main__":
app.run()
Loading

0 comments on commit f39bd47

Please sign in to comment.