@mastra/openai 1.0.1-alpha.9 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts DELETED
@@ -1,59 +0,0 @@
1
- import { Integration, ToolApi } from '@mastra/core';
2
-
3
- // @ts-ignore
4
- import OpenaiLogo from './assets/openai.png';
5
- import { comments } from './client/service-comments';
6
- import * as integrationClient from './client/services.gen';
7
- import * as zodSchema from './client/zodSchema';
8
-
9
- type OpenaiConfig = {
10
- API_KEY: string;
11
- [key: string]: any;
12
- };
13
-
14
- export class OpenaiIntegration extends Integration {
15
- readonly name = 'OPENAI';
16
- readonly logoUrl = OpenaiLogo;
17
- config: OpenaiConfig;
18
- readonly tools: Record<Exclude<keyof typeof integrationClient, 'client'>, ToolApi>;
19
- categories = ['ai'];
20
- description =
21
- 'OpenAI is an artificial intelligence platform that provides a set of tools and APIs for building AI-powered applications.';
22
-
23
- constructor({ config }: { config: OpenaiConfig }) {
24
- super();
25
-
26
- this.config = config;
27
- this.tools = this._generateIntegrationTools<typeof this.tools>();
28
- }
29
-
30
- protected get toolSchemas() {
31
- return zodSchema;
32
- }
33
-
34
- protected get toolDocumentations() {
35
- return comments;
36
- }
37
-
38
- protected get baseClient() {
39
- integrationClient.client.setConfig({
40
- baseUrl: `https://api.openai.com/v1`,
41
- });
42
- return integrationClient;
43
- }
44
-
45
- getApiClient = async () => {
46
- const value = {
47
- API_KEY: this.config?.['API_KEY'],
48
- } as Record<string, any>;
49
-
50
- const baseClient = this.baseClient;
51
-
52
- baseClient.client.interceptors.request.use((request, options) => {
53
- request.headers.set('Authorization', `Bearer ${value?.['API_KEY']}`);
54
- return request;
55
- });
56
-
57
- return integrationClient;
58
- };
59
- }