|
1 | 1 | ---
|
2 | 2 | title: 'Tutorial: Connect to OpenAI from Azure Functions in Visual Studio Code'
|
3 | 3 | description: Learn how to connect Azure Functions to OpenAI by adding an output binding to your Visual Studio Code project.
|
4 |
| -ms.date: 07/02/2024 |
| 4 | +ms.date: 07/08/2024 |
5 | 5 | ms.topic: tutorial
|
6 | 6 | author: dbandaru
|
7 | 7 | ms.author: dbandaru
|
@@ -198,34 +198,15 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
|
198 | 198 |
|
199 | 199 | 1. In the new `whois.js` code file, replace the contents of the file with this code:
|
200 | 200 |
|
201 |
| - ```javascript |
202 |
| - const { app, input } = require("@azure/functions"); |
203 |
| - |
204 |
| - const openAICompletionInput = input.generic({ |
205 |
| - prompt: 'Who is {name}?', |
206 |
| - maxTokens: '100', |
207 |
| - type: 'textCompletion', |
208 |
| - model: '%CHAT_MODEL_DEPLOYMENT_NAME%' |
209 |
| - }); |
210 |
| - app.http('whois', { |
211 |
| - methods: ['GET'], |
212 |
| - route: 'whois/{name}', |
213 |
| - authLevel: 'anonymous', |
214 |
| - extraInputs: [openAICompletionInput], |
215 |
| - handler: async (request, context) => { |
216 |
| - var response = context.extraInputs.get(openAICompletionInput); |
217 |
| - return { body: response.content.trim() }; |
218 |
| - } |
219 |
| - }); |
220 |
| - ``` |
| 201 | + :::code language="javascript" source="~/functions-openai-extension/samples/textcompletion/javascript/src/functions/whois.js" ::: |
221 | 202 |
|
222 | 203 | :::zone-end
|
223 | 204 | :::zone pivot="programming-language-typescript"
|
224 | 205 | 1. In Visual Studio Code, Press F1 and in the command palette type `Azure Functions: Create Function...`, select **HTTP trigger**, type the function name `whois`, select **Anonymous**, and press Enter.
|
225 | 206 |
|
226 | 207 | 1. In the new `whois.ts` code file, replace the contents of the file with this code:
|
227 | 208 |
|
228 |
| - :::code language="typescript" source="~/functions-openai-extension/samples/textcompletion/nodejs/src/functions/whois.ts" ::: |
| 209 | + :::code language="typescript" source="~/functions-openai-extension/samples/textcompletion/typescript/src/functions/whois.ts" ::: |
229 | 210 |
|
230 | 211 | :::zone-end
|
231 | 212 | :::zone pivot="programming-language-python"
|
|
0 commit comments