From 47782abeca20175319c2a3c7dcd4a776c3ab3df1 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Mon, 29 Apr 2024 11:20:47 -0700 Subject: [PATCH] better handling of starting the prmpt --- packages/core/src/test.ts | 14 +++++++++++-- packages/vscode/src/fragmentcommands.ts | 28 +++++++++++++++---------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/packages/core/src/test.ts b/packages/core/src/test.ts index 363056046d..0fae00638f 100644 --- a/packages/core/src/test.ts +++ b/packages/core/src/test.ts @@ -44,13 +44,23 @@ export function generatePromptFooConfiguration( text: { id: "azureopenai:chat:gpt-4", config: { - apiHost: testProvider, + apiHost: testProvider + .replace(/^https:\/\//i, "") + .replace( + /\/openai\/deployments$/i, + "" + ), }, }, embedding: { id: "azureopenai:embeddings:text-embedding-ada-002", config: { - apiHost: testProvider, + apiHost: testProvider + .replace(/^https:\/\//i, "") + .replace( + /\/openai\/deployments$/i, + "" + ), }, }, } diff --git a/packages/vscode/src/fragmentcommands.ts b/packages/vscode/src/fragmentcommands.ts index bed1273394..21d7d3e33b 100644 --- a/packages/vscode/src/fragmentcommands.ts +++ b/packages/vscode/src/fragmentcommands.ts @@ -73,17 +73,23 @@ async function showPromptParametersQuickPicks( } async function startTestViewer() { - // show results - const url = "http://localhost:15500" - const terminal = vscode.window.createTerminal({ - name: "Promptfoo viewer", - isTransient: true, - env: { - PROMPTFOO_DISABLE_TELEMETRY: "1", - PROMPTFOO_DISABLE_UPDATE: "1", - }, - }) - terminal.sendText(`npx --yes promptfoo@latest view -y`) + const name = "Promptfoo View" + if (vscode.window.terminals.find((t) => t.name === name)) { + await vscode.env.openExternal( + vscode.Uri.parse("http://localhost:15500") + ) + } else { + // show results + const terminal = vscode.window.createTerminal({ + name, + isTransient: true, + env: { + PROMPTFOO_DISABLE_TELEMETRY: "1", + PROMPTFOO_DISABLE_UPDATE: "1", + }, + }) + terminal.sendText(`npx --yes promptfoo@latest view -y`) + } } export function activateFragmentCommands(state: ExtensionState) {