From 2b498290a031fa3fbaad4cfdb76755f25318fdbb Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:16:34 -0700 Subject: [PATCH] fix: use `gpt-4o` as default model (#63) this aligns with other uses across github --- index.d.ts | 4 +--- index.test-d.ts | 2 +- lib/prompt.js | 10 +++++----- test/prompt.test.js | 14 +++++++------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/index.d.ts b/index.d.ts index 24ae984..dd799e1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -47,9 +47,7 @@ export type CreateConfirmationEventOptions = { }; export interface CreateConfirmationEventInterface { - ( - options: CreateConfirmationEventOptions, - ): string; + (options: CreateConfirmationEventOptions): string; } export interface CreateReferencesEventInterface { (references: CopilotReference[]): string; diff --git a/index.test-d.ts b/index.test-d.ts index 0a41a4d..d57ca79 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -218,7 +218,7 @@ export async function promptTest() { await prompt("What is the capital of France?", { token: "secret", request: { - fetch: () => { }, + fetch: () => {}, }, }); diff --git a/lib/prompt.js b/lib/prompt.js index 6dd4ff7..fb5cc80 100644 --- a/lib/prompt.js +++ b/lib/prompt.js @@ -1,15 +1,16 @@ // @ts-check -/** @type {import('..').PromptInterface} */ +const DEFAULT_ENDPOINT = "https://api.githubcopilot.com/chat/completions"; +const DEFAULT_MODEL = "gpt-4o"; +/** @type {import('..').PromptInterface} */ function parsePromptArguments(userPrompt, promptOptions) { const { request: requestOptions, ...options } = typeof userPrompt === "string" ? promptOptions : userPrompt; const promptFetch = requestOptions?.fetch || fetch; - const model = options.model || "gpt-4"; - const endpoint = - options.endpoint || "https://api.githubcopilot.com/chat/completions"; + const model = options.model || DEFAULT_MODEL; + const endpoint = options.endpoint || DEFAULT_ENDPOINT; const systemMessage = options.tools ? "You are a helpful assistant. Use the supplied tools to assist the user." @@ -58,7 +59,6 @@ async function sendPromptRequest(promptFetch, options) { } const body = await response.text(); - console.log({ body }); throw Object.assign( new Error( diff --git a/test/prompt.test.js b/test/prompt.test.js index 7820464..897832c 100644 --- a/test/prompt.test.js +++ b/test/prompt.test.js @@ -35,7 +35,7 @@ suite("prompt", () => { content: "What is the capital of France?", }, ], - model: "gpt-4", + model: "gpt-4o", }), }) .reply( @@ -152,7 +152,7 @@ suite("prompt", () => { { role: "assistant", content: "The capital of France is Paris." }, { role: "user", content: "What about Spain?" }, ], - model: "gpt-4", + model: "gpt-4o", }), }) .reply( @@ -216,7 +216,7 @@ suite("prompt", () => { content: "What is the capital of France?", }, ], - model: "gpt-4", + model: "gpt-4o", }), }) .reply( @@ -273,7 +273,7 @@ suite("prompt", () => { { role: "assistant", content: "The capital of France is Paris." }, { role: "user", content: "What about Spain?" }, ], - model: "gpt-4", + model: "gpt-4o", }), }) .reply( @@ -342,7 +342,7 @@ suite("prompt", () => { }, { role: "user", content: "Call the function" }, ], - model: "gpt-4", + model: "gpt-4o", toolsChoice: "auto", }), }) @@ -412,7 +412,7 @@ suite("prompt", () => { content: "What is the capital of France?", }, ], - model: "gpt-4", + model: "gpt-4o", }), }) .reply(400, "Bad Request", { @@ -453,7 +453,7 @@ suite("prompt", () => { role: "user", }, ], - model: "gpt-4", + model: "gpt-4o", toolsChoice: undefined, }, },