diff --git a/src/api/api/agents/designer/designer.prompty b/src/api/api/agents/designer/designer.prompty index afeda865..3e446a71 100644 --- a/src/api/api/agents/designer/designer.prompty +++ b/src/api/api/agents/designer/designer.prompty @@ -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: diff --git a/src/api/api/agents/designer/designer.py b/src/api/api/agents/designer/designer.py index e33a2159..fc6c7cf3 100644 --- a/src/api/api/agents/designer/designer.py +++ b/src/api/api/agents/designer/designer.py @@ -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") ) diff --git a/src/api/api/agents/editor/editor.prompty b/src/api/api/agents/editor/editor.prompty index 0935d8f0..3bb6fd20 100644 --- a/src/api/api/agents/editor/editor.prompty +++ b/src/api/api/agents/editor/editor.prompty @@ -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 diff --git a/src/api/api/agents/editor/editor.py b/src/api/api/agents/editor/editor.py index 520b5cae..2a811f66 100644 --- a/src/api/api/agents/editor/editor.py +++ b/src/api/api/agents/editor/editor.py @@ -1,5 +1,3 @@ - -from promptflow.core import Flow from promptflow.core import Prompty, AzureOpenAIModelConfiguration import json import os @@ -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, diff --git a/src/api/api/agents/product/ai_search.py b/src/api/api/agents/product/ai_search.py index 3d9d26ab..de759e05 100644 --- a/src/api/api/agents/product/ai_search.py +++ b/src/api/api/agents/product/ai_search.py @@ -7,7 +7,7 @@ QueryCaptionType, QueryAnswerType, ) -from azure.core.credentials import AzureKeyCredential +from azure.identity import DefaultAzureCredential def retrieve_documentation( @@ -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( diff --git a/src/api/api/agents/product/product.py b/src/api/api/agents/product/product.py index df6dc4cc..10df3b16 100644 --- a/src/api/api/agents/product/product.py +++ b/src/api/api/agents/product/product.py @@ -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): @@ -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"] ) diff --git a/src/api/api/agents/researcher/researcher.prompty b/src/api/api/agents/researcher/researcher.prompty index 0079ba76..f87ee8f3 100644 --- a/src/api/api/agents/researcher/researcher.prompty +++ b/src/api/api/agents/researcher/researcher.prompty @@ -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 diff --git a/src/api/api/agents/researcher/researcher.py b/src/api/api/agents/researcher/researcher.py index 721435d9..fd3670bd 100644 --- a/src/api/api/agents/researcher/researcher.py +++ b/src/api/api/agents/researcher/researcher.py @@ -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} diff --git a/src/api/api/agents/writer/writer.prompty b/src/api/api/agents/writer/writer.prompty index 7babca14..9521290b 100644 --- a/src/api/api/agents/writer/writer.prompty +++ b/src/api/api/agents/writer/writer.prompty @@ -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: diff --git a/src/api/api/agents/writer/writer.py b/src/api/api/agents/writer/writer.py index 363f4ec3..80f51616 100644 --- a/src/api/api/agents/writer/writer.py +++ b/src/api/api/agents/writer/writer.py @@ -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") )