import { Op, OpOptions } from './opType'; /** * A wrapper to weave op-ify a function or method that works on sync and async functions. * * Wrapped functions: * 1. Take the same inputs and return the same outputs as the original function. * 2. Will automatically track calls in the Weave UI. * * If you don't call `weave.init` then the function will behave as if it were not wrapped. * * @param fn The function to wrap * @param options Optional configs like call and param naming * @returns The wrapped function * * @example * // Basic usage * import OpenAI from 'openai'; * import * as weave from 'weave'; * * const client = await weave.init({ project: 'my-project' }); * const oaiClient = weave.wrapOpenAI(new OpenAI()); * * const extract = weave.op(async function extract() { * return await oaiClient.chat.completions.create({ * model: 'gpt-4-turbo', * messages: [{ role: 'user', content: 'Create a user as JSON' }], * }); * }); * * await extract(); * * // You can also wrap methods by passing the object as the first argument. * // This will bind the method to the object and wrap it with op. * class MyModel { * private oaiClient: OpenAI; * * constructor() { * this.oaiClient = weave.wrapOpenAI(new OpenAI()); * this.invoke = weave.op(this, this.invoke); * } * * async invoke() { * return await this.oaiClient.chat.completions.create({ * model: 'gpt-4-turbo', * messages: [{ role: 'user', content: 'Create a user as JSON' }], * }); * } * } * * const model = new MyModel(); * const res = await model.invoke(); */ export declare function op any>(fn: T, options?: OpOptions): Op<(...args: Parameters) => Promise>>>; export declare function op any>(thisArg: any, fn: T, options?: OpOptions): Op<(...args: Parameters) => Promise>>>; export declare function isOp(fn: any): fn is Op; //# sourceMappingURL=op.d.ts.map