Python: Remove references to text-davinci-003 text models as it causes tests to hang. (#6089)

### Motivation and Context

Python PR merges were failing due to integration tests. Local
integration tests were hanging on running Azure text completions. It
appears text-davinci-003 was deprecated, and needed to be replaced by
gpt-35-turbo-instruct.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

Remove references to text-davinci-003 text models as it causes tests to
hang.to hang. Updated to gpt-35-turbo-instruct, which passes. Add EastUS
AOAI deployment name var.

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
This commit is contained in:
Evan Mattson
2024-05-02 12:47:17 +00:00
committed by GitHub
parent 1bcb9ce265
commit deb813bdca
9 changed files with 17 additions and 24 deletions
@@ -79,6 +79,7 @@ jobs:
AzureOpenAI__Label: azure-text-davinci-003
AzureOpenAIEmbedding__Label: azure-text-embedding-ada-002
AzureOpenAI__DeploymentName: ${{ vars.AZUREOPENAI__DEPLOYMENTNAME }}
AzureOpenAI__Text__DeploymentName: ${{ vars.AZUREOPENAI__TEXT__DEPLOYMENTNAME }}
AzureOpenAIChat__DeploymentName: ${{ vars.AZUREOPENAI__CHAT__DEPLOYMENTNAME }}
AzureOpenAIEmbeddings__DeploymentName: ${{ vars.AZUREOPENAIEMBEDDINGS__DEPLOYMENTNAME2 }}
AzureOpenAIEmbeddings_EastUS__DeploymentName: ${{ vars.AZUREOPENAIEMBEDDINGS_EASTUS__DEPLOYMENTNAME}}
@@ -145,6 +146,7 @@ jobs:
AzureOpenAI__Label: azure-text-davinci-003
AzureOpenAIEmbedding__Label: azure-text-embedding-ada-002
AzureOpenAI__DeploymentName: ${{ vars.AZUREOPENAI__DEPLOYMENTNAME }}
AzureOpenAI__Text__DeploymentName: ${{ vars.AZUREOPENAI__TEXT__DEPLOYMENTNAME }}
AzureOpenAIChat__DeploymentName: ${{ vars.AZUREOPENAI__CHAT__DEPLOYMENTNAME }}
AzureOpenAIEmbeddings__DeploymentName: ${{ vars.AZUREOPENAIEMBEDDINGS__DEPLOYMENTNAME2 }}
AzureOpenAIEmbeddings_EastUS__DeploymentName: ${{ vars.AZUREOPENAIEMBEDDINGS_EASTUS__DEPLOYMENTNAME}}
@@ -90,7 +90,7 @@
" deployment, api_key, endpoint = azure_openai_settings_from_dot_env()\n",
" azure_text_service = AzureTextCompletion(\n",
" service_id=\"aoai_text\", deployment_name=\"gpt-35-turbo-instruct\", endpoint=endpoint, api_key=api_key\n",
" ) # set the deployment name to the value of your text model (e.g. gpt-35-turbo-instruct or text-davinci-003)\n",
" ) # set the deployment name to the value of your text model (e.g. gpt-35-turbo-instruct)\n",
" azure_chat_service = AzureChatCompletion(\n",
" service_id=\"aoai_chat\", deployment_name=\"gpt-35-turbo\", endpoint=endpoint, api_key=api_key\n",
" ) # set the deployment name to the value of your chat model\n",
@@ -85,8 +85,8 @@
"if selectedService == Service.AzureOpenAI:\n",
" deployment, api_key, endpoint = azure_openai_settings_from_dot_env()\n",
" azure_text_service = AzureTextCompletion(\n",
" service_id=\"aoai_text\", deployment_name=\"text-davinci-003\", endpoint=endpoint, api_key=api_key\n",
" ) # set the deployment name to the value of your text model (e.g. gpt-35-turbo-instruct or text-davinci-003)\n",
" service_id=\"aoai_text\", deployment_name=\"gpt-35-turbo-instruct\", endpoint=endpoint, api_key=api_key\n",
" ) # set the deployment name to the value of your text model (e.g. gpt-35-turbo-instruct)\n",
" azure_chat_service = AzureChatCompletion(\n",
" service_id=\"aoai_chat\", deployment_name=\"gpt-35-turbo\", endpoint=endpoint, api_key=api_key\n",
" ) # set the deployment name to the value of your chat model\n",
@@ -5,7 +5,7 @@ OPENAI_API_KEY=""
OPENAI_ORG_ID=""
AZURE_OPEN_AI_DEPLOYMENT_TYPE="chat-completion" # chat-completion or text-completion
AZURE_OPEN_AI_CHAT_COMPLETION_DEPLOYMENT_NAME="gpt-35-turbo"
AZURE_OPEN_AI_TEXT_COMPLETION_DEPLOYMENT_NAME="text-davinci-003"
AZURE_OPEN_AI_TEXT_COMPLETION_DEPLOYMENT_NAME="gpt-35-turbo-instruct"
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_OPENAI_API_VERSION=""
@@ -25,7 +25,7 @@ OPENAI_API_KEY=""
OPENAI_ORG_ID=""
AZURE_OPEN_AI_CHAT_COMPLETION_DEPLOYMENT_NAME="gpt-35-turbo"
AZURE_OPEN_AI_TEXT_COMPLETION_DEPLOYMENT_NAME="text-davinci-003"
AZURE_OPEN_AI_TEXT_COMPLETION_DEPLOYMENT_NAME="gpt-35-turbo-instruct"
AZURE_OPENAI_ENDPOINT=""
AZURE_OPENAI_API_KEY=""
AZURE_OPENAI_API_VERSION=""
@@ -41,8 +41,6 @@ async def main() -> None:
# Setting up OpenAI services for text completion and text embedding
kernel.add_service(
AzureChatCompletion(
# Note: text-davinci-003 is deprecated and will be replaced by
# AzureOpenAI's gpt-35-turbo-instruct model.
service_id="dv",
deployment_name="gpt-35-turbo",
endpoint=AZURE_OPENAI_ENDPOINT,
@@ -79,7 +77,7 @@ Here is some background information about the user that you should use to answer
User: {{$user_input}}
Assistant: """.strip()
sk_prompt_rag_sc = """
You will get a question, background information to be used with that question and a answer that was given.
You will get a question, background information to be used with that question and a answer that was given.
You have to answer Grounded or Ungrounded or Unclear.
Grounded if the answer is based on the background information and clearly answers the question.
Ungrounded if the answer could be true but is not based on the background information.
@@ -19,9 +19,9 @@ async def test_azure_e2e_text_completion_with_plugin(setup_tldr_function_for_oai
_, api_key, endpoint = get_aoai_config
if "Python_Integration_Tests" in os.environ:
deployment_name = os.environ["AzureOpenAI__DeploymentName"]
deployment_name = os.environ["AzureOpenAI__Text__DeploymentName"]
else:
deployment_name = "text-davinci-003"
deployment_name = "gpt-35-turbo-instruct"
print("* Service: Azure OpenAI Text Completion")
print(f"* Endpoint: {endpoint}")
@@ -55,7 +55,6 @@ async def test_azure_e2e_text_completion_with_plugin(setup_tldr_function_for_oai
summary = await retry(lambda: kernel.invoke(tldr_function, arguments))
output = str(summary).strip()
print(f"TLDR using input string: '{output}'")
assert "First Law" not in output and ("human" in output or "Human" in output or "preserve" in output)
assert len(output) < 100
@@ -68,9 +67,9 @@ async def test_azure_e2e_text_completion_with_plugin_with_provided_client(
_, api_key, endpoint = get_aoai_config
if "Python_Integration_Tests" in os.environ:
deployment_name = os.environ["AzureOpenAI__DeploymentName"]
deployment_name = os.environ["AzureOpenAI__Text__DeploymentName"]
else:
deployment_name = "text-davinci-003"
deployment_name = "gpt-35-turbo-instruct"
print("* Service: Azure OpenAI Text Completion")
print(f"* Endpoint: {endpoint}")
@@ -112,5 +111,4 @@ async def test_azure_e2e_text_completion_with_plugin_with_provided_client(
summary = await retry(lambda: kernel.invoke(tldr_function, arguments))
output = str(summary).strip()
print(f"TLDR using input string: '{output}'")
assert "First Law" not in output and ("human" in output or "Human" in output or "preserve" in output)
assert len(output) < 100
@@ -5,7 +5,6 @@ import os
import pytest
from test_utils import retry
import semantic_kernel as sk
import semantic_kernel.connectors.ai.open_ai as sk_oai
from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings
from semantic_kernel.core_plugins.conversation_summary_plugin import (
@@ -13,6 +12,7 @@ from semantic_kernel.core_plugins.conversation_summary_plugin import (
)
from semantic_kernel.functions.kernel_arguments import KernelArguments
from semantic_kernel.prompt_template.prompt_template_config import PromptTemplateConfig
from semantic_kernel.utils.settings import openai_settings_from_dot_env
@pytest.mark.asyncio
@@ -63,19 +63,14 @@ async def test_azure_summarize_conversation_using_plugin(setup_summarize_convers
async def test_oai_summarize_conversation_using_plugin(
setup_summarize_conversation_using_plugin,
):
_, chatTranscript = setup_summarize_conversation_using_plugin
# Even though the kernel is scoped to the function, it appears that
# it is shared because adding the same plugin throws an error.
# Create a new kernel for this test.
kernel = sk.Kernel()
kernel, chatTranscript = setup_summarize_conversation_using_plugin
if "Python_Integration_Tests" in os.environ:
api_key = os.environ["OpenAI__ApiKey"]
org_id = None
else:
# Load credentials from .env file
api_key, org_id = sk.openai_settings_from_dot_env()
api_key, org_id = openai_settings_from_dot_env()
execution_settings = PromptExecutionSettings(
service_id="conversation_summary", max_tokens=ConversationSummaryPlugin._max_tokens, temperature=0.1, top_p=0.5
@@ -5,7 +5,6 @@ import os
import pytest
import semantic_kernel as sk
import semantic_kernel.connectors.ai.open_ai as sk_oai
from semantic_kernel.connectors.search_engine import BingConnector
from semantic_kernel.core_plugins.math_plugin import MathPlugin
@@ -17,6 +16,7 @@ from semantic_kernel.planners import StepwisePlanner
from semantic_kernel.planners.stepwise_planner.stepwise_planner_config import (
StepwisePlannerConfig,
)
from semantic_kernel.utils.settings import bing_search_settings_from_dot_env
class TempWebSearchEnginePlugin:
@@ -48,7 +48,7 @@ def get_bing_config():
api_key = os.environ["Bing__ApiKey"]
else:
# Load credentials from .env file
api_key = sk.bing_search_settings_from_dot_env()
api_key = bing_search_settings_from_dot_env()
return api_key