@@ -32,13 +32,33 @@ For passwordless authentication, you need to
32
32
33
33
## Set up
34
34
35
+ 1 . Create a new folder ` assistants-quickstart ` to contain the application and open Visual Studio Code in that folder with the following command:
36
+
37
+ ``` shell
38
+ mkdir assistants-quickstart && code assistants-quickstart
39
+ ```
40
+
41
+
42
+ 1. Create the ` package.json` with the following command:
43
+
44
+ ` ` ` shell
45
+ npm init -y
46
+ ` ` `
47
+
48
+ 1. Update the ` package.json` to ECMAScript with the following command:
49
+
50
+ ` ` ` shell
51
+ npm pkg set type=module
52
+ ` ` `
53
+
54
+
35
55
1. Install the OpenAI Assistants client library for JavaScript with:
36
56
37
57
` ` ` console
38
58
npm install openai
39
59
` ` `
40
60
41
- 2 . For the **recommended** passwordless authentication:
61
+ 1 . For the ** recommended** passwordless authentication:
42
62
43
63
` ` ` console
44
64
npm install @azure/identity
@@ -104,27 +124,68 @@ An individual assistant can access up to 128 tools including `code interpreter`,
104
124
105
125
# ### [TypeScript](#tab/typescript)
106
126
107
- Sign in to Azure with ` az login ` then create and run an assistant with the following ** recommended** passwordless TypeScript module (index.ts):
127
+ Create an assistant with the following ** recommended** passwordless TypeScript module (index.ts):
108
128
109
129
:::code language=" typescript" source=" ~/azure-typescript-e2e-apps/quickstarts/azure-openai-assistants/ts/src/index.ts" :::
110
130
111
131
To use the service key for authentication, you can create and run an assistant with the following TypeScript module (index.ts):
112
132
113
133
:::code language=" typescript" source=" ~/azure-typescript-e2e-apps/quickstarts/azure-openai-assistants/ts/src/index-using-password.ts" :::
114
134
135
+ Create the ` tsconfig.json` file to transpile the TypeScript code and copy the following code for ECMAScript.
136
+
137
+ ` ` ` json
138
+ {
139
+ " compilerOptions" : {
140
+ " target" : " es2022" ,
141
+ " module" : " es2022" ,
142
+ " moduleResolution" : " node" ,
143
+ }
144
+ }
145
+ ` ` `
146
+
115
147
# ### [JavaScript](#tab/javascript)
116
148
117
- Sign in to Azure with ` az login ` then create and run an assistant with the following ** recommended** passwordless JavaScript module (index.mjs):
149
+ Create an assistant with the following ** recommended** passwordless JavaScript module (index.mjs):
118
150
119
151
:::code language=" javascript" source=" ~/azure-typescript-e2e-apps/quickstarts/azure-openai-assistants/js/src/index.mjs" :::
120
152
121
153
To use the service key for authentication, you can create and run an assistant with the following JavaScript module (index.mjs):
122
154
123
155
:::code language=" javascript" source=" ~/azure-typescript-e2e-apps/quickstarts/azure-openai-assistants/js/src/index-using-password.mjs" :::
124
156
125
-
126
157
---
127
158
159
+ # # Run the code
160
+
161
+ 1. Sign in to Azure with ` az login` .
162
+
163
+ 2. Run the code
164
+
165
+ # ### [TypeScript](#tab/typescript)
166
+
167
+ Transpile from TypeScript to JavaScript.
168
+
169
+ ` ` ` shell
170
+ tsc index.ts
171
+ ` ` `
172
+
173
+ Run the JavaScript file.
174
+
175
+ ` ` ` shell
176
+ node index.js
177
+ ` ` `
178
+
179
+ # ### [JavaScript](#tab/javascript)
180
+
181
+ Run the JavaScript file.
182
+
183
+ ` ` ` shell
184
+ node index.js
185
+ ` ` `
186
+
187
+ ```
188
+
128
189
## Output
129
190
130
191
``` console
0 commit comments