Load the JS client using pnpm workspaces
This makes it so we're using our own openpipe client for all OpenAI calls from the OpenPipe app. The client doesn't do anything at the moment beyond proxying to the OpenAI lib. But this infra work should make it easier to quickly iterate on the client and test the changes in our own app.
This commit is contained in:
@@ -4,19 +4,18 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
console.log("Exporting public OpenAPI schema to client-libs/schema.json");
|
||||
|
||||
const scriptPath = import.meta.url.replace("file://", "");
|
||||
const clientLibsPath = path.join(path.dirname(scriptPath), "../../../../client-libs");
|
||||
|
||||
const schemaPath = path.join(clientLibsPath, "schema.json");
|
||||
const schemaPath = path.join(clientLibsPath, "openapi.json");
|
||||
|
||||
console.log(`Exporting public OpenAPI schema to ${schemaPath}`);
|
||||
|
||||
console.log("Exporting schema");
|
||||
fs.writeFileSync(schemaPath, JSON.stringify(openApiDocument, null, 2), "utf-8");
|
||||
|
||||
console.log("Generating Typescript client");
|
||||
console.log("Generating TypeScript client");
|
||||
|
||||
const tsClientPath = path.join(clientLibsPath, "typescript/codegen");
|
||||
const tsClientPath = path.join(clientLibsPath, "typescript/src/codegen");
|
||||
|
||||
fs.rmSync(tsClientPath, { recursive: true, force: true });
|
||||
|
||||
@@ -27,6 +26,8 @@ execSync(
|
||||
},
|
||||
);
|
||||
|
||||
console.log("Done!");
|
||||
console.log("Generating Python client");
|
||||
|
||||
process.exit(0);
|
||||
execSync(path.join(clientLibsPath, "python/codegen.sh"));
|
||||
|
||||
console.log("Done!");
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { type ClientOptions, default as OriginalOpenAI } from "openai";
|
||||
import { type ClientOptions } from "openai";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import OpenAI from "openpipe/src/openai";
|
||||
|
||||
import { env } from "~/env.mjs";
|
||||
|
||||
// TODO: use local dependency
|
||||
// import { OpenAI } from "openpipe";
|
||||
|
||||
let config: ClientOptions;
|
||||
|
||||
try {
|
||||
@@ -23,4 +21,4 @@ try {
|
||||
|
||||
// export const openai = env.OPENPIPE_API_KEY ? new OpenAI.OpenAI(config) : new OriginalOpenAI(config);
|
||||
|
||||
export const openai = new OriginalOpenAI(config);
|
||||
export const openai = new OpenAI(config);
|
||||
|
||||
Reference in New Issue
Block a user