Add smoketest (broken)
This commit is contained in:
@@ -36,10 +36,7 @@ export class OpenPipeApi {
|
||||
modelProvider: T,
|
||||
promptFunction: () => PromptTypes[T],
|
||||
scenarioVariables: Record<string, unknown>
|
||||
): Promise<{
|
||||
id?: string;
|
||||
prompt: PromptTypes[T];
|
||||
}> {
|
||||
) {
|
||||
const prompt = promptFunction() as PromptTypes[T];
|
||||
if (!prompt) {
|
||||
console.error("Prompt function returned null", promptFunction.toString());
|
||||
@@ -65,11 +62,14 @@ export class OpenPipeApi {
|
||||
|
||||
return {
|
||||
id: resp?.data?.loggedCallId,
|
||||
prompt,
|
||||
}
|
||||
prompt: prompt!,
|
||||
};
|
||||
}
|
||||
|
||||
public async captureResponse(loggedCallId: string | undefined, responsePayload: any): Promise<void> {
|
||||
public async captureResponse(
|
||||
loggedCallId: string | undefined,
|
||||
responsePayload: any
|
||||
): Promise<void> {
|
||||
if (!loggedCallId) {
|
||||
console.error("No call log ID provided to captureResponse");
|
||||
return;
|
||||
@@ -84,6 +84,5 @@ export class OpenPipeApi {
|
||||
} catch (err) {
|
||||
console.error("Error reporting to OpenPipe", err);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"smoketest": "tsx ./tests/smoketest.ts"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -14,6 +14,7 @@
|
||||
"openai": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.4.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"tsx": "^3.12.7",
|
||||
"typescript": "^5.1.6"
|
||||
|
||||
7
client-libs/js/pnpm-lock.yaml
generated
7
client-libs/js/pnpm-lock.yaml
generated
@@ -13,6 +13,9 @@ dependencies:
|
||||
version: 3.3.0
|
||||
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^20.4.5
|
||||
version: 20.4.5
|
||||
dotenv:
|
||||
specifier: ^16.3.1
|
||||
version: 16.3.1
|
||||
@@ -244,6 +247,10 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@types/node@20.4.5:
|
||||
resolution: {integrity: sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==}
|
||||
dev: true
|
||||
|
||||
/asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
dev: false
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import "dotenv/config";
|
||||
import { Configuration, OpenPipeApi } from "../index";
|
||||
import { Configuration, OpenAIApi } from 'openai'
|
||||
import { Configuration as OPConfiguration, OpenPipeApi } from "..";
|
||||
|
||||
const config = new Configuration({
|
||||
|
||||
export const openAIConfig = new Configuration({ apiKey: process.env.OPENAI_API_KEY });
|
||||
|
||||
const openai = new OpenAIApi(openAIConfig);
|
||||
|
||||
const config = new OPConfiguration({
|
||||
opOptions: {
|
||||
apiKey: "mock-key",
|
||||
basePath: "http://localhost:3000/api",
|
||||
@@ -11,7 +17,7 @@ const config = new Configuration({
|
||||
const client = new OpenPipeApi(config);
|
||||
|
||||
async function main() {
|
||||
const prompt = client.capturePrompt(
|
||||
const prompt = await client.capturePrompt(
|
||||
"123",
|
||||
"openai/ChatCompletion",
|
||||
() => ({
|
||||
@@ -26,17 +32,9 @@ async function main() {
|
||||
{}
|
||||
);
|
||||
|
||||
const response = await client.createChatCompletion({
|
||||
model: "gpt-3.5-turbo",
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: "count to 3 in french",
|
||||
},
|
||||
],
|
||||
});
|
||||
const response = await openai.createChatCompletion(prompt.prompt);
|
||||
|
||||
console.log("got response", response.data);
|
||||
console.log("got response", response.data.choices[0].message);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user