From fffa30d73bf9c3807f2520ba914951e0c7f14c52 Mon Sep 17 00:00:00 2001 From: Mustafa Hosseinzadeh <43893019+mustafahsz@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:07:07 +0330 Subject: [PATCH] Update testing-with-copilot.md The code was updated to use modern ES6 import syntax instead of require. Additionally, it now uses the OpenAI class directly instead of OpenAIApi and Configuration, simplifying the initialization process. This modernization improves readability and aligns with current JavaScript standards. No changes were made to the functionality. --- docs/copilot/testing-with-copilot.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/copilot/testing-with-copilot.md b/docs/copilot/testing-with-copilot.md index 2c1f638f94..92b6795fd8 100644 --- a/docs/copilot/testing-with-copilot.md +++ b/docs/copilot/testing-with-copilot.md @@ -42,13 +42,14 @@ If you have implemented a `PromptHandler` for a specific LLM or service, conside ### Example of a `PromptHandler` for OpenAI's GPT-4 ```javascript -const { Configuration, OpenAIApi } = require('openai'); +import OpenAI from 'openai'; + const path = require('path'); class OpenAIPromptHandler { constructor(apiKey) { - const configuration = new Configuration({ apiKey }); - this.openai = new OpenAIApi(configuration); + const configuration = new OpenAI({ apiKey }); + this.openai = new OpenAI(configuration); } async runPrompt(prompt, imagePath) { @@ -71,7 +72,7 @@ class OpenAIPromptHandler { } } - const response = await this.openai.createChatCompletion({ + const response = await this.openai.chat.completions.create({ model: 'gpt-4', messages, });