Skip to content

Commit

Permalink
adding managed identity through out the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
marlenezw committed May 15, 2024
1 parent cf6f011 commit ad4ab05
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/api/api/agents/designer/designer.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ model:
configuration:
type: azure_openai
azure_deployment: ${env:AZURE_OPENAI_DEPLOYMENT_NAME}
api_key: ${env:AZURE_OPENAI_API_KEY"}
api_version: ${env:AZURE_OPENAI_API_VERSION}
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
inputs:
Expand Down
1 change: 0 additions & 1 deletion src/api/api/agents/designer/designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def design(context, instructions, feedback):
# Load prompty with AzureOpenAIModelConfiguration override
configuration = AzureOpenAIModelConfiguration(
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)
Expand Down
2 changes: 2 additions & 0 deletions src/api/api/agents/editor/editor.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ model:
api: chat
configuration:
type: azure_openai
azure_endpoint: ${AZURE_OPENAI_ENDPOINT}
api_version: ${env:AZURE_OPENAI_API_VERSION}
parameters:
max_tokens: 1200
temperature: 0.2
Expand Down
4 changes: 1 addition & 3 deletions src/api/api/agents/editor/editor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

from promptflow.core import Flow
from promptflow.core import Prompty, AzureOpenAIModelConfiguration
import json
import os
Expand All @@ -15,8 +13,8 @@ def edit(article, feedback):
# Load prompty with AzureOpenAIModelConfiguration override
configuration = AzureOpenAIModelConfiguration(
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)
override_model = {
"configuration": configuration,
Expand Down
4 changes: 2 additions & 2 deletions src/api/api/agents/product/ai_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
QueryCaptionType,
QueryAnswerType,
)
from azure.core.credentials import AzureKeyCredential
from azure.identity import DefaultAzureCredential


def retrieve_documentation(
Expand All @@ -19,7 +19,7 @@ def retrieve_documentation(
search_client = SearchClient(
endpoint=os.environ["AZURE_SEARCH_ENDPOINT"],
index_name=index_name,
credential=AzureKeyCredential(os.environ["AZURE_SEARCH_API_KEY"]),
credential=DefaultAzureCredential(),
)

vector_query = VectorizedQuery(
Expand Down
10 changes: 3 additions & 7 deletions src/api/api/agents/product/product.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import os
import json
from typing import Dict, List
import prompty
from openai import AzureOpenAI
import pathlib
from typing import Dict
from promptflow.tools.common import init_azure_openai_client
from api.agents.product.ai_search import retrieve_documentation
from promptflow.connections import AzureOpenAIConnection
from promptflow.core import (AzureOpenAIModelConfiguration, Prompty, tool)
from azure.core.credentials import AzureKeyCredential
from dotenv import load_dotenv

load_dotenv()

def get_context(question, embedding):
Expand All @@ -18,7 +15,6 @@ def get_context(question, embedding):
def get_embedding(question: str):
connection = AzureOpenAIConnection(
azure_deployment="text-embedding-ada-002",
api_key=os.environ["AZURE_OPENAI_API_KEY"],
api_version=os.environ["AZURE_OPENAI_API_VERSION"],
api_base=os.environ["AZURE_OPENAI_ENDPOINT"]
)
Expand Down
1 change: 0 additions & 1 deletion src/api/api/agents/researcher/researcher.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ model:
api: chat
configuration:
type: azure_openai
api_key: ${AZURE_OPENAI_API_KEY}
azure_endpoint: ${AZURE_OPENAI_ENDPOINT}
azure_deployment: gpt-35-turbo
api_version: 2023-07-01-preview
Expand Down
1 change: 1 addition & 0 deletions src/api/api/agents/researcher/researcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

load_dotenv()

#bing does not currently support managed identity
BING_SEARCH_ENDPOINT = os.getenv("BING_SEARCH_ENDPOINT")
BING_SEARCH_KEY = os.getenv("BING_SEARCH_KEY")
BING_HEADERS = {"Ocp-Apim-Subscription-Key": BING_SEARCH_KEY}
Expand Down
1 change: 1 addition & 0 deletions src/api/api/agents/writer/writer.prompty
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ model:
api: chat
configuration:
type: azure_openai
azure_endpoint: ${AZURE_OPENAI_ENDPOINT}
azure_deployment: gpt-4
api_version: 2023-07-01-preview
parameters:
Expand Down
1 change: 0 additions & 1 deletion src/api/api/agents/writer/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def execute(context, feedback, instructions, research, products):
# Load prompty with AzureOpenAIModelConfiguration override
configuration = AzureOpenAIModelConfiguration(
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
)
Expand Down

0 comments on commit ad4ab05

Please sign in to comment.