listpage-next-nest 0.0.163 → 0.0.184

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.
@@ -70,6 +70,27 @@ export declare class HttpExceptionFilter implements ExceptionFilter {
70
70
  catch(exception: unknown, host: ArgumentsHost): void;
71
71
  }
72
72
 
73
+ export declare abstract class LLMProvider<RequestionOption extends {
74
+ messages: {
75
+ role: string;
76
+ content: string;
77
+ }[];
78
+ } = any> {
79
+ protected baseURL: string;
80
+ protected apiKey: string;
81
+ protected model: string;
82
+ constructor(options?: {
83
+ api_key?: string;
84
+ model?: string;
85
+ });
86
+ call(options: RequestionOption): Promise<ServerSendJsonData>;
87
+ sse(options: RequestionOption): Promise<ReplaySubject<ServerSendEventData>>;
88
+ protected abstract handleJson(json: any): ServerSendJsonData;
89
+ protected abstract handleStream(subject: ReplaySubject<ServerSendEventData>, stream: ReadableStream<Uint8Array<ArrayBufferLike>>): Promise<void>;
90
+ protected abstract request(options: RequestionOption): Promise<Response>;
91
+ static parseJson<T = any>(json: string): T;
92
+ }
93
+
73
94
  export declare type LLMProviderCallOptions = {
74
95
  provider: SupportProvider;
75
96
  params: ProviderParams[LLMProviderCallOptions['provider']];
@@ -179,11 +200,12 @@ export declare type ServerSendEventCallback<T extends ServerSendEventData['type'
179
200
  }>['data']) => void;
180
201
 
181
202
  export declare type ServerSendEventData = {
182
- type: 'received' | 'thinking' | 'processing' | 'chunk' | 'complete' | 'citations';
203
+ type: 'function_call' | 'received' | 'thinking' | 'processing' | 'chunk' | 'complete' | 'citations';
183
204
  data: SevrverSendEventMessages[ServerSendEventData['type']];
184
205
  };
185
206
 
