Skip to content

Commit

Permalink
Merge pull request #67 from Azure-Samples/azure-functions-v2-refactor
Browse files Browse the repository at this point in the history
Azure functions v2 refactor
  • Loading branch information
ruoccofabrizio authored Nov 9, 2023
2 parents be0490d + 62d3227 commit 90131b0
Show file tree
Hide file tree
Showing 112 changed files with 108 additions and 289 deletions.
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"azureFunctions.deploySubpath": "backend",
"azureFunctions.deploySubpath": "code\\batch",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": "..\\.venv",
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen"
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectLanguageModel": 2
}
20 changes: 0 additions & 20 deletions backend/AddURLEmbeddings/function.json

This file was deleted.

3 changes: 0 additions & 3 deletions backend/AddURLEmbeddings/sample.dat

This file was deleted.

12 changes: 0 additions & 12 deletions backend/BatchPushResults/function.json

This file was deleted.

20 changes: 0 additions & 20 deletions backend/BatchStartProcessing/function.json

This file was deleted.

166 changes: 0 additions & 166 deletions backend/utilities/QuestionHandler.py

This file was deleted.

2 changes: 2 additions & 0 deletions backend/Admin.py → code/admin/Admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from dotenv import load_dotenv
load_dotenv()

import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

logger = logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel(logging.WARNING)

Expand Down
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import requests
from azure.storage.blob import BlobServiceClient, generate_blob_sas, ContentSettings
import urllib.parse
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from utilities.helpers.ConfigHelper import ConfigHelper
from dotenv import load_dotenv
load_dotenv()
Expand All @@ -28,7 +30,8 @@ def remote_convert_files_and_add_embeddings(process_all=False):
backend_url = urllib.parse.urljoin(os.getenv('BACKEND_URL','http://localhost:7071'), "/api/BatchStartProcessing")
params = {}
if os.getenv('FUNCTION_KEY') != None:
params['clientKey'] = os.getenv('FUNCTION_KEY')
params['code'] = os.getenv('FUNCTION_KEY')
params['clientId'] = "clientKey"
if process_all:
params['process_all'] = "true"
try:
Expand All @@ -43,7 +46,8 @@ def remote_convert_files_and_add_embeddings(process_all=False):
def add_urls():
params = {}
if os.getenv('FUNCTION_KEY') != None:
params['clientKey'] = os.getenv('FUNCTION_KEY')
params['code'] = os.getenv('FUNCTION_KEY')
params['clientId'] = "clientKey"
urls = st.session_state['urls'].split('\n')
for url in urls:
body = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import traceback
import logging
import pandas as pd
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from utilities.helpers.AzureSearchHelper import AzureSearchHelper
from dotenv import load_dotenv
load_dotenv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import traceback
import logging
from dotenv import load_dotenv

import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from utilities.helpers.ConfigHelper import ConfigHelper


load_dotenv()

logger = logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel(logging.WARNING)
Expand Down
9 changes: 5 additions & 4 deletions app.py → code/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

from flask import Flask, Response, request, jsonify
from dotenv import load_dotenv
from backend.utilities.QuestionHandler import QuestionHandler
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

load_dotenv()
load_dotenv(os.path.join(os.path.dirname(__file__), '..', '..', '.env')) # Load environment variables from .env file

app = Flask(__name__)

Expand Down Expand Up @@ -256,7 +257,7 @@ def conversation_azure_byod():

@app.route("/api/conversation/custom", methods=["GET","POST"])
def conversation_custom():
from backend.utilities.helpers.OrchestratorHelper import Orchestrator, OrchestrationSettings
from utilities.helpers.OrchestratorHelper import Orchestrator, OrchestrationSettings
message_orchestrator = Orchestrator()

try:
Expand All @@ -267,7 +268,7 @@ def conversation_custom():
for i,k in enumerate(user_assistent_messages):
if i % 2 == 0:
chat_history.append((user_assistent_messages[i]['content'],user_assistent_messages[i+1]['content']))
from backend.utilities.helpers.ConfigHelper import ConfigHelper
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)

response_obj = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions code/app/static/assets/Azure-d0a62656.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions code/app/static/assets/Send-a9ab2367.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/app/static/favicon.ico
Binary file not shown.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions code/batch/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions"
]
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import logging, traceback

import azure.functions as func
import sys
sys.path.append("..")
from utilities.helpers.DocumentProcessorHelper import DocumentProcessor
from utilities.helpers.ConfigHelper import ConfigHelper

def main(req: func.HttpRequest) -> func.HttpResponse:
bp_add_url_embeddings = func.Blueprint()

@bp_add_url_embeddings.route(route="AddURLEmbeddings")
def add_url_embeddings(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
# Get Url from request
url = req.params.get('url')
Expand Down
Loading

0 comments on commit 90131b0

Please sign in to comment.