Files
OpenPipe-llm/client-libs/typescript/shared.ts
Kyle Corbitt 1684663ddc Publish the ingestion library to NPM (#204)
* Update client libs typescript README

* Create index.d.ts files

* Publish the ingestion library to NPM

Library is now published at https://www.npmjs.com/package/openpipe; see README for details.

* Rename package.json in /dist folder

* Increment patch version

* Increment package version

* Add newline to publish.sh

---------

Co-authored-by: David Corbitt <davidlcorbitt@gmail.com>
2023-08-29 12:18:57 -07:00

31 lines
852 B
TypeScript

import pkg from "./package.json";
import { DefaultService } from "./codegen";
export type OpenPipeConfig = {
apiKey?: string;
baseUrl?: string;
};
export type OpenPipeArgs = {
openpipe?: { cache?: boolean; tags?: Record<string, string> };
};
export type OpenPipeMeta = {
cacheStatus: "HIT" | "MISS" | "SKIP";
// We report your call to OpenPipe asynchronously in the background. If you
// need to wait until the report is sent to take further action, you can await
// this promise.
reportingFinished: Promise<void>;
};
export type ReportFn = (...args: Parameters<DefaultService["report"]>) => Promise<void>;
export const getTags = (args: OpenPipeArgs["openpipe"]): Record<string, string> => ({
...args?.tags,
...(args?.cache ? { $cache: args.cache?.toString() } : {}),
$sdk: "typescript",
"$sdk.version": pkg.version,
});