@alquimia-ai/tools 1.11.0 → 1.11.2

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.
@@ -18,6 +18,7 @@ declare class AlquimiaSDK {
18
18
  private evaluationStrategy;
19
19
  private tools;
20
20
  private extraData;
21
+ private assistantConfig;
21
22
  private forceProfile;
22
23
  private userId;
23
24
  private whisperProvider?;
@@ -39,6 +40,7 @@ declare class AlquimiaSDK {
39
40
  withTools(tools: any): AlquimiaSDK;
40
41
  withExtraData(extraData: any): AlquimiaSDK;
41
42
  withForceProfile(forceProfile: any): AlquimiaSDK;
43
+ withAssistantConfig(assistantConfig: any): AlquimiaSDK;
42
44
  withUserId(userId: string): AlquimiaSDK;
43
45
  textToSpeech(text: string): Promise<TTSResult>;
44
46
  speechToText(audio: string): Promise<string>;
@@ -18,6 +18,7 @@ declare class AlquimiaSDK {
18
18
  private evaluationStrategy;
19
19
  private tools;
20
20
  private extraData;
21
+ private assistantConfig;
21
22
  private forceProfile;
22
23
  private userId;
23
24
  private whisperProvider?;
@@ -39,6 +40,7 @@ declare class AlquimiaSDK {
39
40
  withTools(tools: any): AlquimiaSDK;
40
41
  withExtraData(extraData: any): AlquimiaSDK;
41
42
  withForceProfile(forceProfile: any): AlquimiaSDK;
43
+ withAssistantConfig(assistantConfig: any): AlquimiaSDK;
42
44
  withUserId(userId: string): AlquimiaSDK;
43
45
  textToSpeech(text: string): Promise<TTSResult>;
44
46
  speechToText(audio: string): Promise<string>;
package/dist/sdk/index.js CHANGED
@@ -44,6 +44,7 @@ var AlquimiaSDK = class {
44
44
  this.evaluationStrategy = null;
45
45
  this.tools = {};
46
46
  this.extraData = {};
47
+ this.assistantConfig = {};
47
48
  this.forceProfile = {};
48
49
  this.userId = null;
49
50
  this.config = config;
@@ -123,6 +124,10 @@ var AlquimiaSDK = class {
123
124
  this.forceProfile = forceProfile;
124
125
  return this;
125
126
  }
127
+ withAssistantConfig(assistantConfig) {
128
+ this.assistantConfig = assistantConfig;
129
+ return this;
130
+ }
126
131
  withUserId(userId) {
127
132
  this.userId = userId;
128
133
  return this;
@@ -148,6 +153,8 @@ var AlquimiaSDK = class {
148
153
  session_id: this.conversationId,
149
154
  extra_data: this.extraData,
150
155
  force_profile: this.forceProfile,
156
+ config: this.assistantConfig,
157
+ tools: this.tools,
151
158
  user_id: this.userId
152
159
  };
153
160
  const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/sdk/index.ts","../../src/sdk/alquimia-sdk.ts"],"sourcesContent":["export { default as AlquimiaSDK } from './alquimia-sdk';","import axios, { AxiosInstance } from \"axios\";\nimport {\n StableDiffusionProvider,\n WhisperProvider,\n CharacterizationProvider,\n RatingsProvider,\n LoggerProvider,\n} from \"../providers\";\nimport { TTSResult } from \"../types\";\ninterface AlquimiaSDKConfig {\n apiKey: string;\n chatUrl: string;\n streamUrl: string;\n assistantId: string;\n}\n\n\nclass AlquimiaSDK {\n private config: AlquimiaSDKConfig;\n private axiosInstance: AxiosInstance;\n private conversationId: string | null = null;\n private sessionId: string | null = null;\n private streamId: string | null = null;\n private evaluationStrategy: string | null = null;\n private tools: any = {};\n private extraData: any = {};\n private forceProfile: any = {};\n private userId: string | null = null;\n private whisperProvider?: WhisperProvider\n private stableDiffusionProvider?: StableDiffusionProvider\n private analyzeCharacterizationProvider?: CharacterizationProvider\n private ratingsProvider?: RatingsProvider\n private loggerProvider?: LoggerProvider\n private enforceCharacterization?: boolean\n \n constructor(config: AlquimiaSDKConfig, enforceCharacterization: boolean = true) {\n this.config = config;\n this.enforceCharacterization = enforceCharacterization;\n\n this.axiosInstance = axios.create();\n this.axiosInstance.interceptors.response.use(\n (response) => response,\n async (error) => {\n if (error.response?.status) {\n if (this.loggerProvider) {\n await this.loggerProvider.logError(\n 'Server Error',\n error,\n {\n url: error.config.url,\n method: error.config.method,\n data: error.config.data,\n status: error.response.status,\n responseData: error.response.data\n }\n );\n }\n }\n return Promise.reject(error);\n }\n );\n \n this.textToSpeech = this.textToSpeech.bind(this);\n this.speechToText = this.speechToText.bind(this);\n }\n\n static configure(\n apiKey: string,\n inferUrl: string,\n streamUrl: string,\n assistantId: string\n ): AlquimiaSDKConfig {\n return {\n apiKey,\n chatUrl: `${inferUrl}/chat/${assistantId}`,\n streamUrl: `${streamUrl}`,\n assistantId: assistantId\n };\n }\n\n widthConversationId(conversationId: string ): AlquimiaSDK {\n this.conversationId = conversationId \n return this;\n }\n\n withWhisperProvider(provider: WhisperProvider): AlquimiaSDK {\n this.whisperProvider = provider;\n return this;\n }\n\n withStableDiffusionProvider(provider: StableDiffusionProvider): AlquimiaSDK {\n this.stableDiffusionProvider = provider\n return this\n }\n\n withAnalyzeCharacterizationProvider(provider: CharacterizationProvider): AlquimiaSDK {\n this.analyzeCharacterizationProvider = provider\n return this\n }\n\n withRatingsProvider(provider: RatingsProvider): AlquimiaSDK {\n this.ratingsProvider = provider\n return this\n }\n\n withLoggerProvider(provider: LoggerProvider): AlquimiaSDK {\n this.loggerProvider = provider\n return this\n }\n\n getEnforceCharacterization(): boolean {\n return this.enforceCharacterization ?? true;\n }\n\n getEvaluationStrategy(): string | null {\n return this.evaluationStrategy;\n }\n\n withTools(tools: any): AlquimiaSDK {\n this.tools = tools;\n return this;\n }\n\n withExtraData(extraData: any): AlquimiaSDK {\n this.extraData = extraData;\n return this;\n }\n\n withForceProfile(forceProfile: any): AlquimiaSDK {\n this.forceProfile = forceProfile;\n return this;\n }\n\n withUserId(userId: string): AlquimiaSDK {\n this.userId = userId;\n return this;\n }\n\n textToSpeech(text: string): Promise<TTSResult> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.textToSpeech(text)\n }\n\n speechToText(audio: string): Promise<string> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.speechToText(audio)\n }\n\n async sendMessage(query: string, traceParent?: string) {\n if (!this.conversationId) {\n throw new Error(\"Conversation not initialized\");\n }\n\n const initMessage = {\n query,\n session_id: this.conversationId,\n extra_data: this.extraData,\n force_profile: this.forceProfile,\n user_id: this.userId\n };\n \n const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-trace-parent\": traceParent || \"\",\n },\n })).data\n \n this.evaluationStrategy = result.config.dante.profile.evaluation_strategy.evaluation_strategy_id;\n this.streamId = result.stream_id;\n\n return this\n }\n\n async generateImage(query: string) {\n if (!this.stableDiffusionProvider) {\n throw new Error(\"Stable Diffusion provider not initialized\");\n }\n return this.stableDiffusionProvider.generateImage(query)\n }\n\n async analyzeCharacterization(text: string) {\n if (!this.analyzeCharacterizationProvider) {\n throw new Error(\"analyze characterization provider not initialized\");\n }\n return this.analyzeCharacterizationProvider.analyzeCharacterization(text)\n }\n\n async rate(data: any) {\n if (!this.ratingsProvider) {\n throw new Error(\"ratings provider not initialized\");\n }\n return this.ratingsProvider.rate(data)\n }\n\n async logInfo(message: string, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logInfo(message, data)\n }\n\n async logError(message: string, error: Error, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logError(message, error, data)\n }\n\n getUrlStream() {\n return `${this.config.streamUrl}/${this.streamId}`;\n }\n\n getStreamId() {\n return this.streamId;\n }\n}\n\nexport default AlquimiaSDK;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAqC;AAiBrC,IAAM,cAAN,MAAkB;AAAA,EAkBhB,YAAY,QAA2B,0BAAmC,MAAM;AAfhF,SAAQ,iBAAgC;AACxC,SAAQ,YAA2B;AACnC,SAAQ,WAA0B;AAClC,SAAQ,qBAAoC;AAC5C,SAAQ,QAAa,CAAC;AACtB,SAAQ,YAAiB,CAAC;AAC1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WAAO;AAAA,EACX;AAAA,EAEA,MAAM,cAAc,OAAe;AACjC,QAAI,CAAC,KAAK,yBAAyB;AACjC,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AACA,WAAO,KAAK,wBAAwB,cAAc,KAAK;AAAA,EACzD;AAAA,EAEA,MAAM,wBAAwB,MAAc;AAC1C,QAAI,CAAC,KAAK,iCAAiC;AACzC,YAAM,IAAI,MAAM,mDAAmD;AAAA,IACrE;AACA,WAAO,KAAK,gCAAgC,wBAAwB,IAAI;AAAA,EAC1E;AAAA,EAEA,MAAM,KAAK,MAAW;AACpB,QAAI,CAAC,KAAK,iBAAiB;AACzB,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AACA,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACvC;AAAA,EAEA,MAAM,QAAQ,SAAiB,MAAW;AACxC,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,QAAQ,SAAS,IAAI;AAAA,EAClD;AAAA,EAEA,MAAM,SAAS,SAAiB,OAAc,MAAW;AACvD,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,SAAS,SAAS,OAAO,IAAI;AAAA,EAC1D;AAAA,EAEA,eAAe;AACb,WAAO,GAAG,KAAK,OAAO,SAAS,IAAI,KAAK,QAAQ;AAAA,EAClD;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAO,uBAAQ;","names":["axios"]}
1
+ {"version":3,"sources":["../../src/sdk/index.ts","../../src/sdk/alquimia-sdk.ts"],"sourcesContent":["export { default as AlquimiaSDK } from './alquimia-sdk';","import axios, { AxiosInstance } from \"axios\";\nimport {\n StableDiffusionProvider,\n WhisperProvider,\n CharacterizationProvider,\n RatingsProvider,\n LoggerProvider,\n} from \"../providers\";\nimport { TTSResult } from \"../types\";\ninterface AlquimiaSDKConfig {\n apiKey: string;\n chatUrl: string;\n streamUrl: string;\n assistantId: string;\n}\n\n\nclass AlquimiaSDK {\n private config: AlquimiaSDKConfig;\n private axiosInstance: AxiosInstance;\n private conversationId: string | null = null;\n private sessionId: string | null = null;\n private streamId: string | null = null;\n private evaluationStrategy: string | null = null;\n private tools: any = {};\n private extraData: any = {};\n private assistantConfig: any = {};\n private forceProfile: any = {};\n private userId: string | null = null;\n private whisperProvider?: WhisperProvider\n private stableDiffusionProvider?: StableDiffusionProvider\n private analyzeCharacterizationProvider?: CharacterizationProvider\n private ratingsProvider?: RatingsProvider\n private loggerProvider?: LoggerProvider\n private enforceCharacterization?: boolean\n \n constructor(config: AlquimiaSDKConfig, enforceCharacterization: boolean = true) {\n this.config = config;\n this.enforceCharacterization = enforceCharacterization;\n\n this.axiosInstance = axios.create();\n this.axiosInstance.interceptors.response.use(\n (response) => response,\n async (error) => {\n if (error.response?.status) {\n if (this.loggerProvider) {\n await this.loggerProvider.logError(\n 'Server Error',\n error,\n {\n url: error.config.url,\n method: error.config.method,\n data: error.config.data,\n status: error.response.status,\n responseData: error.response.data\n }\n );\n }\n }\n return Promise.reject(error);\n }\n );\n \n this.textToSpeech = this.textToSpeech.bind(this);\n this.speechToText = this.speechToText.bind(this);\n }\n\n static configure(\n apiKey: string,\n inferUrl: string,\n streamUrl: string,\n assistantId: string\n ): AlquimiaSDKConfig {\n return {\n apiKey,\n chatUrl: `${inferUrl}/chat/${assistantId}`,\n streamUrl: `${streamUrl}`,\n assistantId: assistantId\n };\n }\n\n widthConversationId(conversationId: string ): AlquimiaSDK {\n this.conversationId = conversationId \n return this;\n }\n\n withWhisperProvider(provider: WhisperProvider): AlquimiaSDK {\n this.whisperProvider = provider;\n return this;\n }\n\n withStableDiffusionProvider(provider: StableDiffusionProvider): AlquimiaSDK {\n this.stableDiffusionProvider = provider\n return this\n }\n\n withAnalyzeCharacterizationProvider(provider: CharacterizationProvider): AlquimiaSDK {\n this.analyzeCharacterizationProvider = provider\n return this\n }\n\n withRatingsProvider(provider: RatingsProvider): AlquimiaSDK {\n this.ratingsProvider = provider\n return this\n }\n\n withLoggerProvider(provider: LoggerProvider): AlquimiaSDK {\n this.loggerProvider = provider\n return this\n }\n\n getEnforceCharacterization(): boolean {\n return this.enforceCharacterization ?? true;\n }\n\n getEvaluationStrategy(): string | null {\n return this.evaluationStrategy;\n }\n\n withTools(tools: any): AlquimiaSDK {\n this.tools = tools;\n return this;\n }\n\n withExtraData(extraData: any): AlquimiaSDK {\n this.extraData = extraData;\n return this;\n }\n\n withForceProfile(forceProfile: any): AlquimiaSDK {\n this.forceProfile = forceProfile;\n return this;\n }\n\n withAssistantConfig(assistantConfig: any): AlquimiaSDK {\n this.assistantConfig = assistantConfig;\n return this;\n }\n\n withUserId(userId: string): AlquimiaSDK {\n this.userId = userId;\n return this;\n }\n\n textToSpeech(text: string): Promise<TTSResult> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.textToSpeech(text)\n }\n\n speechToText(audio: string): Promise<string> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.speechToText(audio)\n }\n\n async sendMessage(query: string, traceParent?: string) {\n if (!this.conversationId) {\n throw new Error(\"Conversation not initialized\");\n }\n\n const initMessage = {\n query,\n session_id: this.conversationId,\n extra_data: this.extraData,\n force_profile: this.forceProfile,\n config: this.assistantConfig,\n tools: this.tools,\n user_id: this.userId\n };\n \n const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-trace-parent\": traceParent || \"\",\n },\n })).data\n \n this.evaluationStrategy = result.config.dante.profile.evaluation_strategy.evaluation_strategy_id;\n this.streamId = result.stream_id;\n\n return this\n }\n\n async generateImage(query: string) {\n if (!this.stableDiffusionProvider) {\n throw new Error(\"Stable Diffusion provider not initialized\");\n }\n return this.stableDiffusionProvider.generateImage(query)\n }\n\n async analyzeCharacterization(text: string) {\n if (!this.analyzeCharacterizationProvider) {\n throw new Error(\"analyze characterization provider not initialized\");\n }\n return this.analyzeCharacterizationProvider.analyzeCharacterization(text)\n }\n\n async rate(data: any) {\n if (!this.ratingsProvider) {\n throw new Error(\"ratings provider not initialized\");\n }\n return this.ratingsProvider.rate(data)\n }\n\n async logInfo(message: string, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logInfo(message, data)\n }\n\n async logError(message: string, error: Error, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logError(message, error, data)\n }\n\n getUrlStream() {\n return `${this.config.streamUrl}/${this.streamId}`;\n }\n\n getStreamId() {\n return this.streamId;\n }\n}\n\nexport default AlquimiaSDK;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAqC;AAiBrC,IAAM,cAAN,MAAkB;AAAA,EAmBhB,YAAY,QAA2B,0BAAmC,MAAM;AAhBhF,SAAQ,iBAAgC;AACxC,SAAQ,YAA2B;AACnC,SAAQ,WAA0B;AAClC,SAAQ,qBAAoC;AAC5C,SAAQ,QAAa,CAAC;AACtB,SAAQ,YAAiB,CAAC;AAC1B,SAAQ,kBAAuB,CAAC;AAChC,SAAQ,eAAoB,CAAC;AAC7B,SAAQ,SAAwB;AAS9B,SAAK,SAAS;AACd,SAAK,0BAA0B;AAE/B,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAClC,SAAK,cAAc,aAAa,SAAS;AAAA,MACvC,CAAC,aAAa;AAAA,MACd,OAAO,UAAU;AACf,YAAI,MAAM,UAAU,QAAQ;AAC1B,cAAI,KAAK,gBAAgB;AACvB,kBAAM,KAAK,eAAe;AAAA,cACxB;AAAA,cACA;AAAA,cACA;AAAA,gBACE,KAAK,MAAM,OAAO;AAAA,gBAClB,QAAQ,MAAM,O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AI,MAAM,mDAAmD;AAAA,IACrE;AACA,WAAO,KAAK,gCAAgC,wBAAwB,IAAI;AAAA,EAC1E;AAAA,EAEA,MAAM,KAAK,MAAW;AACpB,QAAI,CAAC,KAAK,iBAAiB;AACzB,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AACA,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACvC;AAAA,EAEA,MAAM,QAAQ,SAAiB,MAAW;AACxC,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,QAAQ,SAAS,IAAI;AAAA,EAClD;AAAA,EAEA,MAAM,SAAS,SAAiB,OAAc,MAAW;AACvD,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,SAAS,SAAS,OAAO,IAAI;AAAA,EAC1D;AAAA,EAEA,eAAe;AACb,WAAO,GAAG,KAAK,OAAO,SAAS,IAAI,KAAK,QAAQ;AAAA,EAClD;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAO,uBAAQ;","names":["axios"]}
@@ -8,6 +8,7 @@ var AlquimiaSDK = class {
8
8
  this.evaluationStrategy = null;
9
9
  this.tools = {};
10
10
  this.extraData = {};
11
+ this.assistantConfig = {};
11
12
  this.forceProfile = {};
12
13
  this.userId = null;
13
14
  this.config = config;
@@ -87,6 +88,10 @@ var AlquimiaSDK = class {
87
88
  this.forceProfile = forceProfile;
88
89
  return this;
89
90
  }
91
+ withAssistantConfig(assistantConfig) {
92
+ this.assistantConfig = assistantConfig;
93
+ return this;
94
+ }
90
95
  withUserId(userId) {
91
96
  this.userId = userId;
92
97
  return this;
@@ -112,6 +117,8 @@ var AlquimiaSDK = class {
112
117
  session_id: this.conversationId,
113
118
  extra_data: this.extraData,
114
119
  force_profile: this.forceProfile,
120
+ config: this.assistantConfig,
121
+ tools: this.tools,
115
122
  user_id: this.userId
116
123
  };
117
124
  const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/sdk/alquimia-sdk.ts"],"sourcesContent":["import axios, { AxiosInstance } from \"axios\";\nimport {\n StableDiffusionProvider,\n WhisperProvider,\n CharacterizationProvider,\n RatingsProvider,\n LoggerProvider,\n} from \"../providers\";\nimport { TTSResult } from \"../types\";\ninterface AlquimiaSDKConfig {\n apiKey: string;\n chatUrl: string;\n streamUrl: string;\n assistantId: string;\n}\n\n\nclass AlquimiaSDK {\n private config: AlquimiaSDKConfig;\n private axiosInstance: AxiosInstance;\n private conversationId: string | null = null;\n private sessionId: string | null = null;\n private streamId: string | null = null;\n private evaluationStrategy: string | null = null;\n private tools: any = {};\n private extraData: any = {};\n private forceProfile: any = {};\n private userId: string | null = null;\n private whisperProvider?: WhisperProvider\n private stableDiffusionProvider?: StableDiffusionProvider\n private analyzeCharacterizationProvider?: CharacterizationProvider\n private ratingsProvider?: RatingsProvider\n private loggerProvider?: LoggerProvider\n private enforceCharacterization?: boolean\n \n constructor(config: AlquimiaSDKConfig, enforceCharacterization: boolean = true) {\n this.config = config;\n this.enforceCharacterization = enforceCharacterization;\n\n this.axiosInstance = axios.create();\n this.axiosInstance.interceptors.response.use(\n (response) => response,\n async (error) => {\n if (error.response?.status) {\n if (this.loggerProvider) {\n await this.loggerProvider.logError(\n 'Server Error',\n error,\n {\n url: error.config.url,\n method: error.config.method,\n data: error.config.data,\n status: error.response.status,\n responseData: error.response.data\n }\n );\n }\n }\n return Promise.reject(error);\n }\n );\n \n this.textToSpeech = this.textToSpeech.bind(this);\n this.speechToText = this.speechToText.bind(this);\n }\n\n static configure(\n apiKey: string,\n inferUrl: string,\n streamUrl: string,\n assistantId: string\n ): AlquimiaSDKConfig {\n return {\n apiKey,\n chatUrl: `${inferUrl}/chat/${assistantId}`,\n streamUrl: `${streamUrl}`,\n assistantId: assistantId\n };\n }\n\n widthConversationId(conversationId: string ): AlquimiaSDK {\n this.conversationId = conversationId \n return this;\n }\n\n withWhisperProvider(provider: WhisperProvider): AlquimiaSDK {\n this.whisperProvider = provider;\n return this;\n }\n\n withStableDiffusionProvider(provider: StableDiffusionProvider): AlquimiaSDK {\n this.stableDiffusionProvider = provider\n return this\n }\n\n withAnalyzeCharacterizationProvider(provider: CharacterizationProvider): AlquimiaSDK {\n this.analyzeCharacterizationProvider = provider\n return this\n }\n\n withRatingsProvider(provider: RatingsProvider): AlquimiaSDK {\n this.ratingsProvider = provider\n return this\n }\n\n withLoggerProvider(provider: LoggerProvider): AlquimiaSDK {\n this.loggerProvider = provider\n return this\n }\n\n getEnforceCharacterization(): boolean {\n return this.enforceCharacterization ?? true;\n }\n\n getEvaluationStrategy(): string | null {\n return this.evaluationStrategy;\n }\n\n withTools(tools: any): AlquimiaSDK {\n this.tools = tools;\n return this;\n }\n\n withExtraData(extraData: any): AlquimiaSDK {\n this.extraData = extraData;\n return this;\n }\n\n withForceProfile(forceProfile: any): AlquimiaSDK {\n this.forceProfile = forceProfile;\n return this;\n }\n\n withUserId(userId: string): AlquimiaSDK {\n this.userId = userId;\n return this;\n }\n\n textToSpeech(text: string): Promise<TTSResult> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.textToSpeech(text)\n }\n\n speechToText(audio: string): Promise<string> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.speechToText(audio)\n }\n\n async sendMessage(query: string, traceParent?: string) {\n if (!this.conversationId) {\n throw new Error(\"Conversation not initialized\");\n }\n\n const initMessage = {\n query,\n session_id: this.conversationId,\n extra_data: this.extraData,\n force_profile: this.forceProfile,\n user_id: this.userId\n };\n \n const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-trace-parent\": traceParent || \"\",\n },\n })).data\n \n this.evaluationStrategy = result.config.dante.profile.evaluation_strategy.evaluation_strategy_id;\n this.streamId = result.stream_id;\n\n return this\n }\n\n async generateImage(query: string) {\n if (!this.stableDiffusionProvider) {\n throw new Error(\"Stable Diffusion provider not initialized\");\n }\n return this.stableDiffusionProvider.generateImage(query)\n }\n\n async analyzeCharacterization(text: string) {\n if (!this.analyzeCharacterizationProvider) {\n throw new Error(\"analyze characterization provider not initialized\");\n }\n return this.analyzeCharacterizationProvider.analyzeCharacterization(text)\n }\n\n async rate(data: any) {\n if (!this.ratingsProvider) {\n throw new Error(\"ratings provider not initialized\");\n }\n return this.ratingsProvider.rate(data)\n }\n\n async logInfo(message: string, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logInfo(message, data)\n }\n\n async logError(message: string, error: Error, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logError(message, error, data)\n }\n\n getUrlStream() {\n return `${this.config.streamUrl}/${this.streamId}`;\n }\n\n getStreamId() {\n return this.streamId;\n }\n}\n\nexport default AlquimiaSDK;\n"],"mappings":";AAAA,OAAO,WAA8B;AAiBrC,IAAM,cAAN,MAAkB;AAAA,EAkBhB,YAAY,QAA2B,0BAAmC,MAAM;AAfhF,SAAQ,iBAAgC;AACxC,SAAQ,YAA2B;AACnC,SAAQ,WAA0B;AAClC,SAAQ,qBAAoC;AAC5C,SAAQ,QAAa,CAAC;AACtB,SAAQ,YAAiB,CAAC;AAC1B,SAAQ,eAAoB,CAAC;AAC7B,SAAQ,SAAwB;AAS9B,SAAK,SAAS;AACd,SAAK,0BAA0B;AAE/B,SAAK,gBAAgB,MAAM,OAAO;AAClC,SAAK,cAAc,aAAa,SAAS;AAAA,MACvC,CAAC,aAAa;AAAA,MACd,OAAO,UAAU;AACf,YAAI,MAAM,UAAU,QAAQ;AAC1B,cAAI,KAAK,gBAAgB;AACvB,kBAAM,KAAK,eAAe;AAAA,cACxB;AAAA,cACA;AAAA,cACA;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,IAAI;AAAA,EAC1E;AAAA,EAEA,MAAM,KAAK,MAAW;AACpB,QAAI,CAAC,KAAK,iBAAiB;AACzB,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AACA,WAAO,KAAK,gBAAgB,KAAK,IAAI;AAAA,EACvC;AAAA,EAEA,MAAM,QAAQ,SAAiB,MAAW;AACxC,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,QAAQ,SAAS,IAAI;AAAA,EAClD;AAAA,EAEA,MAAM,SAAS,SAAiB,OAAc,MAAW;AACvD,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,SAAS,SAAS,OAAO,IAAI;AAAA,EAC1D;AAAA,EAEA,eAAe;AACb,WAAO,GAAG,KAAK,OAAO,SAAS,IAAI,KAAK,QAAQ;AAAA,EAClD;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAO,uBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../src/sdk/alquimia-sdk.ts"],"sourcesContent":["import axios, { AxiosInstance } from \"axios\";\nimport {\n StableDiffusionProvider,\n WhisperProvider,\n CharacterizationProvider,\n RatingsProvider,\n LoggerProvider,\n} from \"../providers\";\nimport { TTSResult } from \"../types\";\ninterface AlquimiaSDKConfig {\n apiKey: string;\n chatUrl: string;\n streamUrl: string;\n assistantId: string;\n}\n\n\nclass AlquimiaSDK {\n private config: AlquimiaSDKConfig;\n private axiosInstance: AxiosInstance;\n private conversationId: string | null = null;\n private sessionId: string | null = null;\n private streamId: string | null = null;\n private evaluationStrategy: string | null = null;\n private tools: any = {};\n private extraData: any = {};\n private assistantConfig: any = {};\n private forceProfile: any = {};\n private userId: string | null = null;\n private whisperProvider?: WhisperProvider\n private stableDiffusionProvider?: StableDiffusionProvider\n private analyzeCharacterizationProvider?: CharacterizationProvider\n private ratingsProvider?: RatingsProvider\n private loggerProvider?: LoggerProvider\n private enforceCharacterization?: boolean\n \n constructor(config: AlquimiaSDKConfig, enforceCharacterization: boolean = true) {\n this.config = config;\n this.enforceCharacterization = enforceCharacterization;\n\n this.axiosInstance = axios.create();\n this.axiosInstance.interceptors.response.use(\n (response) => response,\n async (error) => {\n if (error.response?.status) {\n if (this.loggerProvider) {\n await this.loggerProvider.logError(\n 'Server Error',\n error,\n {\n url: error.config.url,\n method: error.config.method,\n data: error.config.data,\n status: error.response.status,\n responseData: error.response.data\n }\n );\n }\n }\n return Promise.reject(error);\n }\n );\n \n this.textToSpeech = this.textToSpeech.bind(this);\n this.speechToText = this.speechToText.bind(this);\n }\n\n static configure(\n apiKey: string,\n inferUrl: string,\n streamUrl: string,\n assistantId: string\n ): AlquimiaSDKConfig {\n return {\n apiKey,\n chatUrl: `${inferUrl}/chat/${assistantId}`,\n streamUrl: `${streamUrl}`,\n assistantId: assistantId\n };\n }\n\n widthConversationId(conversationId: string ): AlquimiaSDK {\n this.conversationId = conversationId \n return this;\n }\n\n withWhisperProvider(provider: WhisperProvider): AlquimiaSDK {\n this.whisperProvider = provider;\n return this;\n }\n\n withStableDiffusionProvider(provider: StableDiffusionProvider): AlquimiaSDK {\n this.stableDiffusionProvider = provider\n return this\n }\n\n withAnalyzeCharacterizationProvider(provider: CharacterizationProvider): AlquimiaSDK {\n this.analyzeCharacterizationProvider = provider\n return this\n }\n\n withRatingsProvider(provider: RatingsProvider): AlquimiaSDK {\n this.ratingsProvider = provider\n return this\n }\n\n withLoggerProvider(provider: LoggerProvider): AlquimiaSDK {\n this.loggerProvider = provider\n return this\n }\n\n getEnforceCharacterization(): boolean {\n return this.enforceCharacterization ?? true;\n }\n\n getEvaluationStrategy(): string | null {\n return this.evaluationStrategy;\n }\n\n withTools(tools: any): AlquimiaSDK {\n this.tools = tools;\n return this;\n }\n\n withExtraData(extraData: any): AlquimiaSDK {\n this.extraData = extraData;\n return this;\n }\n\n withForceProfile(forceProfile: any): AlquimiaSDK {\n this.forceProfile = forceProfile;\n return this;\n }\n\n withAssistantConfig(assistantConfig: any): AlquimiaSDK {\n this.assistantConfig = assistantConfig;\n return this;\n }\n\n withUserId(userId: string): AlquimiaSDK {\n this.userId = userId;\n return this;\n }\n\n textToSpeech(text: string): Promise<TTSResult> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.textToSpeech(text)\n }\n\n speechToText(audio: string): Promise<string> {\n if (!this.whisperProvider) {\n throw new Error(\"Whisper provider not initialized\");\n }\n return this.whisperProvider.speechToText(audio)\n }\n\n async sendMessage(query: string, traceParent?: string) {\n if (!this.conversationId) {\n throw new Error(\"Conversation not initialized\");\n }\n\n const initMessage = {\n query,\n session_id: this.conversationId,\n extra_data: this.extraData,\n force_profile: this.forceProfile,\n config: this.assistantConfig,\n tools: this.tools,\n user_id: this.userId\n };\n \n const result = (await this.axiosInstance.post(this.config.chatUrl, initMessage, {\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-trace-parent\": traceParent || \"\",\n },\n })).data\n \n this.evaluationStrategy = result.config.dante.profile.evaluation_strategy.evaluation_strategy_id;\n this.streamId = result.stream_id;\n\n return this\n }\n\n async generateImage(query: string) {\n if (!this.stableDiffusionProvider) {\n throw new Error(\"Stable Diffusion provider not initialized\");\n }\n return this.stableDiffusionProvider.generateImage(query)\n }\n\n async analyzeCharacterization(text: string) {\n if (!this.analyzeCharacterizationProvider) {\n throw new Error(\"analyze characterization provider not initialized\");\n }\n return this.analyzeCharacterizationProvider.analyzeCharacterization(text)\n }\n\n async rate(data: any) {\n if (!this.ratingsProvider) {\n throw new Error(\"ratings provider not initialized\");\n }\n return this.ratingsProvider.rate(data)\n }\n\n async logInfo(message: string, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logInfo(message, data)\n }\n\n async logError(message: string, error: Error, data: any) {\n if (!this.loggerProvider) {\n throw new Error(\"logger provider not initialized\");\n }\n return this.loggerProvider.logError(message, error, data)\n }\n\n getUrlStream() {\n return `${this.config.streamUrl}/${this.streamId}`;\n }\n\n getStreamId() {\n return this.streamId;\n }\n}\n\nexport default AlquimiaSDK;\n"],"mappings":";AAAA,OAAO,WAA8B;AAiBrC,IAAM,cAAN,MAAkB;AAAA,EAmBhB,YAAY,QAA2B,0BAAmC,MAAM;AAhBhF,SAAQ,iBAAgC;AACxC,SAAQ,YAA2B;AACnC,SAAQ,WAA0B;AAClC,SAAQ,qBAAoC;AAC5C,SAAQ,QAAa,CAAC;AACtB,SAAQ,YAAiB,CAAC;AAC1B,SAAQ,kBAAuB,CAAC;AAChC,SAAQ,eAAoB,CAAC;AAC7B,SAAQ,SAAwB;AAS9B,SAAK,SAAS;AACd,SAAK,0BAA0B;AAE/B,SAAK,gBAAgB,MAAM,OAAO;AAClC,SAAK,cAAc,aAAa,SAAS;AAAA,MACvC,CAAC,aAAa;AAAA,MACd,OAAO,UAAU;AACf,YAAI,MAAM,UAAU,QAAQ;AAC1B,cAAI,KAAK,gBAAgB;AACvB,kBAAM,KAAK,eAAe;AAAA,cACxB;AAAA,cACA;AAAA,cACA;AAAA,gBACE,KAAK,MAAM,OAAO;AAAA,gBAClB,QAAQ,MAAM,OAAO;AAAA,gBACrB,MAAM,MAAM,OAAO;AAAA,gBACnB,QAAQ,MAAM,SAAS;AAAA,gBACvB,cAAc,MAAM,SAAS;AAAA,cAC/B;AAAA,YACF;AAAA,UACF;AAAA,QACF;AACA,eAAO,QAAQ,OAAO,KAAK;AAAA,MAC7B;AAAA,IACF;AAEA,SAAK,eAAe,KAAK,aAAa,KAAK,IAAI;AAC/C,SAAK,eAAe,KAAK,aAAa,KAAK,IAAI;AAAA,EACjD;AAAA,EAEA,OAAO,UACL,QACA,UACA,WACA,aACmB;AACnB,WAAO;AAAA,MACL;AAAA,MACA,SAAS,GAAG,QAAQ,SAAS,WAAW;AAAA,MACxC,WAAW,GAAG,SAAS;AA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B,OAAc,MAAW;AACvD,QAAI,CAAC,KAAK,gBAAgB;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,WAAO,KAAK,eAAe,SAAS,SAAS,OAAO,IAAI;AAAA,EAC1D;AAAA,EAEA,eAAe;AACb,WAAO,GAAG,KAAK,OAAO,SAAS,IAAI,KAAK,QAAQ;AAAA,EAClD;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAO,uBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alquimia-ai/tools",
3
- "version": "1.11.0",
3
+ "version": "1.11.2",
4
4
  "author": "Alquimia AI",
5
5
  "description": "tools for Alquimia SDK",
6
6
  "private": false,