|
1 | 1 | import {convertDocToFormData} from '@/lib/utils/doc-to-formdata'; |
2 | 2 | import {Request} from '../common/request'; |
3 | 3 | import {Workflow} from './workflows'; |
| 4 | +import { |
| 5 | + Images, |
| 6 | + ImageGenerationOptions, |
| 7 | + ImageGenerationResponse, |
| 8 | +} from './images'; |
4 | 9 |
|
5 | 10 | export type Role = 'user' | 'assistant' | 'system' | 'tool'; |
6 | 11 |
|
@@ -646,6 +651,12 @@ export class Langbase { |
646 | 651 | create: (trace: any) => Promise<any>; |
647 | 652 | }; |
648 | 653 |
|
| 654 | + public images: { |
| 655 | + generate: ( |
| 656 | + options: ImageGenerationOptions, |
| 657 | + ) => Promise<ImageGenerationResponse>; |
| 658 | + }; |
| 659 | + |
649 | 660 | constructor(options?: LangbaseOptions) { |
650 | 661 | this.baseUrl = options?.baseUrl ?? 'https://api.langbase.com'; |
651 | 662 | this.apiKey = options?.apiKey ?? ''; |
@@ -737,6 +748,12 @@ export class Langbase { |
737 | 748 | this.traces = { |
738 | 749 | create: this.createTrace.bind(this), |
739 | 750 | }; |
| 751 | + |
| 752 | + // Initialize images primitive |
| 753 | + const imagesInstance = new Images(this.request); |
| 754 | + this.images = { |
| 755 | + generate: imagesInstance.generate.bind(imagesInstance), |
| 756 | + }; |
740 | 757 | } |
741 | 758 |
|
742 | 759 | private async runPipe( |
@@ -942,7 +959,7 @@ export class Langbase { |
942 | 959 | Authorization: `Bearer ${this.apiKey}`, |
943 | 960 | 'Content-Type': options.contentType, |
944 | 961 | }, |
945 | | - body: options.document, |
| 962 | + body: options.document as any, |
946 | 963 | }); |
947 | 964 | } catch (error) { |
948 | 965 | throw error; |
|
0 commit comments