From eea5c34c09d310c42b80df92c4b0550ac8554bcb Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Sat, 17 Feb 2024 08:10:06 -0800 Subject: [PATCH 1/5] updates to byod cookbook for v1 --- examples/azure/chat_with_your_own_data.ipynb | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/examples/azure/chat_with_your_own_data.ipynb b/examples/azure/chat_with_your_own_data.ipynb index 6f8b05fb..6d40cc4c 100644 --- a/examples/azure/chat_with_your_own_data.ipynb +++ b/examples/azure/chat_with_your_own_data.ipynb @@ -99,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -128,10 +128,10 @@ " deployment = \"\"\n", "\n", " client = openai.AzureOpenAI(\n", - " base_url=f\"{endpoint}/openai/deployments/{deployment}/extensions\",\n", + " azure_endpoint=endpoint,\n", " api_key=api_key,\n", - " api_version=\"2023-09-01-preview\"\n", - " )" + " api_version=\"2024-02-15-preview\"\n", + " )\n" ] }, { @@ -168,9 +168,9 @@ " deployment = \"\"\n", "\n", " client = openai.AzureOpenAI(\n", - " base_url=f\"{endpoint}/openai/deployments/{deployment}/extensions\",\n", + " azure_endpoint=endpoint,\n", " azure_ad_token_provider=get_bearer_token_provider(DefaultAzureCredential(), \"https://cognitiveservices.azure.com/.default\"),\n", - " api_version=\"2023-09-01-preview\"\n", + " api_version=\"2024-02-15-preview\"\n", " )" ] }, @@ -218,7 +218,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now we can use Azure on your own data with Chat Completions. Providing our search endpoint, key, and index name in `dataSources`, any questions posed to the model will now be grounded in our own data. An additional property, `context`, will be provided in the response to show the data the model referenced to answer the question." + "Now we can use Azure on your own data with Chat Completions. Providing our search endpoint, key, and index name in `data_sources`, any questions posed to the model will now be grounded in our own data. An additional property, `context`, will be provided in the response to show the data the model referenced to answer the question." ] }, { @@ -231,7 +231,7 @@ " messages=[{\"role\": \"user\", \"content\": \"What are the differences between Azure Machine Learning and Azure AI services?\"}],\n", " model=deployment,\n", " extra_body={\n", - " \"dataSources\": [\n", + " \"data_sources\": [\n", " {\n", " \"type\": \"AzureCognitiveSearch\",\n", " \"parameters\": {\n", @@ -245,8 +245,7 @@ ")\n", "print(f\"{completion.choices[0].message.role}: {completion.choices[0].message.content}\")\n", "\n", - "# `context` is in the model_extra for Azure\n", - "print(f\"\\nContext: {completion.choices[0].message.model_extra['context']['messages'][0]['content']}\")" + "print(f\"\\nContext: {completion.choices[0].message.context}\")" ] }, { @@ -266,7 +265,7 @@ " messages=[{\"role\": \"user\", \"content\": \"What are the differences between Azure Machine Learning and Azure AI services?\"}],\n", " model=deployment,\n", " extra_body={\n", - " \"dataSources\": [\n", + " \"data_sources\": [\n", " {\n", " \"type\": \"AzureCognitiveSearch\",\n", " \"parameters\": {\n", @@ -287,8 +286,10 @@ " print(\"\\n\"+ delta.role + \": \", end=\"\", flush=True)\n", " if delta.content:\n", " print(delta.content, end=\"\", flush=True)\n", - " if delta.model_extra.get(\"context\"):\n", - " print(f\"Context: {delta.model_extra['context']}\", end=\"\", flush=True)" + " if hasattr(delta, \"context\"):\n", + " context = delta.context\n", + "\n", + "print(f\"\\nContext: {context}\")" ] } ], @@ -308,7 +309,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.11.7" }, "orig_nbformat": 4 }, From 8dd7c368421ecd305bfe5636c89d4b7f204a4bc4 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Sat, 17 Feb 2024 08:17:38 -0800 Subject: [PATCH 2/5] update byod cookbook for None:\n", - " \"\"\"Sets up the OpenAI Python SDK to use your own data for the chat endpoint.\n", - " \n", - " :param deployment_id: The deployment ID for the model to use with your own data.\n", - "\n", - " To remove this configuration, simply set openai.requestssession to None.\n", - " \"\"\"\n", - "\n", - " class BringYourOwnDataAdapter(requests.adapters.HTTPAdapter):\n", - "\n", - " def send(self, request, **kwargs):\n", - " request.url = f\"{openai.api_base}/openai/deployments/{deployment_id}/extensions/chat/completions?api-version={openai.api_version}\"\n", - " return super().send(request, **kwargs)\n", - "\n", - " session = requests.Session()\n", - "\n", - " # Mount a custom adapter which will use the extensions endpoint for any call using the given `deployment_id`\n", - " session.mount(\n", - " prefix=f\"{openai.api_base}/openai/deployments/{deployment_id}\",\n", - " adapter=BringYourOwnDataAdapter()\n", - " )\n", - "\n", - " if use_azure_active_directory:\n", - " session.auth = TokenRefresh(default_credential, [\"https://cognitiveservices.azure.com/.default\"])\n", - "\n", - " openai.requestssession = session\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can call the convenience function to configure the SDK with the model we plan to use for our own data." + "Providing our search endpoint, key, and index name for the `data_sources` keyword argument, any questions posed to the model will now be grounded in our own data. An additional property, `context`, will be provided to show the data the model referenced to answer the question." ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "setup_byod(\"gpt-4\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Providing our search endpoint, key, and index name for the `dataSources` keyword argument, any questions posed to the model will now be grounded in our own data. An additional property, `context`, will be provided to show the data the model referenced to answer the question." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"id\": \"65b485bb-b3c9-48da-8b6f-7d3a219f0b40\",\n", - " \"model\": \"gpt-4\",\n", - " \"created\": 1693338769,\n", - " \"object\": \"extensions.chat.completion\",\n", - " \"choices\": [\n", - " {\n", - " \"index\": 0,\n", - " \"finish_reason\": \"stop\",\n", - " \"message\": {\n", - " \"role\": \"assistant\",\n", - " \"content\": \"Azure AI services and Azure Machine Learning (AML) both aim to apply artificial intelligence (AI) to enhance business operations, but they target different audiences and offer different capabilities [doc1]. \\n\\nAzure AI services are designed for developers without machine learning experience and provide pre-trained models to solve general problems such as text analysis, image recognition, and natural language processing [doc5]. These services require general knowledge about your data without needing experience with machine learning or data science and provide REST APIs and language-based SDKs [doc2].\\n\\nOn the other hand, Azure Machine Learning is tailored for data scientists and involves a longer process of data collection, cleaning, transformation, algorithm selection, model training, and deployment [doc5]. It allows users to create custom solutions for highly specialized and specific problems, requiring familiarity with the subject matter, data, and expertise in data science [doc5].\\n\\nIn summary, Azure AI services offer pre-trained models for developers without machine learning experience, while Azure Machine Learning is designed for data scientists to create custom solutions for specific problems.\",\n", - " \"end_turn\": true,\n", - " \"context\": {\n", - " \"messages\": [\n", - " {\n", - " \"role\": \"tool\",\n", - " \"content\": \"{\\\"citations\\\": [{\\\"content\\\": \\\"

