You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[!INCLUDE [Set up required variables](./use-your-data-common-variables.md)]
@@ -23,81 +23,214 @@ npm init
23
23
24
24
Install the Azure OpenAI client and Azure Identity libraries for JavaScript with npm:
25
25
26
+
#### [TypeScript](#tab/typescript)
27
+
28
+
```console
29
+
npm install openai @azure/identity @azure/openai
30
+
```
31
+
32
+
The `@azure/openai/types` dependency is included to extend the Azure OpenAI model for the `data_sources` property. This import is only necessary for TypeScript.
33
+
34
+
#### [JavaScript](#tab/javascript)
35
+
26
36
```console
27
37
npm install @azure/openai @azure/identity
28
38
```
29
39
40
+
---
41
+
30
42
Your app's _package.json_ file will be updated with the dependencies.
31
43
32
44
## Create a sample application
33
45
34
-
Open a command prompt where you want the new project, and create a new file named ChatWithOwnData.js. Copy the following code into the ChatWithOwnData.js file.
// To see streaming results as they arrive, uncomment line below
79
-
// console.log(newText);
46
+
#### [TypeScript](#tab/typescript)
47
+
48
+
1. Open a command prompt where you want the new project, and create a new file named `ChatWithOwnData.ts`. Copy the following code into the `ChatWithOwnData.ts` file.
49
+
50
+
```typescript
51
+
import"dotenv/config";
52
+
import { AzureOpenAI } from"openai";
53
+
import"@azure/openai/types";
54
+
55
+
// Set the Azure and AI Search values from environment variables
- An Azure OpenAI resource deployed in a [supported region and with a supported model](./concepts/use-your-data.md#regional-availability-and-model-support).
52
57
53
-
- Be sure that you are assigned at least the [Cognitive Services Contributor](./how-to/role-based-access-control.md#cognitive-services-contributor) role for the Azure OpenAI resource.
58
+
- Be sure that you're assigned at least the [Cognitive Services Contributor](./how-to/role-based-access-control.md#cognitive-services-contributor) role for the Azure OpenAI resource.
54
59
55
60
- Download the example data from [GitHub](https://github.com/Azure-Samples/cognitive-services-sample-data-files/blob/master/openai/contoso_benefits_document_example.pdf) if you don't have your own data.
56
61
62
+
#### [JavaScript](#tab/javascript)
63
+
64
+
- An Azure subscription - <ahref="https://azure.microsoft.com/free/cognitive-services"target="_blank">Create one for free</a>.
65
+
-[LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
66
+
- An Azure OpenAI resource deployed in a [supported region and with a supported model](./concepts/use-your-data.md#regional-availability-and-model-support).
67
+
68
+
- Be sure that you're assigned at least the [Cognitive Services Contributor](./how-to/role-based-access-control.md#cognitive-services-contributor) role for the Azure OpenAI resource.
69
+
70
+
- Download the example data from [GitHub](https://github.com/Azure-Samples/cognitive-services-sample-data-files/blob/master/openai/contoso_benefits_document_example.pdf) if you don't have your own data.
71
+
72
+
---
73
+
57
74
::: zone pivot="programming-language-javascript"
58
75
76
+
77
+
59
78
-[Long Term Support (LTS) versions of Node.js](https://github.com/nodejs/release#release-schedule)
0 commit comments