listpage-next-nest 0.0.152 → 0.0.163
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/dist/cjs/index.cjs +36 -11
- package/dist/cjs/index.d.ts +12 -6
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -38,7 +38,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
38
38
|
BaseQueryDto: ()=>BaseQueryDto,
|
|
39
39
|
ApiResponse: ()=>ApiResponse,
|
|
40
40
|
HttpExceptionFilter: ()=>HttpExceptionFilter,
|
|
41
|
-
SupportProvider: ()=>types_SupportProvider,
|
|
42
41
|
User: ()=>User,
|
|
43
42
|
Public: ()=>Public,
|
|
44
43
|
PaginatedResponse: ()=>PaginatedResponse,
|
|
@@ -517,7 +516,7 @@ StaticRouteModule = static_route_module_ts_decorate([
|
|
|
517
516
|
(0, common_namespaceObject.Module)({})
|
|
518
517
|
], StaticRouteModule);
|
|
519
518
|
const external_rxjs_namespaceObject = require("rxjs");
|
|
520
|
-
class
|
|
519
|
+
class LLMProvider {
|
|
521
520
|
async call(options) {
|
|
522
521
|
const response = await this.request({
|
|
523
522
|
...options,
|
|
@@ -544,6 +543,13 @@ class BaseProvider {
|
|
|
544
543
|
this.handleStream(subject, stream);
|
|
545
544
|
return subject;
|
|
546
545
|
}
|
|
546
|
+
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
|
+
}
|
|
547
553
|
constructor(){
|
|
548
554
|
this.baseURL = '';
|
|
549
555
|
}
|
|
@@ -556,7 +562,7 @@ const parseJson = (json)=>{
|
|
|
556
562
|
return;
|
|
557
563
|
}
|
|
558
564
|
};
|
|
559
|
-
class VolcengineProvider extends
|
|
565
|
+
class VolcengineProvider extends LLMProvider {
|
|
560
566
|
handleJson(json) {
|
|
561
567
|
const content = json.choices[0].message.content || '';
|
|
562
568
|
const reasoning_content = json.choices[0].message.reasoning_content || void 0;
|
|
@@ -649,7 +655,7 @@ class VolcengineProvider extends BaseProvider {
|
|
|
649
655
|
super(...args), this.baseURL = 'https://ark.cn-beijing.volces.com/api/v3/chat/completions ';
|
|
650
656
|
}
|
|
651
657
|
}
|
|
652
|
-
class MetaProvider extends
|
|
658
|
+
class MetaProvider extends LLMProvider {
|
|
653
659
|
handleJson(json) {
|
|
654
660
|
const message = json.choices[0].message;
|
|
655
661
|
return {
|
|
@@ -760,6 +766,12 @@ class MetaProvider extends BaseProvider {
|
|
|
760
766
|
super(...args), this.baseURL = 'https://metaso.cn/api/v1/chat/completions';
|
|
761
767
|
}
|
|
762
768
|
}
|
|
769
|
+
function compilePrompt(prompt, params) {
|
|
770
|
+
const compiled = (0, external_lodash_namespaceObject.template)(prompt, {
|
|
771
|
+
interpolate: /{{([\s\S]+?)}}/g
|
|
772
|
+
});
|
|
773
|
+
return compiled(params);
|
|
774
|
+
}
|
|
763
775
|
function llm_provider_service_ts_decorate(decorators, target, key, desc) {
|
|
764
776
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
765
777
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -779,6 +791,26 @@ class LLMProviderService {
|
|
|
779
791
|
}
|
|
780
792
|
throw new common_namespaceObject.BadRequestException('不支持该大模型提供商');
|
|
781
793
|
}
|
|
794
|
+
async run(options) {
|
|
795
|
+
const { system, user, data = {}, provider, params } = options;
|
|
796
|
+
const messages = [
|
|
797
|
+
{
|
|
798
|
+
role: 'system',
|
|
799
|
+
content: compilePrompt(system, data)
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
role: 'user',
|
|
803
|
+
content: user
|
|
804
|
+
}
|
|
805
|
+
];
|
|
806
|
+
return this.call({
|
|
807
|
+
provider,
|
|
808
|
+
params: {
|
|
809
|
+
...params,
|
|
810
|
+
messages
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
}
|
|
782
814
|
async sse(options, callback) {
|
|
783
815
|
const { provider, params } = options;
|
|
784
816
|
const ProviderConstructors = {
|
|
@@ -821,11 +853,6 @@ LLMProviderModule = llm_provider_module_ts_decorate([
|
|
|
821
853
|
]
|
|
822
854
|
})
|
|
823
855
|
], LLMProviderModule);
|
|
824
|
-
var types_SupportProvider = /*#__PURE__*/ function(SupportProvider) {
|
|
825
|
-
SupportProvider["volcengine"] = "volcengine";
|
|
826
|
-
SupportProvider["meta"] = "meta";
|
|
827
|
-
return SupportProvider;
|
|
828
|
-
}({});
|
|
829
856
|
var types_ServerSendEventName = /*#__PURE__*/ function(ServerSendEventName) {
|
|
830
857
|
ServerSendEventName["Received"] = "received";
|
|
831
858
|
ServerSendEventName["Thinking"] = "thinking";
|
|
@@ -854,7 +881,6 @@ exports.ServerSendEventName = __webpack_exports__.ServerSendEventName;
|
|
|
854
881
|
exports.StaticRouteMiddleware = __webpack_exports__.StaticRouteMiddleware;
|
|
855
882
|
exports.StaticRouteMiddlewareFactory = __webpack_exports__.StaticRouteMiddlewareFactory;
|
|
856
883
|
exports.StaticRouteModule = __webpack_exports__.StaticRouteModule;
|
|
857
|
-
exports.SupportProvider = __webpack_exports__.SupportProvider;
|
|
858
884
|
exports.User = __webpack_exports__.User;
|
|
859
885
|
exports.setup = __webpack_exports__.setup;
|
|
860
886
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -877,7 +903,6 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
877
903
|
"StaticRouteMiddleware",
|
|
878
904
|
"StaticRouteMiddlewareFactory",
|
|
879
905
|
"StaticRouteModule",
|
|
880
|
-
"SupportProvider",
|
|
881
906
|
"User",
|
|
882
907
|
"setup"
|
|
883
908
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -78,8 +78,17 @@ export declare type LLMProviderCallOptions = {
|
|
|
78
78
|
export declare class LLMProviderModule {
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
export declare type LLMProviderRunOptions = {
|
|
82
|
+
system: string;
|
|
83
|
+
user: string;
|
|
84
|
+
data?: any;
|
|
85
|
+
provider: SupportProvider;
|
|
86
|
+
params: Omit<ProviderParams[LLMProviderRunOptions['provider']], 'messages'>;
|
|
87
|
+
};
|
|
88
|
+
|
|
81
89
|
export declare class LLMProviderService {
|
|
82
90
|
call(options: LLMProviderCallOptions): Promise<ServerSendJsonData>;
|
|
91
|
+
run(options: LLMProviderRunOptions): Promise<ServerSendJsonData>;
|
|
83
92
|
sse(options: LLMProviderCallOptions, callback?: ServerSendEventCallback): Promise<ReplaySubject<ServerSendEventData>>;
|
|
84
93
|
}
|
|
85
94
|
|
|
@@ -115,8 +124,8 @@ export declare class PaginationData<T> {
|
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
declare type ProviderParams = {
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
volcengine: VolcengineRequestionOption;
|
|
128
|
+
meta: MetaRequestionOption;
|
|
120
129
|
};
|
|
121
130
|
|
|
122
131
|
export declare const Public: () => CustomDecorator<string>;
|
|
@@ -240,10 +249,7 @@ export declare interface StaticRouteOptions {
|
|
|
240
249
|
routeMappings: RouteMapping[];
|
|
241
250
|
}
|
|
242
251
|
|
|
243
|
-
export declare
|
|
244
|
-
volcengine = "volcengine",
|
|
245
|
-
meta = "meta"
|
|
246
|
-
}
|
|
252
|
+
export declare type SupportProvider = 'volcengine' | 'meta';
|
|
247
253
|
|
|
248
254
|
export declare const User: (...dataOrPipes: (string | PipeTransform<any, any> | Type<PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
249
255
|
|