Skip to content

Commit e77e25d

Browse files
committed
docs: update readme
1 parent 72a7ada commit e77e25d

File tree

1 file changed

+137
-42
lines changed

1 file changed

+137
-42
lines changed

README.md

Lines changed: 137 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
![Node version](https://img.shields.io/badge/Node.js->=20-3c873a?style=flat-square)
88
[![License](https://img.shields.io/badge/License-MIT-pink?style=flat-square)](LICENSE)
99

10-
:star: Like and fork this sample to receive lastest changes and updates!
10+
Azure OpenAI Assistants allows you to create AI assistants tailored to your needs through custom instructions and augmented by advanced tools like code interpreter, and custom functions. In this article, we provide an in-depth walkthrough of getting started with the Assistants API.
11+
12+
(Like and fork this sample to receive lastest changes and updates)
1113

1214
[![Overview](https://img.shields.io/badge/Getting%20Started-blue?style=flat-square)](#overview)
1315
[![Get started](https://img.shields.io/badge/Get%20Started-blue?style=flat-square)](#get-started)
@@ -23,9 +25,15 @@
2325

2426
This sample shows how to quickly get started with [OpenAI Assistant](https://learn.microsoft.com/azure/ai-services/openai/how-to/assistant) on Azure. The application is hosted on [Azure Static Web Apps](https://learn.microsoft.com/azure/static-web-apps/overview) and [Azure Functions](https://learn.microsoft.com/azure/azure-functions/functions-overview?pivots=programming-language-javascript). You can use it as a starting point for building more complex Assistant and Agent applications.
2527

26-
## Overview
28+
## Features
2729

28-
Azure OpenAI Assistants allows you to create AI assistants tailored to your needs through custom instructions and augmented by advanced tools like code interpreter, and custom functions. In this article, we provide an in-depth walkthrough of getting started with the Assistants API.
30+
This project demonstrates how to build a simple Assistant application using Azure OpenAI Assistants. The Assistant can help you:
31+
- Retrieve financial information, such as stock values.
32+
- Answer questions.
33+
- Send emails,
34+
- Run custom functions.
35+
36+
## Architecture Diagram
2937

3038
<div align="center">
3139
<img src="./docs/architecture-diagram-assistant-javascript.png" alt="Screenshot showing the assistant app high level diagram" width="640px" />
@@ -37,13 +45,86 @@ This application is built around two main components:
3745

3846
- A serverless API built with [Azure Functions](https://learn.microsoft.com/azure/azure-functions/functions-overview?pivots=programming-language-javascript) and using OpenAI JavaScript SDK. The code is located in the [`api`](./api/) folder.
3947

40-
## Get started
48+
## Getting Started
49+
50+
You have a few options for getting started with this template. The quickest way to get started is [GitHub Codespaces](#github-codespaces), since it will setup all the tools for you, but you can also [set it up locally](#local-environment). You can also use a [VS Code dev container](#vs-code-dev-containers)
51+
52+
This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
53+
54+
* We recommend using `swedencentral`
55+
56+
### GitHub Codespaces
4157

42-
There are multiple ways to get started with this project.
58+
You can run this template virtually by using GitHub Codespaces. The button will open a web-based VS Code instance in your browser:
4359

44-
The quickest way is to use [GitHub Codespaces](#use-github-codespaces) that provides a preconfigured environment for you. Alternatively, you can [set up your local environment](#use-your-local-environment) following the instructions below.
60+
1. Open the template (this may take several minutes)
61+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/azure-openai-assistant-javascript?hide_repo_select=true&ref&quickstart=true)
62+
2. Open a terminal window
63+
3. Sign into your Azure account:
64+
65+
```shell
66+
azd auth login --use-device-code
67+
```
68+
4. Provision the Azure resources and deploy your code:
69+
70+
```shell
71+
azd up
72+
```
73+
5. Open a terminal and navigate to the root of the project, then run the API server first:
74+
75+
```bash
76+
npm install --prefix api
77+
npm start --prefix api
78+
```
79+
80+
6. Open another terminal and navigate to the root of the project, then run the webapp server:
81+
82+
```bash
83+
npm install
84+
npm start
85+
```
86+
87+
Open the URL `http://localhost:4280` in your browser to interact with the Assistant.
4588

46-
### Use your local environment
89+
### VS Code Dev Containers
90+
91+
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):
92+
93+
1. Start Docker Desktop (install it if not already installed)
94+
2. Open the project:
95+
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/azure-openai-assistant-javascript)
96+
3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window.
97+
4. Sign into your Azure account:
98+
99+
```shell
100+
azd auth login
101+
```
102+
4. Provision the Azure resources and deploy your code:
103+
104+
```shell
105+
azd up
106+
```
107+
5. Open a terminal and navigate to the root of the project, then run the API server first:
108+
109+
```bash
110+
npm install --prefix api
111+
npm start --prefix api
112+
```
113+
6. Open another terminal and navigate to the root of the project, then run the webapp server:
114+
115+
```bash
116+
npm install
117+
npm start
118+
```
119+
8. Configure a CI/CD pipeline:
120+
121+
```shell
122+
azd pipeline config
123+
```
124+
125+
### Local Environment
126+
127+
#### Prerequisites
47128

48129
You need to install following tools to work on your local machine:
49130

@@ -55,30 +136,47 @@ You need to install following tools to work on your local machine:
55136
- **Important**: Ensure you can run `pwsh.exe` from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
56137
- Instead of Powershell, you can also use Git Bash or WSL to run the Azure Developer CLI commands.
57138
- (Optional - if you are not using SWA CLI) [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local?tabs=macos%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-javascript) _(should be installed automatically with NPM, only install manually if the API fails to start)_
139+
- This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
140+
* We recommend using `swedencentral`
58141

59142
Then you can get the project code:
60143

61144
1. [**Fork**](https://github.com/Azure-Samples/azure-openai-assistant-javascript/fork) the project to create your own copy of this repository.
62145
2. On your forked repository, select the **Code** button, then the **Local** tab, and copy the URL of your forked repository.
63146
3. Open a terminal and run this command to clone the repo: <code> git clone &lt;your-repo-url&gt; </code>
64147

65-
### Use GitHub Codespaces
148+
#### Quickstart (with Azure OpenAI models)
66149

67-
You can run this project directly in your browser by using GitHub Codespaces, which will open a web-based VS Code:
150+
1. Bring down the template code:
68151

69-
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=blue&logo=github)](https://codespaces.new/Azure-Samples/azure-openai-assistant-javascript?hide_repo_select=true&ref&quickstart=true)
152+
```shell
153+
azd init --template azure-openai-assistant-javascript
154+
```
70155

71-
### Use a VS Code dev container
156+
This will perform a git clone
72157

73-
A similar option to Codespaces is VS Code Dev Containers, that will open the project in your local VS Code instance using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
158+
2. Sign into your Azure account:
74159

75-
You will also need to have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine to run the container.
160+
```shell
161+
azd auth login
162+
```
76163

77-
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/azure-openai-assistant-javascript)
164+
3. Install all dependencies:
78165

79-
## Run the sample locally (with Azure OpenAI models)
166+
```bash
167+
npm install
168+
npm install --prefix api
169+
```
170+
4. Provision and deploy the project to Azure:
80171

81-
First you need to provision the Azure resources needed to run the sample. Follow the instructions in the [Deploy the sample to Azure](#deploy-the-sample-to-azure) section to deploy the sample to Azure, then you'll be able to run the sample locally using the deployed Azure resources.
172+
```shell
173+
azd up
174+
```
175+
4. Configure a CI/CD pipeline:
176+
177+
```shell
178+
azd pipeline config
179+
```
82180

83181
Once your deployment is complete, you should see a `.env` file in the `api` folder. This file contains the environment variables needed to run the application using Azure resources.
84182

@@ -94,51 +192,48 @@ EMAIL_SENDER_APP_PASSWORD="foobar"
94192

95193
**Important: Please follow [this guide](https://support.microsoft.com/account-billing/manage-app-passwords-for-two-step-verification-d6dc8c6d-4bf7-4851-ad95-6d07799387e9) to generate an Application Password if you are using MFA.**
96194

195+
#### Local Development
196+
97197
To run the sample, run the following commands, which will start the web app, and the API locally.
98198

99199
1. Open a terminal and navigate to the root of the project, then run the API server first:
100200

101-
```bash
102-
npm install --prefix api
103-
npm start --prefix api
104-
```
105-
201+
```bash
202+
npm start --prefix api
203+
```
106204
2. Open another terminal and navigate to the root of the project, then run the webapp server:
107205

108-
```bash
109-
npm install
110-
npm start
111-
```
206+
```bash
207+
npm start
208+
```
112209

113210
Open the URL `http://localhost:4280` in your browser to interact with the Assistant.
114211

115-
### Deploy the sample to Azure
212+
## Guidance
116213

117-
#### Azure prerequisites
214+
### Region Availability
118215

119-
- **Azure account**. If you're new to Azure, [get an Azure account for free](https://azure.microsoft.com/free) to get free Azure credits to get started. If you're a student, you can also get free credits with [Azure for Students](https://aka.ms/azureforstudents).
120-
- **Azure subscription with access enabled for the Azure OpenAI Service**. You can request access with [this form](https://aka.ms/oaiapply).
216+
This template uses `gpt-35-turbo` version `1106` which may not be available in all Azure regions. Check for [up-to-date region availability](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) and select a region during deployment accordingly
217+
* We recommend using `swedencentral`
121218

122-
#### Deploy the sample
219+
### Costs
123220

124-
1. Open a terminal and navigate to the root of the project.
125-
2. Authenticate with Azure by running `azd auth login`.
126-
3. Run `azd up` to deploy the application to Azure. This will provision Azure resources, deploy this sample.
127-
- You will be prompted to select a base location for the resources.
128-
- By default, the OpenAI resource will be deployed to `swedencentral`. You can set a different location with `azd env set AZURE_OPENAI_RESOURCE_GROUP_LOCATION <location>`. Currently only a short list of locations is accepted. **Azure OpenAI Assistants are currently available in Sweden Central, East US 2, and Australia East. For more information about model availability in those regions, [see the models guide](https://learn.microsoft.com/azure/ai-services/openai/concepts/models).**
221+
Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage.
222+
However, you can use the [Azure pricing calculator](https://azure.com/e/bf51ef20b57a4da08e47511938ad5415) for the resources below to get an estimate.
129223
130-
The deployment process will take a few minutes. Once it's done, you'll see the URL of the web app in the terminal.
224+
- Azure Container Apps: Consumption plan, Free for the first 2M executions. Pricing per execution and memory used. [Pricing](https://azure.microsoft.com/en-us/pricing/details/container-apps/)
225+
- Azure OpenAI: Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
131226
132-
You can now open the web app in your browser and start chatting with the bot.
227+
> [!WARNING]
228+
> To avoid unnecessary costs, remember to take down your app if it's no longer in use, either by deleting the resource group in the Portal or running `azd down --purge`.
133229

134-
#### Clean up
230+
### Security
135231

136-
To clean up all the Azure resources created by this sample:
232+
> [!NOTE]
233+
> When implementing this template please specify whether the template uses Managed Identity or Key Vault
137234

138-
1. Run `azd down --purge`
139-
2. When asked if you are sure you want to continue, enter `y`
235+
This template has either [Managed Identity](https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview) or Key Vault built in to eliminate the need for developers to manage these credentials. Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. Additionally, we have added a [GitHub Action tool](https://github.com/microsoft/security-devops-action) that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices in your repo we recommend anyone creating solutions based on our templates ensure that the [Github secret scanning](https://docs.github.com/code-security/secret-scanning/about-secret-scanning) setting is enabled in your repos.
140236

141-
The resource group and all the resources will be deleted.
142237

143238
## Resources
144239

0 commit comments

Comments
 (0)