186
207
  export declare enum ServerSendEventName {
208
+ FunctionCall = "function_call",
187
209
  Received = "received",
188
210
  Thinking = "thinking",
189
211
  Processing = "processing",
@@ -227,6 +249,11 @@ export declare type SevrverSendEventMessages = {
227
249
  [ServerSendEventName.Citations]: {
228
250
  citations: CitationItem[];
229
251
  };
252
+ [ServerSendEventName.FunctionCall]: {
253
+ name: string;
254
+ arguments: any;
255
+ result?: any;
256
+ };
230
257
  };
231
258
 
232
259
  export declare class StaticRouteMiddleware implements NestMiddleware {
@@ -27,8 +27,9 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  LLMProviderModule: ()=>LLMProviderModule,
28
28
  RequestContextMiddleware: ()=>RequestContextMiddleware,
29
29
  AdminAuthGuard: ()=>AdminAuthGuard,
30
- StaticRouteMiddleware: ()=>StaticRouteMiddleware,
30
+ LLMProvider: ()=>LLMProvider,
31
31
  PaginationData: ()=>PaginationData,
32
+ StaticRouteMiddleware: ()=>StaticRouteMiddleware,
32
33
  StaticRouteMiddlewareFactory: ()=>StaticRouteMiddlewareFactory,
33
34
  RequestIdMiddleware: ()=>RequestIdMiddleware,
34
35
  LoggingInterceptor: ()=>LoggingInterceptor,
@@ -403,7 +404,6 @@ query_dto_ts_decorate([
403
404
  (0, external_class_transformer_namespaceObject.Type)(()=>Number),
404
405
  (0, external_class_validator_namespaceObject.IsInt)(),
405
406
  (0, external_class_validator_namespaceObject.Min)(1),
406
- (0, external_class_validator_namespaceObject.Max)(100),
407
407
  _ts_metadata("design:type", Number)
408
408
  ], BaseQueryDto.prototype, "pageSize", void 0);
409
409
  query_dto_ts_decorate([
@@ -517,6 +517,11 @@ StaticRouteModule = static_route_module_ts_decorate([
517
517
  ], StaticRouteModule);
518
518
  const external_rxjs_namespaceObject = require("rxjs");
519
519
  class LLMProvider {
520
+ constructor(options){
521
+ this.baseURL = '';
522
+ this.apiKey = options.api_key;
523
+ this.model = options.model;
524
+ }
520
525
  async call(options) {
521
526
  const response = await this.request({
522
527
  ...options,
@@ -544,14 +549,15 @@ class LLMProvider {
544
549
  return subject;
545
550
  }
546
551
  static parseJson(json) {
547
- json = json.trim();
548
- if (json.startsWith('```json') && json.endsWith('```')) return JSON.parse(json.slice(6, -3));
549
- json = json.match(/```json([\s\S]*?)```/)?.[1] || json;
550
- json = json.trim();
551
- return JSON.parse(json);
552
- }
553
- constructor(){
554
- this.baseURL = '';
552
+ try {
553
+ json = (json || '').trim();
554
+ const match = json.match(/(```json[\s\S]*?```)/);
555
+ json = (match ? match[1] : json).trim();
556
+ if (json.startsWith('```json') && json.endsWith('```')) return JSON.parse(json.slice(6, -3));
557
+ return JSON.parse(json);
558
+ } catch (e) {
559
+ throw new Error('模型输出不是有效 JSON');
560
+ }
555
561
  }
556
562
  }
557
563
  const parseJson = (json)=>{
@@ -634,12 +640,15 @@ class VolcengineProvider extends LLMProvider {
634
640
  subject.complete();
635
641
  }
636
642
  async request(options) {
637
- const { api_key, ...restOptions } = options;
643
+ const { api_key = this.apiKey, model = this.model, ...restOptions } = options;
638
644
  const headers = {
639
645
  'Content-Type': 'application/json',
640
646
  Authorization: `Bearer ${api_key}`
641
647
  };
642
- const body = restOptions;
648
+ const body = {
649
+ ...restOptions,
650
+ model
651
+ };
643
652
  const response = await fetch(this.baseURL, {
644
653
  method: 'POST',
645
654
  headers,
@@ -745,12 +754,15 @@ class MetaProvider extends LLMProvider {
745
754
  subject.complete();
746
755
  }
747
756
  async request(options) {
748
- const { api_key, ...restOptions } = options;
757
+ const { api_key = this.apiKey, model = this.model, ...restOptions } = options;
749
758
  const headers = {
750
759
  'Content-Type': 'application/json',
751
760
  Authorization: `Bearer ${api_key}`
752
761
  };
753
- const body = restOptions;
762
+ const body = {
763
+ ...restOptions,
764
+ model
765
+ };
754
766
  const response = await fetch(this.baseURL, {
755
767
  method: 'POST',
756
768
  headers,
@@ -854,6 +866,7 @@ LLMProviderModule = llm_provider_module_ts_decorate([
854
866
  })
855
867
  ], LLMProviderModule);
856
868
  var types_ServerSendEventName = /*#__PURE__*/ function(ServerSendEventName) {
869
+ ServerSendEventName["FunctionCall"] = "function_call";
857
870
  ServerSendEventName["Received"] = "received";
858
871
  ServerSendEventName["Thinking"] = "thinking";
859
872
  ServerSendEventName["Processing"] = "processing";
@@ -867,6 +880,7 @@ exports.ApiResponse = __webpack_exports__.ApiResponse;
867
880
  exports.BaseQueryDto = __webpack_exports__.BaseQueryDto;
868
881
  exports.CorsInterceptor = __webpack_exports__.CorsInterceptor;
869
882
  exports.HttpExceptionFilter = __webpack_exports__.HttpExceptionFilter;
883
+ exports.LLMProvider = __webpack_exports__.LLMProvider;
870
884
  exports.LLMProviderModule = __webpack_exports__.LLMProviderModule;
871
885
  exports.LLMProviderService = __webpack_exports__.LLMProviderService;
872
886
  exports.LoggingInterceptor = __webpack_exports__.LoggingInterceptor;
@@ -889,6 +903,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
889
903
  "BaseQueryDto",
890
904
  "CorsInterceptor",
891
905
  "HttpExceptionFilter",
906
+ "LLMProvider",
892
907
  "LLMProviderModule",
893
908
  "LLMProviderService",
894
909
  "LoggingInterceptor",
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "listpage-next-nest",
3
- "version": "0.0.163",
3
+ "version": "0.0.184",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "main": "./dist/cjs/index.cjs",
6
6
  "module": "./dist/esm/index.js",
7
- "type": "module",
8
7
  "exports": {
9
8
  ".": {
10
9
  "types": "./dist/cjs/index.d.ts",
@@ -46,6 +45,10 @@
46
45
  "express": "~5.1.0",
47
46
  "uuid": "9.0.1",
48
47
  "lodash": "~4.17.21",
49
- "flexsearch": "~0.8.212"
48
+ "zod": "^3.23.8",
49
+ "@langchain/core": "1.0.5",
50
+ "@langchain/community": "~1.0.3",
51
+ "@langchain/openai": "~1.1.1",
52
+ "@langchain/classic": "~1.0.3"
50
53
  }
51
54
  }