How are Azure AI services and Azure Machine Learning (AML) similar?.

\\\\n

Both have the end-goal of applying artificial intelligence (AI) to enhance business operations, though how each provides this in the respective offerings is different..

\\\\n

Generally, the audiences are different:

\\\\n
    \\\\n
  • Azure AI services are for developers without machine-learning experience..
  • \\\\n
  • Azure Machine Learning is tailored for data scientists.\\\", \\\"id\\\": null, \\\"title\\\": \\\"Azure AI services and machine learning\\\", \\\"filepath\\\": \\\"cognitive-services-and-machine-learning.md\\\", \\\"url\\\": \\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\", \\\"metadata\\\": {\\\"chunking\\\": \\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 2/Highlights=30 of size=137\\\"}, \\\"chunk_id\\\": \\\"2\\\"}, {\\\"content\\\": \\\"Convert speech into text and text into natural-sounding speech..Translate from one language to another and enable speaker verification and recognition..\\\\n\\\\n\\\\nVision\\\\nRecognize, identify, caption, index, and moderate your pictures, videos, and digital ink content..\\\\n\\\\n

    \\\\n

    \\\\n

    Use Azure AI services when you:

    \\\\n
      \\\\n
    • Can use a generalized solution..
    • \\\\n
    \\\\n

    Use other machine-learning solutions when you:

    \\\\n
      \\\\n
    • Need to choose the algorithm and need to train on very specific data..
    • \\\\n
    \\\\n

    What is machine learning?.

    \\\\n

    Machine learning is a concept where you bring together data and an algorithm to solve a specific need..Once the data and algorithm are trained, the output is a model that you can use again with different data..The trained model provides insights based on the new data..

    \\\\n

    The process of building a machine learning system requires some knowledge of machine learning or data science..

    \\\\n

    Machine learning is provided using Azure Machine Learning (AML) products and services..

    \\\\n

    What is an Azure AI service?.

    \\\\n

    An Azure AI service provides part or all of the components in a machine learning solution: data, algorithm, and trained model..These services are meant to require general knowledge about your data without needing experience with machine learning or data science..These services provide both REST API(s) and language-based SDKs..As a result, you need to have programming language knowledge to use the services..

    \\\", \\\"id\\\": null, \\\"title\\\": \\\"Azure AI services and machine learning\\\", \\\"filepath\\\": \\\"cognitive-services-and-machine-learning.md\\\", \\\"url\\\": \\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\", \\\"metadata\\\": {\\\"chunking\\\": \\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 1/Highlights=67 of size=506\\\"}, \\\"chunk_id\\\": \\\"1\\\"}, {\\\"content\\\": \\\"
    \\\\n

    title: Azure AI services and Machine Learning\\\\ntitleSuffix: Azure AI services\\\\ndescription: Learn where Azure AI services fits in with other Azure offerings for machine learning.\\\\nservices: cognitive-services\\\\nmanager: nitinme\\\\nauthor: aahill\\\\nms.author: aahi\\\\nms.service: cognitive-services\\\\nms.topic: conceptual\\\\nms.date: 10/28/2021

    \\\\n
    \\\\n

    Azure AI services and machine learning

    \\\\n

    Azure AI services provides machine learning capabilities to solve general problems such as analyzing text for emotional sentiment or analyzing images to recognize objects or faces..You don't need special machine learning or data science knowledge to use these services../what-are-ai-services.md\\\\\\\">Azure AI services is a group of services, each supporting different, generalized prediction capabilities..The services are divided into different categories to help you find the right service..

    \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\", \\\"id\\\": null, \\\"title\\\": \\\"Azure AI services and machine learning\\\", \\\"filepath\\\": \\\"cognitive-services-and-machine-learning.md\\\", \\\"url\\\": \\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\", \\\"metadata\\\": {\\\"chunking\\\": \\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 0/Highlights=63 of size=526\\\"}, \\\"chunk_id\\\": \\\"0\\\"}, {\\\"content\\\": \\\"

    How is Azure Cognitive Search related to Azure AI services?

    \\\\n

    Azure Cognitive Search is a separate cloud search service that optionally uses Azure AI services to add image and natural language processing to indexing workloads. Azure AI services is exposed in Azure Cognitive Search through built-in skills that wrap individual APIs. You can use a free resource for walkthroughs, but plan on creating and attaching a billable resource for larger volumes.

    \\\\n

    How can you use Azure AI services?

    \\\\n

    Each service provides information about your data. You can combine services together to chain solutions such as converting speech (audio) to text, translating the text into many languages, then using the translated languages to get answers from a knowledge base. While Azure AI services can be used to create intelligent solutions on their own, they can also be combined with traditional machine learning projects to supplement models or accelerate the development process.

    \\\\n

    Azure AI services that provide exported models for other machine learning tools:

    \\\\n
    Service categoryPurpose
    DecisionBuild apps that surface recommendations for informed and efficient decision-making..
    LanguageAllow your apps to process natural language with pre-built scripts, evaluate sentiment and learn how to recognize what users want..
    SearchAdd Bing Search APIs to your apps and harness the ability to comb billions of webpages, images, videos, and news with a single API call..
    Speech
    \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n
    Azure AI serviceModel information
    Custom VisionExport for Tensorflow for Android, CoreML for iOS11, ONNX for Windows ML
    \\\\n

    Learn more

    \\\\n\\\\n

    Next steps

    \\\\n\\\", \\\"id\\\": null, \\\"title\\\": \\\"Azure AI services and machine learning\\\", \\\"filepath\\\": \\\"cognitive-services-and-machine-learning.md\\\", \\\"url\\\": \\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\", \\\"metadata\\\": {\\\"chunking\\\": \\\"orignal document size=793. Scores=3.3767838 and None.Org Highlight count=69.\\\"}, \\\"chunk_id\\\": \\\"3\\\"}, {\\\"content\\\": \\\"

    How are Azure AI services different from machine learning?.

    \\\\n

    Azure AI services provide a trained model for you..This brings data and an algorithm together, available from a REST API(s) or SDK..An Azure AI service provides answers to general problems such as key phrases in text or item identification in images..

    \\\\n

    Machine learning is a process that generally requires a longer period of time to implement successfully..This time is spent on data collection, cleaning, transformation, algorithm selection, model training, and deployment to get to the same level of functionality provided by an Azure AI service..With machine learning, it is possible to provide answers to highly specialized and/or specific problems..Machine learning problems require familiarity with the specific subject matter and data of the problem under consideration, as well as expertise in data science..

    \\\\n

    What kind of data do you have?.

    \\\\n

    Azure AI services, as a group of services, can require none, some, or all custom data for the trained model..

    \\\\n

    No additional training data required

    \\\\n

    Services that provide a fully-trained model can be treated as a opaque box..You don't need to know how they work or what data was used to train them..

    \\\\n

    Some or all training data required

    \\\\n

    Some services allow you to bring your own data, then train a model..This allows you to extend the model using the Service's data and algorithm with your own data..The output matches your needs..When you bring your own data, you may need to tag the data in a way specific to the service..For example, if you are training a model to identify flowers, you can provide a catalog of flower images along with the location of the flower in each image to train the model..These services process significant amounts of model data..

    \\\\n

    Service requirements for the data model

    \\\\n

    The following data categorizes each service by which kind of data it allows or requires..

    \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n
    Azure AI serviceNo training data requiredYou provide some or all training dataReal-time or near real-time data collection
    Language Understanding (LUIS)x
    Personalizer1xxx
    Visionx
    \\\\n

    1 Personalizer only needs training data collected by the service (as it operates in real-time) to evaluate your policy and data..

    \\\\n

    Where can you use Azure AI services?.

    \\\\n

    The services are used in any application that can make REST API(s) or SDK calls..Examples of applications include web sites, bots, virtual or mixed reality, desktop and mobile applications.\\\", \\\"id\\\": null, \\\"title\\\": \\\"Azure AI services and machine learning\\\", \\\"filepath\\\": \\\"cognitive-services-and-machine-learning.md\\\", \\\"url\\\": \\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\", \\\"metadata\\\": {\\\"chunking\\\": \\\"orignal document size=1734. Scores=3.1447978 and None.Org Highlight count=66.Filtering to highlight size=891\\\"}, \\\"chunk_id\\\": \\\"4\\\"}], \\\"intent\\\": \\\"[\\\\\\\"What are the differences between Azure Machine Learning and Azure AI services?\\\\\\\"]\\\"}\",\n", - " \"end_turn\": false\n", - " }\n", - " ]\n", - " }\n", - " }\n", - " }\n", - " ]\n", - "}\n" - ] - } - ], "source": [ "completion = openai.ChatCompletion.create(\n", " messages=[{\"role\": \"user\", \"content\": \"What are the differences between Azure Machine Learning and Azure AI services?\"}],\n", " deployment_id=\"gpt-4\",\n", - " dataSources=[ # camelCase is intentional, as this is the format the API expects\n", + " data_sources=[\n", " {\n", " \"type\": \"AzureCognitiveSearch\",\n", " \"parameters\": {\n", @@ -368,37 +276,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Context: {\n", - " \"messages\": [\n", - " {\n", - " \"role\": \"tool\",\n", - " \"content\": \"{\\\"citations\\\":[{\\\"content\\\":\\\"

    How are Azure AI services and Azure Machine Learning (AML) similar?.

    \\\\n

    Both have the end-goal of applying artificial intelligence (AI) to enhance business operations, though how each provides this in the respective offerings is different..

    \\\\n

    Generally, the audiences are different:

    \\\\n
      \\\\n
    • Azure AI services are for developers without machine-learning experience..
    • \\\\n
    • Azure Machine Learning is tailored for data scientists.\\\",\\\"id\\\":null,\\\"title\\\":\\\"Azure AI services and machine learning\\\",\\\"filepath\\\":\\\"cognitive-services-and-machine-learning.md\\\",\\\"url\\\":\\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\",\\\"metadata\\\":{\\\"chunking\\\":\\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 2/Highlights=30 of size=137\\\"},\\\"chunk_id\\\":\\\"2\\\"},{\\\"content\\\":\\\"Convert speech into text and text into natural-sounding speech..Translate from one language to another and enable speaker verification and recognition..\\\\n\\\\n\\\\nVision\\\\nRecognize, identify, caption, index, and moderate your pictures, videos, and digital ink content..\\\\n\\\\n

      \\\\n

      \\\\n

      Use Azure AI services when you:

      \\\\n
        \\\\n
      • Can use a generalized solution..
      • \\\\n
      \\\\n

      Use other machine-learning solutions when you:

      \\\\n
        \\\\n
      • Need to choose the algorithm and need to train on very specific data..
      • \\\\n
      \\\\n

      What is machine learning?.

      \\\\n

      Machine learning is a concept where you bring together data and an algorithm to solve a specific need..Once the data and algorithm are trained, the output is a model that you can use again with different data..The trained model provides insights based on the new data..

      \\\\n

      The process of building a machine learning system requires some knowledge of machine learning or data science..

      \\\\n

      Machine learning is provided using Azure Machine Learning (AML) products and services..

      \\\\n

      What is an Azure AI service?.

      \\\\n

      An Azure AI service provides part or all of the components in a machine learning solution: data, algorithm, and trained model..These services are meant to require general knowledge about your data without needing experience with machine learning or data science..These services provide both REST API(s) and language-based SDKs..As a result, you need to have programming language knowledge to use the services..

      \\\",\\\"id\\\":null,\\\"title\\\":\\\"Azure AI services and machine learning\\\",\\\"filepath\\\":\\\"cognitive-services-and-machine-learning.md\\\",\\\"url\\\":\\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\",\\\"metadata\\\":{\\\"chunking\\\":\\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 1/Highlights=67 of size=506\\\"},\\\"chunk_id\\\":\\\"1\\\"},{\\\"content\\\":\\\"
      \\\\n

      title: Azure AI services and Machine Learning\\\\ntitleSuffix: Azure AI services\\\\ndescription: Learn where Azure AI services fits in with other Azure offerings for machine learning.\\\\nservices: cognitive-services\\\\nmanager: nitinme\\\\nauthor: aahill\\\\nms.author: aahi\\\\nms.service: cognitive-services\\\\nms.topic: conceptual\\\\nms.date: 10/28/2021

      \\\\n
      \\\\n

      Azure AI services and machine learning

      \\\\n

      Azure AI services provides machine learning capabilities to solve general problems such as analyzing text for emotional sentiment or analyzing images to recognize objects or faces..You don't need special machine learning or data science knowledge to use these services../what-are-ai-services.md\\\\\\\">Azure AI services is a group of services, each supporting different, generalized prediction capabilities..The services are divided into different categories to help you find the right service..

      \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\",\\\"id\\\":null,\\\"title\\\":\\\"Azure AI services and machine learning\\\",\\\"filepath\\\":\\\"cognitive-services-and-machine-learning.md\\\",\\\"url\\\":\\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\",\\\"metadata\\\":{\\\"chunking\\\":\\\"orignal document size=1188. Scores=5.689296 and None.Org Highlight count=160.Filtering to chunk no. 0/Highlights=63 of size=526\\\"},\\\"chunk_id\\\":\\\"0\\\"},{\\\"content\\\":\\\"

      How is Azure Cognitive Search related to Azure AI services?

      \\\\n

      Azure Cognitive Search is a separate cloud search service that optionally uses Azure AI services to add image and natural language processing to indexing workloads. Azure AI services is exposed in Azure Cognitive Search through built-in skills that wrap individual APIs. You can use a free resource for walkthroughs, but plan on creating and attaching a billable resource for larger volumes.

      \\\\n

      How can you use Azure AI services?

      \\\\n

      Each service provides information about your data. You can combine services together to chain solutions such as converting speech (audio) to text, translating the text into many languages, then using the translated languages to get answers from a knowledge base. While Azure AI services can be used to create intelligent solutions on their own, they can also be combined with traditional machine learning projects to supplement models or accelerate the development process.

      \\\\n

      Azure AI services that provide exported models for other machine learning tools:

      \\\\n
      Service categoryPurpose
      DecisionBuild apps that surface recommendations for informed and efficient decision-making..
      LanguageAllow your apps to process natural language with pre-built scripts, evaluate sentiment and learn how to recognize what users want..
      SearchAdd Bing Search APIs to your apps and harness the ability to comb billions of webpages, images, videos, and news with a single API call..
      Speech
      \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n
      Azure AI serviceModel information
      Custom VisionExport for Tensorflow for Android, CoreML for iOS11, ONNX for Windows ML
      \\\\n

      Learn more

      \\\\n\\\\n

      Next steps

      \\\\n\\\",\\\"id\\\":null,\\\"title\\\":\\\"Azure AI services and machine learning\\\",\\\"filepath\\\":\\\"cognitive-services-and-machine-learning.md\\\",\\\"url\\\":\\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\",\\\"metadata\\\":{\\\"chunking\\\":\\\"orignal document size=793. Scores=3.3767838 and None.Org Highlight count=69.\\\"},\\\"chunk_id\\\":\\\"3\\\"},{\\\"content\\\":\\\"

      How are Azure AI services different from machine learning?.

      \\\\n

      Azure AI services provide a trained model for you..This brings data and an algorithm together, available from a REST API(s) or SDK..An Azure AI service provides answers to general problems such as key phrases in text or item identification in images..

      \\\\n

      Machine learning is a process that generally requires a longer period of time to implement successfully..This time is spent on data collection, cleaning, transformation, algorithm selection, model training, and deployment to get to the same level of functionality provided by an Azure AI service..With machine learning, it is possible to provide answers to highly specialized and/or specific problems..Machine learning problems require familiarity with the specific subject matter and data of the problem under consideration, as well as expertise in data science..

      \\\\n

      What kind of data do you have?.

      \\\\n

      Azure AI services, as a group of services, can require none, some, or all custom data for the trained model..

      \\\\n

      No additional training data required

      \\\\n

      Services that provide a fully-trained model can be treated as a opaque box..You don't need to know how they work or what data was used to train them..

      \\\\n

      Some or all training data required

      \\\\n

      Some services allow you to bring your own data, then train a model..This allows you to extend the model using the Service's data and algorithm with your own data..The output matches your needs..When you bring your own data, you may need to tag the data in a way specific to the service..For example, if you are training a model to identify flowers, you can provide a catalog of flower images along with the location of the flower in each image to train the model..These services process significant amounts of model data..

      \\\\n

      Service requirements for the data model

      \\\\n

      The following data categorizes each service by which kind of data it allows or requires..

      \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n
      Azure AI serviceNo training data requiredYou provide some or all training dataReal-time or near real-time data collection
      Language Understanding (LUIS)x
      Personalizer1xxx
      Visionx
      \\\\n

      1 Personalizer only needs training data collected by the service (as it operates in real-time) to evaluate your policy and data..

      \\\\n

      Where can you use Azure AI services?.

      \\\\n

      The services are used in any application that can make REST API(s) or SDK calls..Examples of applications include web sites, bots, virtual or mixed reality, desktop and mobile applications.\\\",\\\"id\\\":null,\\\"title\\\":\\\"Azure AI services and machine learning\\\",\\\"filepath\\\":\\\"cognitive-services-and-machine-learning.md\\\",\\\"url\\\":\\\"https://krpraticstorageacc.blob.core.windows.net/azure-openai/cognitive-services-and-machine-learning.md\\\",\\\"metadata\\\":{\\\"chunking\\\":\\\"orignal document size=1734. Scores=3.1447978 and None.Org Highlight count=66.Filtering to highlight size=891\\\"},\\\"chunk_id\\\":\\\"4\\\"}],\\\"intent\\\":\\\"[\\\\\\\"What are the differences between Azure Machine Learning and Azure AI services?\\\\\\\"]\\\"}\",\n", - " \"end_turn\": false\n", - " }\n", - " ]\n", - "}\n", - "assistant: Azure AI services and Azure Machine Learning (AML) both aim to apply artificial intelligence (AI) to enhance business operations, but they target different audiences and offer different capabilities [doc1]. \n", - "\n", - "Azure AI services are designed for developers without machine learning experience and provide pre-trained models to solve general problems such as text analysis, image recognition, and natural language processing [doc5]. These services require general knowledge about your data without needing experience with machine learning or data science and provide REST APIs and language-based SDKs [doc2].\n", - "\n", - "On the other hand, Azure Machine Learning is tailored for data scientists and offers a platform to build, train, and deploy custom machine learning models [doc1]. It requires knowledge of machine learning or data science and allows users to choose the algorithm and train on very specific data [doc2].\n", - "\n", - "In summary, Azure AI services offer pre-trained models for developers without machine learning experience, while Azure Machine Learning is a platform for data scientists to build and deploy custom machine learning models." - ] - } - ], + "outputs": [], "source": [ "response = openai.ChatCompletion.create(\n", " messages=[{\"role\": \"user\", \"content\": \"What are the differences between Azure Machine Learning and Azure AI services?\"}],\n", " deployment_id=\"gpt-4\",\n", - " dataSources=[\n", + " data_sources=[\n", " {\n", " \"type\": \"AzureCognitiveSearch\",\n", " \"parameters\": {\n", @@ -439,7 +324,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.11.7" }, "orig_nbformat": 4 }, From 345d98176445addb40b89edc992e312630cfd6e5 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Sun, 18 Feb 2024 21:10:31 -0800 Subject: [PATCH 3/5] change data_sources type to azure_search --- examples/azure/archive/chat_with_your_own_data.ipynb | 4 ++-- examples/azure/chat_with_your_own_data.ipynb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/azure/archive/chat_with_your_own_data.ipynb b/examples/azure/archive/chat_with_your_own_data.ipynb index 41a6e0d0..98d6a96c 100644 --- a/examples/azure/archive/chat_with_your_own_data.ipynb +++ b/examples/azure/archive/chat_with_your_own_data.ipynb @@ -255,7 +255,7 @@ " deployment_id=\"gpt-4\",\n", " data_sources=[\n", " {\n", - " \"type\": \"AzureCognitiveSearch\",\n", + " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", " \"key\": os.environ[\"SEARCH_KEY\"],\n", @@ -285,7 +285,7 @@ " deployment_id=\"gpt-4\",\n", " data_sources=[\n", " {\n", - " \"type\": \"AzureCognitiveSearch\",\n", + " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", " \"key\": os.environ[\"SEARCH_KEY\"],\n", diff --git a/examples/azure/chat_with_your_own_data.ipynb b/examples/azure/chat_with_your_own_data.ipynb index 6d40cc4c..805bcd7d 100644 --- a/examples/azure/chat_with_your_own_data.ipynb +++ b/examples/azure/chat_with_your_own_data.ipynb @@ -233,7 +233,7 @@ " extra_body={\n", " \"data_sources\": [\n", " {\n", - " \"type\": \"AzureCognitiveSearch\",\n", + " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", " \"key\": os.environ[\"SEARCH_KEY\"],\n", @@ -267,7 +267,7 @@ " extra_body={\n", " \"data_sources\": [\n", " {\n", - " \"type\": \"AzureCognitiveSearch\",\n", + " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", " \"key\": os.environ[\"SEARCH_KEY\"],\n", From 91f5808df00aaa5c06e1da1af434222fb3eb8b03 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Mon, 4 Mar 2024 16:31:20 -0800 Subject: [PATCH 4/5] update chat.ipynb to remove model_extra as well --- examples/azure/chat.ipynb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/azure/chat.ipynb b/examples/azure/chat.ipynb index d239e2ee..44905008 100644 --- a/examples/azure/chat.ipynb +++ b/examples/azure/chat.ipynb @@ -301,15 +301,13 @@ ")\n", "print(f\"Answer: {completion.choices[0].message.content}\")\n", "\n", - "# prompt content filter result in \"model_extra\" for azure\n", - "prompt_filter_result = completion.model_extra[\"prompt_filter_results\"][0][\"content_filter_results\"]\n", + "prompt_filter_result = completion.prompt_filter_results[0][\"content_filter_results\"]\n", "print(\"\\nPrompt content filter results:\")\n", "for category, details in prompt_filter_result.items():\n", " print(f\"{category}:\\n filtered={details['filtered']}\\n severity={details['severity']}\")\n", "\n", - "# completion content filter result\n", "print(\"\\nCompletion content filter results:\")\n", - "completion_filter_result = completion.choices[0].model_extra[\"content_filter_results\"]\n", + "completion_filter_result = completion.choices[0].content_filter_results\n", "for category, details in completion_filter_result.items():\n", " print(f\"{category}:\\n filtered={details['filtered']}\\n severity={details['severity']}\")" ] From deb424326bb922afbc09d676436f06c463c01fe3 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Fri, 22 Mar 2024 13:58:10 -0700 Subject: [PATCH 5/5] update to ga api version --- examples/azure/chat_with_your_own_data.ipynb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/azure/chat_with_your_own_data.ipynb b/examples/azure/chat_with_your_own_data.ipynb index 805bcd7d..90d00b94 100644 --- a/examples/azure/chat_with_your_own_data.ipynb +++ b/examples/azure/chat_with_your_own_data.ipynb @@ -130,7 +130,7 @@ " client = openai.AzureOpenAI(\n", " azure_endpoint=endpoint,\n", " api_key=api_key,\n", - " api_version=\"2024-02-15-preview\"\n", + " api_version=\"2024-02-01\"\n", " )\n" ] }, @@ -170,7 +170,7 @@ " client = openai.AzureOpenAI(\n", " azure_endpoint=endpoint,\n", " azure_ad_token_provider=get_bearer_token_provider(DefaultAzureCredential(), \"https://cognitiveservices.azure.com/.default\"),\n", - " api_version=\"2024-02-15-preview\"\n", + " api_version=\"2024-02-01\"\n", " )" ] }, @@ -236,8 +236,11 @@ " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", - " \"key\": os.environ[\"SEARCH_KEY\"],\n", - " \"indexName\": os.environ[\"SEARCH_INDEX_NAME\"],\n", + " \"index_name\": os.environ[\"SEARCH_INDEX_NAME\"],\n", + " \"authentication\": {\n", + " \"type\": \"api_key\",\n", + " \"key\": os.environ[\"SEARCH_KEY\"],\n", + " }\n", " }\n", " }\n", " ]\n", @@ -270,8 +273,11 @@ " \"type\": \"azure_search\",\n", " \"parameters\": {\n", " \"endpoint\": os.environ[\"SEARCH_ENDPOINT\"],\n", - " \"key\": os.environ[\"SEARCH_KEY\"],\n", - " \"indexName\": os.environ[\"SEARCH_INDEX_NAME\"],\n", + " \"index_name\": os.environ[\"SEARCH_INDEX_NAME\"],\n", + " \"authentication\": {\n", + " \"type\": \"api_key\",\n", + " \"key\": os.environ[\"SEARCH_KEY\"],\n", + " }\n", " }\n", " }\n", " ]\n",