@mate-academy/llm-gateway 7.0.0 → 7.0.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.
@@ -376,6 +376,17 @@ export type LLMAssistanceOptions<Provider extends LLMProviders, Reporter extends
376
376
  export type LLMAssistanceResult = LLMRequestResult<{
377
377
  text: string;
378
378
  }>;
379
+ /**
380
+ * Options for a one-shot prompt in a newly created chat.
381
+ * Combines chat creation options with message sending options.
382
+ * @template Provider - The LLM provider type
383
+ * @template Reporter - Reporter interface type
384
+ */
385
+ export type LLMAssistInNewChatOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMCreateChatOptions<Provider, Reporter> & {
386
+ prompt: string;
387
+ tools?: LLMToolDefinition[];
388
+ maxToolIterations?: number;
389
+ };
379
390
  export interface LLMToolDefinition<Schema extends LLMSchemaInterface = LLMSchemaInterface> {
380
391
  name: string;
381
392
  description: string;
@@ -1,4 +1,4 @@
1
- import { type LLMAssistanceOptions, type LLMAssistanceResult, type LLMAssistanceMessage, type LLMToolDefinition, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, type LLMProviders, LLMPurposes, type LLMUploadFileOptions, type LLMUploadFileResult, type LLMStructuredResult, type LLMUploadedFile } from '../LLMService.typedefs';
1
+ import { type LLMAssistInNewChatOptions, type LLMAssistanceOptions, type LLMAssistanceResult, type LLMAssistanceMessage, type LLMToolDefinition, type LLMCreateChatOptions, type LLMCreateChatResult, type LLMCreateFileStorageOptions, type LLMCreateFileStorageResult, type LLMInstanceOptions, type LLMModel, type LLMProviders, LLMPurposes, type LLMUploadFileOptions, type LLMUploadFileResult, type LLMStructuredResult, type LLMUploadedFile } from '../LLMService.typedefs';
2
2
  import { type LLMLoggerInterface } from '../utilities/logger';
3
3
  import { type LLMReporterInterface } from '../utilities/reporter';
4
4
  import { LLMBaseService } from '../services';
@@ -21,5 +21,9 @@ export declare abstract class LLMAssistanceService<Provider extends LLMProviders
21
21
  protected abstract assistInChatStructured(options: LLMAssistanceOptions<Provider, Reporter> & {
22
22
  schema: LLMSchemaInterface;
23
23
  }): Promise<LLMStructuredResult>;
24
+ assistInNewChat<Schema extends LLMSchemaInterface>(options: LLMAssistInNewChatOptions<Provider, Reporter> & {
25
+ schema: Schema;
26
+ }): Promise<LLMStructuredResult<InferSchema<Schema>>>;
27
+ assistInNewChat(options: LLMAssistInNewChatOptions<Provider, Reporter>): Promise<LLMAssistanceResult>;
24
28
  abstract countTokens(messages: LLMAssistanceMessage[], model: LLMModel<Provider>): Promise<number>;
25
29
  }
@@ -27,6 +27,25 @@ class LLMAssistanceService extends services_1.LLMBaseService {
27
27
  }
28
28
  return this.assistInChatText(options);
29
29
  }
30
+ async assistInNewChat(options) {
31
+ const chatResult = await this.createChat(options);
32
+ if ('error' in chatResult) {
33
+ return chatResult;
34
+ }
35
+ const message = {
36
+ role: LLMService_typedefs_1.LLMRoles.User,
37
+ content: [{
38
+ type: LLMService_typedefs_1.LLMMessageContentType.TEXT,
39
+ text: options.prompt,
40
+ }],
41
+ };
42
+ // @ts-expect-error conditional Reporter type prevents direct assignment
43
+ return this.assistInChat({
44
+ ...options,
45
+ chatId: chatResult.chatId,
46
+ message,
47
+ });
48
+ }
30
49
  }
31
50
  exports.LLMAssistanceService = LLMAssistanceService;
32
51
  //# sourceMappingURL=LLMAssistanceService.abstract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LLMAssistanceService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMAssistanceService.abstract.ts"],"names":[],"mappings":";;;AAAA,+DAiB+B;AAG/B,yCAA4C;AAG5C,MAAsB,oBAGpB,SAAQ,yBAIP;IACD,YACE,QAAkB,EAClB,MAAsC,EACtC,QAAkB,EAClB,OAAsC;QAEtC,KAAK,CACH,QAAQ,EACR,mBAAmB,EACnB,iCAAW,CAAC,UAAU,EACtB,MAAM,EACN,QAAQ,EACR,OAAO,CACR,CAAC;IACJ,CAAC;IAES,uBAAuB,CAC/B,KAA0B;QAE1B,MAAM,WAAW,GAAG,kBAAkB,CAAC;QACvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;QAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,IAAI,IAAI;sBACjC,4BAA4B,CAC/B,CAAC;YACJ,CAAC;YAED,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CACb,wBAAwB,IAAI,CAAC,IAAI,GAAG,CACrC,CAAC;YACJ,CAAC;YAED,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAuCD,YAAY,CACV,OACmC;QAEnC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,sBAAsB,CAChC,OACkC,CACnC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CAeF;AAhHD,oDAgHC"}
1
+ {"version":3,"file":"LLMAssistanceService.abstract.js","sourceRoot":"","sources":["../../src/services/LLMAssistanceService.abstract.ts"],"names":[],"mappings":";;;AAAA,+DAoB+B;AAG/B,yCAA4C;AAG5C,MAAsB,oBAGpB,SAAQ,yBAIP;IACD,YACE,QAAkB,EAClB,MAAsC,EACtC,QAAkB,EAClB,OAAsC;QAEtC,KAAK,CACH,QAAQ,EACR,mBAAmB,EACnB,iCAAW,CAAC,UAAU,EACtB,MAAM,EACN,QAAQ,EACR,OAAO,CACR,CAAC;IACJ,CAAC;IAES,uBAAuB,CAC/B,KAA0B;QAE1B,MAAM,WAA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AAO;SACR,CAAC,CAAC;IACL,CAAC;CAMF;AAnJD,oDAmJC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mate-academy/llm-gateway",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "A gateway package for LLM services.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",