Skip to content

Commit 3847445

Browse files
authored
Switch JavaScript to the new repo location
1 parent f9f9592 commit 3847445

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

articles/azure-functions/functions-add-openai-text-completion.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Tutorial: Connect to OpenAI from Azure Functions in Visual Studio Code'
33
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
55
ms.topic: tutorial
66
author: dbandaru
77
ms.author: dbandaru
@@ -198,34 +198,15 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
198198

199199
1. In the new `whois.js` code file, replace the contents of the file with this code:
200200

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" :::
221202

222203
:::zone-end
223204
:::zone pivot="programming-language-typescript"
224205
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.
225206

226207
1. In the new `whois.ts` code file, replace the contents of the file with this code:
227208

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" :::
229210

230211
:::zone-end
231212
:::zone pivot="programming-language-python"

0 commit comments

Comments
 (0)