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
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/use-your-data-javascript.md
+3-205Lines changed: 3 additions & 205 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,123 +23,15 @@ 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
-
36
26
```console
37
27
npm install @azure/openai @azure/identity
38
28
```
39
29
40
-
---
41
-
42
30
Your app's _package.json_ file will be updated with the dependencies.
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.
1. 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.
145
37
@@ -231,101 +123,7 @@ Your app's _package.json_ file will be updated with the dependencies.
"What's the most common feedback we received from our customers about the product?",
278
-
},
279
-
],
280
-
max_tokens: 128,
281
-
model: "",
282
-
data_sources: [
283
-
{
284
-
type: "azure_search",
285
-
parameters: {
286
-
endpoint: searchEndpoint,
287
-
index_name: searchIndex,
288
-
authentication: {
289
-
type: "api_key",
290
-
key: searchKey,
291
-
},
292
-
},
293
-
},
294
-
],
295
-
});
296
-
297
-
let response = "";
298
-
for await (const event of events) {
299
-
for (const choice of event.choices) {
300
-
const newText = choice.delta?.content;
301
-
if (newText) {
302
-
response += newText;
303
-
// To see streaming results as they arrive, uncomment line below
304
-
// console.log(newText);
305
-
}
306
-
}
307
-
}
308
-
console.log(response);
309
-
}
310
-
311
-
main().catch((err) => {
312
-
console.error("The sample encountered an error:", err);
313
-
});
314
-
```
315
-
316
-
1.Buildtheapplicationwiththefollowingcommand:
317
-
318
-
```console
319
-
tsc
320
-
```
321
-
322
-
1.Runtheapplicationwiththefollowingcommand:
323
-
324
-
```console
325
-
node ChatWithOwnData.js
326
-
```
327
-
328
-
#### [JavaScript (APIkey)](#tab/javascript-key)
126
+
#### [API key](#tab/javascript-key)
329
127
330
128
1. 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.
0 commit comments