@rimori/client 2.5.12-next.3 → 2.5.12-next.5

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.
@@ -1,5 +1,6 @@
1
1
  import { Tool } from '../../fromRimori/PluginTypes';
2
2
  import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
3
+ import { Language } from '../../controller/SettingsController';
3
4
  export type OnStreamedObjectResult<T = any> = (result: T, isLoading: boolean) => void;
4
5
  type PrimitiveType = 'string' | 'number' | 'boolean';
5
6
  type ObjectToolParameterType = PrimitiveType | {
@@ -91,9 +92,10 @@ export declare class AIModule {
91
92
  /**
92
93
  * Convert voice audio to text using AI.
93
94
  * @param file The audio file to convert.
95
+ * @param language Optional language for the voice.
94
96
  * @returns The transcribed text.
95
97
  */
96
- getTextFromVoice(file: Blob): Promise<string>;
98
+ getTextFromVoice(file: Blob, language?: Language): Promise<string>;
97
99
  private getChatMessage;
98
100
  /**
99
101
  * Generate a structured object from a request using AI.
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { getSTTResponse, getTTSResponse } from '../../controller/VoiceController';
11
10
  /**
12
11
  * Controller for AI-related operations.
13
12
  * Provides access to text generation, voice synthesis, and object generation.
@@ -82,17 +81,39 @@ export class AIModule {
82
81
  */
83
82
  getVoice(text_1) {
84
83
  return __awaiter(this, arguments, void 0, function* (text, voice = 'alloy', speed = 1, language, cache = false) {
85
- return getTTSResponse(this.backendUrl, { input: text, voice, speed, language, cache }, this.token);
84
+ return yield fetch(`${this.backendUrl}/voice/tts`, {
85
+ method: 'POST',
86
+ headers: {
87
+ 'Content-Type': 'application/json',
88
+ Authorization: `Bearer ${this.token}`,
89
+ },
90
+ body: JSON.stringify({ input: text, voice, speed, language, cache }),
91
+ }).then((r) => r.blob());
86
92
  });
87
93
  }
88
94
  /**
89
95
  * Convert voice audio to text using AI.
90
96
  * @param file The audio file to convert.
97
+ * @param language Optional language for the voice.
91
98
  * @returns The transcribed text.
92
99
  */
93
- getTextFromVoice(file) {
100
+ getTextFromVoice(file, language) {
94
101
  return __awaiter(this, void 0, void 0, function* () {
95
- return getSTTResponse(this.backendUrl, file, this.token);
102
+ const formData = new FormData();
103
+ formData.append('file', file);
104
+ if (language) {
105
+ formData.append('language', language.code);
106
+ }
107
+ return yield fetch(`${this.backendUrl}/voice/stt`, {
108
+ method: 'POST',
109
+ headers: { Authorization: `Bearer ${this.token}` },
110
+ body: formData,
111
+ })
112
+ .then((r) => r.json())
113
+ .then((r) => {
114
+ // console.log("STT response: ", r);
115
+ return r.text;
116
+ });
96
117
  });
97
118
  }
98
119
  getChatMessage(systemPrompt, userPrompt) {
@@ -41,6 +41,11 @@ export declare class PluginModule {
41
41
  * @returns The user info.
42
42
  */
43
43
  getUserInfo(): UserInfo;
44
+ getGuildInfo(): {
45
+ id: string;
46
+ name: string;
47
+ description: string | null;
48
+ };
44
49
  /**
45
50
  * Register a callback to be notified when RimoriInfo is updated.
46
51
  * This is useful for reacting to changes in user info, tokens, or other rimori data.
@@ -53,6 +53,13 @@ export class PluginModule {
53
53
  getUserInfo() {
54
54
  return this.rimoriInfo.profile;
55
55
  }
56
+ getGuildInfo() {
57
+ return {
58
+ id: this.rimoriInfo.guild.id,
59
+ name: this.rimoriInfo.guild.name,
60
+ description: this.rimoriInfo.guild.description,
61
+ };
62
+ }
56
63
  /**
57
64
  * Register a callback to be notified when RimoriInfo is updated.
58
65
  * This is useful for reacting to changes in user info, tokens, or other rimori data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.5.12-next.3",
3
+ "version": "2.5.12-next.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -1,10 +0,0 @@
1
- export declare function getSTTResponse(backendUrl: string, audio: Blob, token: string): Promise<string>;
2
- export declare function getTTSResponse(backendUrl: string, request: TTSRequest, token: string): Promise<Blob>;
3
- interface TTSRequest {
4
- input: string;
5
- voice: string;
6
- speed: number;
7
- language?: string;
8
- cache?: boolean;
9
- }
10
- export {};
@@ -1,37 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export function getSTTResponse(backendUrl, audio, token) {
11
- return __awaiter(this, void 0, void 0, function* () {
12
- const formData = new FormData();
13
- formData.append('file', audio);
14
- return yield fetch(`${backendUrl}/voice/stt`, {
15
- method: 'POST',
16
- headers: { Authorization: `Bearer ${token}` },
17
- body: formData,
18
- })
19
- .then((r) => r.json())
20
- .then((r) => {
21
- // console.log("STT response: ", r);
22
- return r.text;
23
- });
24
- });
25
- }
26
- export function getTTSResponse(backendUrl, request, token) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return yield fetch(`${backendUrl}/voice/tts`, {
29
- method: 'POST',
30
- headers: {
31
- 'Content-Type': 'application/json',
32
- Authorization: `Bearer ${token}`,
33
- },
34
- body: JSON.stringify(request),
35
- }).then((r) => r.blob());
36
- });
37
- }