listpage-next-nest 0.0.151 → 0.0.152
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 +119 -1
- package/dist/cjs/index.d.ts +33 -4
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -649,6 +649,117 @@ class VolcengineProvider extends BaseProvider {
|
|
|
649
649
|
super(...args), this.baseURL = 'https://ark.cn-beijing.volces.com/api/v3/chat/completions ';
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
|
+
class MetaProvider extends BaseProvider {
|
|
653
|
+
handleJson(json) {
|
|
654
|
+
const message = json.choices[0].message;
|
|
655
|
+
return {
|
|
656
|
+
model: json.model,
|
|
657
|
+
content: message.content || '',
|
|
658
|
+
reasoning_content: void 0,
|
|
659
|
+
citations: (message.citations || []).map((c)=>({
|
|
660
|
+
content: c.snippet,
|
|
661
|
+
title: c.title,
|
|
662
|
+
url: c.link,
|
|
663
|
+
date: c.date
|
|
664
|
+
})),
|
|
665
|
+
usage: {
|
|
666
|
+
input: json.usage.prompt_tokens,
|
|
667
|
+
output: json.usage.completion_tokens,
|
|
668
|
+
total: json.usage.total_tokens
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
async handleStream(subject, stream) {
|
|
673
|
+
const decoder = new TextDecoder();
|
|
674
|
+
const reader = stream.getReader();
|
|
675
|
+
let buffer = '';
|
|
676
|
+
const handleBuffer = (buffer, onParsed)=>{
|
|
677
|
+
const lines = buffer.split('\n');
|
|
678
|
+
const lastLine = lines.pop();
|
|
679
|
+
const event = {};
|
|
680
|
+
lines.forEach((line)=>{
|
|
681
|
+
if ('' === line.trim()) return void onParsed(event);
|
|
682
|
+
const [name, ...values] = line.split(':');
|
|
683
|
+
const text = values.join(':').trim();
|
|
684
|
+
if ('[DONE]' === text.toUpperCase()) return;
|
|
685
|
+
const data = 'data' === name ? parseJson(text) : text;
|
|
686
|
+
event[name] = data;
|
|
687
|
+
});
|
|
688
|
+
return lastLine;
|
|
689
|
+
};
|
|
690
|
+
let usage = {};
|
|
691
|
+
while(true){
|
|
692
|
+
const { done, value } = await reader.read();
|
|
693
|
+
if (done) break;
|
|
694
|
+
const text = decoder.decode(value, {
|
|
695
|
+
stream: true
|
|
696
|
+
});
|
|
697
|
+
buffer += text;
|
|
698
|
+
buffer = handleBuffer(buffer, (event)=>{
|
|
699
|
+
if (event.data?.object !== 'chat.completion') return;
|
|
700
|
+
usage = event.data.usage;
|
|
701
|
+
const delta = event.data.choices[0].delta;
|
|
702
|
+
if (delta.citations) return void subject.next({
|
|
703
|
+
type: 'citations',
|
|
704
|
+
data: {
|
|
705
|
+
citations: delta.citations.map((c)=>({
|
|
706
|
+
title: c.title,
|
|
707
|
+
url: c.link,
|
|
708
|
+
content: c.content || '',
|
|
709
|
+
date: c.date
|
|
710
|
+
}))
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
if (delta.reasoning_content) return void subject.next({
|
|
714
|
+
type: 'thinking',
|
|
715
|
+
data: {
|
|
716
|
+
model: event.data.model,
|
|
717
|
+
content: delta.reasoning_content
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
if (delta.content) return void subject.next({
|
|
721
|
+
type: 'chunk',
|
|
722
|
+
data: {
|
|
723
|
+
model: event.data.model,
|
|
724
|
+
content: delta.content
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
subject.next({
|
|
730
|
+
type: 'complete',
|
|
731
|
+
data: {
|
|
732
|
+
usage: {
|
|
733
|
+
input: usage?.prompt_tokens || 0,
|
|
734
|
+
output: usage?.completion_tokens || 0,
|
|
735
|
+
total: usage?.total_tokens || 0
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
subject.complete();
|
|
740
|
+
}
|
|
741
|
+
async request(options) {
|
|
742
|
+
const { api_key, ...restOptions } = options;
|
|
743
|
+
const headers = {
|
|
744
|
+
'Content-Type': 'application/json',
|
|
745
|
+
Authorization: `Bearer ${api_key}`
|
|
746
|
+
};
|
|
747
|
+
const body = restOptions;
|
|
748
|
+
const response = await fetch(this.baseURL, {
|
|
749
|
+
method: 'POST',
|
|
750
|
+
headers,
|
|
751
|
+
body: JSON.stringify(body)
|
|
752
|
+
});
|
|
753
|
+
if (!response.ok) {
|
|
754
|
+
const error = await response.text();
|
|
755
|
+
throw new common_namespaceObject.BadRequestException(`HTTP ${response.status}: ${error}`);
|
|
756
|
+
}
|
|
757
|
+
return response;
|
|
758
|
+
}
|
|
759
|
+
constructor(...args){
|
|
760
|
+
super(...args), this.baseURL = 'https://metaso.cn/api/v1/chat/completions';
|
|
761
|
+
}
|
|
762
|
+
}
|
|
652
763
|
function llm_provider_service_ts_decorate(decorators, target, key, desc) {
|
|
653
764
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
654
765
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -662,12 +773,17 @@ class LLMProviderService {
|
|
|
662
773
|
const volcengine = new VolcengineProvider();
|
|
663
774
|
return volcengine.call(params);
|
|
664
775
|
}
|
|
776
|
+
if ('meta' === provider) {
|
|
777
|
+
const meta = new MetaProvider();
|
|
778
|
+
return meta.call(params);
|
|
779
|
+
}
|
|
665
780
|
throw new common_namespaceObject.BadRequestException('不支持该大模型提供商');
|
|
666
781
|
}
|
|
667
782
|
async sse(options, callback) {
|
|
668
783
|
const { provider, params } = options;
|
|
669
784
|
const ProviderConstructors = {
|
|
670
|
-
volcengine: VolcengineProvider
|
|
785
|
+
volcengine: VolcengineProvider,
|
|
786
|
+
meta: MetaProvider
|
|
671
787
|
};
|
|
672
788
|
const Constructor = ProviderConstructors[provider];
|
|
673
789
|
if (!Constructor) throw new common_namespaceObject.BadRequestException('不支持该大模型提供商');
|
|
@@ -707,6 +823,7 @@ LLMProviderModule = llm_provider_module_ts_decorate([
|
|
|
707
823
|
], LLMProviderModule);
|
|
708
824
|
var types_SupportProvider = /*#__PURE__*/ function(SupportProvider) {
|
|
709
825
|
SupportProvider["volcengine"] = "volcengine";
|
|
826
|
+
SupportProvider["meta"] = "meta";
|
|
710
827
|
return SupportProvider;
|
|
711
828
|
}({});
|
|
712
829
|
var types_ServerSendEventName = /*#__PURE__*/ function(ServerSendEventName) {
|
|
@@ -715,6 +832,7 @@ var types_ServerSendEventName = /*#__PURE__*/ function(ServerSendEventName) {
|
|
|
715
832
|
ServerSendEventName["Processing"] = "processing";
|
|
716
833
|
ServerSendEventName["Chunk"] = "chunk";
|
|
717
834
|
ServerSendEventName["Complete"] = "complete";
|
|
835
|
+
ServerSendEventName["Citations"] = "citations";
|
|
718
836
|
return ServerSendEventName;
|
|
719
837
|
}({});
|
|
720
838
|
exports.AdminAuthGuard = __webpack_exports__.AdminAuthGuard;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -52,6 +52,15 @@ export declare class BaseQueryDto {
|
|
|
52
52
|
get take(): number;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
declare type CitationItem = {
|
|
56
|
+
title: string;
|
|
57
|
+
url: string;
|
|
58
|
+
content?: string;
|
|
59
|
+
source?: string;
|
|
60
|
+
date?: string;
|
|
61
|
+
icon?: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
55
64
|
export declare class CorsInterceptor implements NestInterceptor {
|
|
56
65
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
57
66
|
}
|
|
@@ -79,6 +88,19 @@ export declare class LoggingInterceptor implements NestInterceptor {
|
|
|
79
88
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
80
89
|
}
|
|
81
90
|
|
|
91
|
+
declare type MetaRequestionOption = {
|
|
92
|
+
api_key: string;
|
|
93
|
+
model: 'fast' | 'fast_thinking' | 'ds-r1';
|
|
94
|
+
messages: Array<{
|
|
95
|
+
role: string;
|
|
96
|
+
content: string;
|
|
97
|
+
}>;
|
|
98
|
+
stream?: boolean;
|
|
99
|
+
scope?: 'document' | 'scholar' | 'video' | 'podcast';
|
|
100
|
+
conciseSnippet: boolean;
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
};
|
|
103
|
+
|
|
82
104
|
export declare class PaginatedResponse<T> extends ApiResponse<PaginationData<T>> {
|
|
83
105
|
constructor(list: T[], current: number, pageSize: number, total: number, message?: string);
|
|
84
106
|
static create<T>(list: T[], current: number, pageSize: number, total: number, message?: string): PaginatedResponse<T>;
|
|
@@ -94,6 +116,7 @@ export declare class PaginationData<T> {
|
|
|
94
116
|
|
|
95
117
|
declare type ProviderParams = {
|
|
96
118
|
[SupportProvider.volcengine]: VolcengineRequestionOption;
|
|
119
|
+
[SupportProvider.meta]: MetaRequestionOption;
|
|
97
120
|
};
|
|
98
121
|
|
|
99
122
|
export declare const Public: () => CustomDecorator<string>;
|
|
@@ -147,7 +170,7 @@ export declare type ServerSendEventCallback<T extends ServerSendEventData['type'
|
|
|
147
170
|
}>['data']) => void;
|
|
148
171
|
|
|
149
172
|
export declare type ServerSendEventData = {
|
|
150
|
-
type: 'received' | 'thinking' | 'processing' | 'chunk' | 'complete';
|
|
173
|
+
type: 'received' | 'thinking' | 'processing' | 'chunk' | 'complete' | 'citations';
|
|
151
174
|
data: SevrverSendEventMessages[ServerSendEventData['type']];
|
|
152
175
|
};
|
|
153
176
|
|
|
@@ -156,13 +179,15 @@ export declare enum ServerSendEventName {
|
|
|
156
179
|
Thinking = "thinking",
|
|
157
180
|
Processing = "processing",
|
|
158
181
|
Chunk = "chunk",
|
|
159
|
-
Complete = "complete"
|
|
182
|
+
Complete = "complete",
|
|
183
|
+
Citations = "citations"
|
|
160
184
|
}
|
|
161
185
|
|
|
162
186
|
export declare type ServerSendJsonData = {
|
|
163
187
|
model?: string;
|
|
164
188
|
content: string;
|
|
165
|
-
reasoning_content
|
|
189
|
+
reasoning_content?: string;
|
|
190
|
+
citations?: Array<CitationItem>;
|
|
166
191
|
usage: {
|
|
167
192
|
input: number;
|
|
168
193
|
output: number;
|
|
@@ -190,6 +215,9 @@ export declare type SevrverSendEventMessages = {
|
|
|
190
215
|
[ServerSendEventName.Complete]: {
|
|
191
216
|
usage: ServerSendJsonData['usage'];
|
|
192
217
|
};
|
|
218
|
+
[ServerSendEventName.Citations]: {
|
|
219
|
+
citations: CitationItem[];
|
|
220
|
+
};
|
|
193
221
|
};
|
|
194
222
|
|
|
195
223
|
export declare class StaticRouteMiddleware implements NestMiddleware {
|
|
@@ -213,7 +241,8 @@ export declare interface StaticRouteOptions {
|
|
|
213
241
|
}
|
|
214
242
|
|
|
215
243
|
export declare enum SupportProvider {
|
|
216
|
-
volcengine = "volcengine"
|
|
244
|
+
volcengine = "volcengine",
|
|
245
|
+
meta = "meta"
|
|
217
246
|
}
|
|
218
247
|
|
|
219
248
|
export declare const User: (...dataOrPipes: (string | PipeTransform<any, any> | Type<PipeTransform<any, any>>)[]) => ParameterDecorator;
|