|
| 1 | +--- |
| 2 | +title: Quickstart - getting started with Azure OpenAI assistants (preview) in AI Studio |
| 3 | +titleSuffix: Azure OpenAI |
| 4 | +description: Walkthrough on how to get started with Azure OpenAI assistants with new features like code interpreter in AI Studio (Preview). |
| 5 | +manager: nitinme |
| 6 | +ms.service: azure-ai-studio |
| 7 | +ms.custom: |
| 8 | +ms.topic: include |
| 9 | +ms.date: 03/04/2024 |
| 10 | +ms.author: mbullwin |
| 11 | +author: mrbullwinkle |
| 12 | +--- |
| 13 | + |
| 14 | +[!INCLUDE [Azure AI Studio preview](../../../ai-studio/includes/preview-ai-studio.md)] |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- An Azure subscription - <a href="https://azure.microsoft.com/free/cognitive-services" target="_blank">Create one for free</a>. |
| 19 | +- Access granted to Azure OpenAI in the desired Azure subscription. |
| 20 | + |
| 21 | + Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at <a href="https://aka.ms/oai/access" target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue. |
| 22 | +- An [Azure AI hub resource](../../../ai-studio/how-to/create-azure-ai-resource.md) with a model deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md). |
| 23 | +- An [Azure AI project](../../../ai-studio/how-to/create-projects.md) in Azure AI Studio. |
| 24 | + |
| 25 | +## Go to the Azure AI Studio (Preview) |
| 26 | + |
| 27 | +1. Sign in to [Azure AI Studio](https://ai.azure.com). |
| 28 | +1. Go to your project or [create a new project](../../../ai-studio//how-to/create-projects.md) in Azure AI Studio. |
| 29 | +1. From the Azure AI Studio Home page, select **Build** > **Playground**. |
| 30 | + |
| 31 | + The Assistants playground allows you to explore, prototype, and test AI Assistants without needing to run any code. From this page, you can quickly iterate and experiment with new ideas. |
| 32 | + |
| 33 | + The playground provides several options to configure your Assistant. In the following steps, you will use the **Assistant setup** pane to create a new AI assistant. |
| 34 | + |
| 35 | + | **Name** | **Description** | |
| 36 | + |:---|:---| |
| 37 | + | **Assistant name** | Your deployment name that is associated with a specific model. | |
| 38 | + | **Instructions** | Instructions are similar to system messages this is where you give the model guidance about how it should behave and any context it should reference when generating a response. You can describe the assistant's personality, tell it what it should and shouldn't answer, and tell it how to format responses. You can also provide examples of the steps it should take when answering responses. | |
| 39 | + | **Deployment** | This is where you set which model deployment to use with your assistant. | |
| 40 | + | **Functions**| Create custom function definitions for the models to formulate API calls and structure data outputs based on your specifications. Not used in this quickstart. | |
| 41 | + | **Code interpreter** | Code interpreter provides access to a sandboxed Python environment that can be used to allow the model to test and execute code. | |
| 42 | + | **Files** | You can upload up to 20 files, with a max file size of 512 MB to use with tools. Not used in this quickstart. | |
| 43 | + |
| 44 | + |
| 45 | +1. Select your deployment from the **Deployments** dropdown. |
| 46 | +1. Select **Assistants** from the **Mode** dropdown menu. |
| 47 | + |
| 48 | + :::image type="content" source="../media/quickstarts/assistants-ai-studio-playground.png" alt-text="Screenshot of the Assistant configuration screen without all the values filled in." lightbox="../media/quickstarts/assistants-ai-studio-playground.png"::: |
| 49 | + |
| 50 | +## Create your first Assistant |
| 51 | + |
| 52 | +1. From the Assistant setup drop-down, select **New**. |
| 53 | +2. Give your Assistant a name. |
| 54 | +3. Enter the following instructions "You are an AI assistant that can write code to help answer math questions" |
| 55 | +4. Select a model deployment. We recommend testing with one of the latest gpt-4 models. |
| 56 | +5. Select the toggle enabling code interpreter. |
| 57 | +6. Select Save. |
| 58 | + |
| 59 | + :::image type="content" source="../media/quickstarts/assistant-configuration.png" alt-text="Screenshot of the assistant with configuration details entered." lightbox="../media/quickstarts/assistant-configuration.png"::: |
| 60 | + |
| 61 | +7. Enter a question for the assistant to answer: "I need to solve the equation `3x + 11 = 14`. Can you help me?" |
| 62 | +8. Select the **Add and run button** :::image type="icon" source="../media/quickstarts/run.png"::: |
| 63 | + |
| 64 | + ```output |
| 65 | + The solution to the equation (3x + 11 = 14) is (x = 1). |
| 66 | + ``` |
| 67 | +
|
| 68 | + While we can see that answer is correct, to confirm that the model used code interpreter to get to this answer, and that the code it wrote is valid rather than just repeating an answer from the model's training data we'll ask another question. |
| 69 | +
|
| 70 | +9. Enter the follow-up question: "Show me the code you ran to get this solution." |
| 71 | +
|
| 72 | + ```output |
| 73 | + Sure. The code is very straightforward |
| 74 | + ``` |
| 75 | +
|
| 76 | + ```python |
| 77 | + # calculation |
| 78 | + x = (14 - 11) / 3 |
| 79 | + x |
| 80 | +
|
| 81 | + ``` |
| 82 | +
|
| 83 | + ```output |
| 84 | + First, we subtract 11 from 14, then divide the result by 3. This gives us the value of x which is 1.0. |
| 85 | + ```` |
| 86 | +
|
| 87 | + :::image type="content" source="../media/quickstarts/assistant-ai-studio-session.png" alt-text="Screenshot of conversation session in the Assistant playground." lightbox="../media/quickstarts/assistant-ai-studio-session.png"::: |
| 88 | +
|
| 89 | +You could also consult the logs in the right-hand panel to confirm that code interpreter was used and to validate the code that was run to generate the response. It is important to remember that while code interpreter gives the model the capability to respond to more complex math questions by converting the questions into code and running in a sandboxed Python environment, you still need to validate the response to confirm that the model correctly translated your question into a valid representation in code. |
| 90 | +
|
| 91 | +## Key concepts |
| 92 | +
|
| 93 | +While using the Assistants playground, keep the following concepts in mind. |
| 94 | +
|
| 95 | +### Tools |
| 96 | +
|
| 97 | +An individual assistant can access up to 128 tools including `code interpreter`, as well as any custom tools you create via [functions](../how-to/assistant-functions.md). |
| 98 | +
|
| 99 | +### Chat session |
| 100 | +
|
| 101 | +Chat session also known as a *thread* within the Assistant's API is where the conversation between the user and assistant occurs. Unlike traditional chat completion calls there is no limit to the number of messages in a thread. The assistant will automatically compress requests to fit the input token limit of the model. |
| 102 | +
|
| 103 | +This also means that you are not controlling how many tokens are passed to the model during each turn of the conversation. Managing tokens is abstracted away and handled entirely by the Assistants API. |
| 104 | +
|
| 105 | +Select the **Clear chat** button to delete the current conversation history. |
| 106 | +
|
| 107 | +Underneath the text input box there are two buttons: |
| 108 | +
|
| 109 | +- Add a message without run. |
| 110 | +- Add and run. |
| 111 | +
|
| 112 | +### Logs |
| 113 | +
|
| 114 | +Logs provide a detailed snapshot of what the assistant API activity. |
| 115 | +
|
| 116 | +### Show panels |
| 117 | +
|
| 118 | +By default there are three panels: assistant setup, chat session, and Logs. **Show panels** allows you to add, remove, and rearrange the panels. If you ever close a panel and need to get it back, use **Show panels** to restore the lost panel. |
| 119 | +
|
| 120 | +## Clean up resources |
| 121 | +
|
| 122 | +If you want to clean up and remove an OpenAI resource, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it. |
| 123 | +
|
| 124 | +- [Portal](../../multi-service-resource.md?pivots=azportal#clean-up-resources) |
| 125 | +- [Azure CLI](../../multi-service-resource.md?pivots=azcli#clean-up-resources) |
| 126 | +
|
| 127 | +Alternatively you can delete the [assistant](../assistants-reference.md#delete-assistant), or [thread](../assistants-reference-threads.md#delete-thread) via the [Assistant's API](../assistants-reference.md). |
| 128 | +
|
| 129 | +## See also |
| 130 | +
|
| 131 | +* Learn more about how to use Assistants with our [How-to guide on Assistants](../how-to/assistant.md). |
| 132 | +* [Azure OpenAI Assistants API samples](https://github.com/Azure-Samples/azureai-samples/tree/main/scenarios/Assistants) |
0 commit comments