ctod 0.7.0 → 0.7.1

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.
Files changed (99) hide show
  1. package/.api-key +1 -0
  2. package/.nyc_output/42919e68-b472-4a5d-b2d3-5d5153f28467.json +1 -0
  3. package/.nyc_output/processinfo/42919e68-b472-4a5d-b2d3-5d5153f28467.json +1 -0
  4. package/.nyc_output/processinfo/index.json +1 -0
  5. package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/cover-0.png +1 -0
  6. package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/cover-1.png +1 -0
  7. package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/story-config.json +4 -0
  8. package/.output/.output/stores//344/270/200/345/240/264/346/234/237/345/276/205/345/267/262/344/271/205/347/232/204/345/222/214/350/247/243/story.json +22 -0
  9. package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/cover-0.png +1 -0
  10. package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/cover-1.png +1 -0
  11. package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/story-config.json +4 -0
  12. package/.output/.output/stores//345/276/236/351/273/221/346/232/227/350/265/260/345/220/221/345/205/211/346/230/216/story.json +24 -0
  13. package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/cover-0.png +1 -0
  14. package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/cover-1.png +1 -0
  15. package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/story-config.json +4 -0
  16. package/.output/.output/stores//347/240/264/347/242/216/347/232/204/345/271/273/350/261/241/story.json +24 -0
  17. package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/cover-0.png +1 -0
  18. package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/cover-1.png +1 -0
  19. package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/story-config.json +4 -0
  20. package/.output/.output/stores//350/227/235/350/241/223/345/256/266/347/232/204/351/235/210/346/204/237/story.json +28 -0
  21. package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/cover-0.png +1 -0
  22. package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/cover-1.png +1 -0
  23. package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/story-config.json +4 -0
  24. package/.output/.output/stores//350/250/230/346/206/266/345/225/206/344/272/272/story.json +18 -0
  25. package/.output/.output/stores//350/250/255/350/250/210/350/210/207/351/226/213/347/231/274/347/232/204/346/214/221/346/210/260/content.json +22 -0
  26. package/.output/.output/talks//344/273/245/347/254/221/350/251/261/347/202/272/345/237/272/347/244/216/347/232/204/351/235/242/350/251/246/content.json +30 -0
  27. package/.output/.output/talks//344/273/245/347/254/221/350/251/261/347/202/272/345/237/272/347/244/216/347/232/204/351/235/242/350/251/246/cover-1684055229695.png +0 -0
  28. package/.output/.output/talks//345/234/250/346/224/277/346/262/273/345/200/231/351/201/270/344/272/272/350/276/257/350/253/226/344/270/255/347/232/204/350/252/252/346/234/215/346/200/247/346/272/235/351/200/232/content.json +30 -0
  29. package/.output/.output/talks//345/234/250/346/224/277/346/262/273/345/200/231/351/201/270/344/272/272/350/276/257/350/253/226/344/270/255/347/232/204/350/252/252/346/234/215/346/200/247/346/272/235/351/200/232/cover-1684056611678.png +0 -0
  30. package/.output/.output/talks//346/224/276/351/254/206/347/232/204/345/200/231/351/201/270/344/272/272/351/200/262/350/241/214/346/224/277/346/262/273/350/276/257/350/253/226/content.json +36 -0
  31. package/.output/.output/talks//346/224/276/351/254/206/347/232/204/345/200/231/351/201/270/344/272/272/351/200/262/350/241/214/346/224/277/346/262/273/350/276/257/350/253/226/cover-1684055140609.png +0 -0
  32. package/.output/.output/talks//346/224/277/346/262/273/347/254/221/350/251/261/content.json +30 -0
  33. package/.output/.output/talks//346/224/277/346/262/273/347/254/221/350/251/261/cover-1684056246465.png +0 -0
  34. package/.output/.output/talks//350/251/274/350/253/247/345/256/266/351/225/267/346/225/231/345/270/253/346/234/203/350/255/260/content.json +26 -0
  35. package/.output/.output/talks//350/251/274/350/253/247/345/256/266/351/225/267/346/225/231/345/270/253/346/234/203/350/255/260/cover-1685785935121.png +0 -0
  36. package/.output/.output/talks//350/262/241/345/213/231/351/241/247/345/225/217/350/253/256/350/251/242/content.json +26 -0
  37. package/.output/.output/talks//350/262/241/345/213/231/351/241/247/345/225/217/350/253/256/350/251/242/cover-1685785115833.png +0 -0
  38. package/.output/.output/talks//351/206/253/347/224/237/345/222/214/347/227/205/344/272/272/350/250/216/350/253/226/346/202/262/345/202/267/content.json +32 -0
  39. package/.output/.output/talks//351/206/253/347/224/237/345/222/214/347/227/205/344/272/272/350/250/216/350/253/226/346/202/262/345/202/267/cover-1684055075942.png +0 -0
  40. package/dist/index.js +1 -1
  41. package/package.json +1 -1
  42. package/examples/basic.ts +0 -89
  43. package/examples/llama.cpp.ts +0 -56
  44. package/examples/plugin.ts +0 -118
  45. package/lib/broker/chat.ts +0 -435
  46. package/lib/core/parser.ts +0 -62
  47. package/lib/core/plugin.ts +0 -46
  48. package/lib/core/translator.ts +0 -115
  49. package/lib/ctod.ts +0 -71
  50. package/lib/index.ts +0 -41
  51. package/lib/plugins/index.ts +0 -38
  52. package/lib/plugins/limiter.ts +0 -103
  53. package/lib/plugins/print-log.ts +0 -35
  54. package/lib/plugins/retry.ts +0 -25
  55. package/lib/plugins/role.ts +0 -28
  56. package/lib/service/llama3.cpp/completion.ts +0 -313
  57. package/lib/service/llama3.cpp/index.ts +0 -53
  58. package/lib/service/openai/chat.ts +0 -244
  59. package/lib/service/openai/images-generation.ts +0 -64
  60. package/lib/service/openai/index.ts +0 -97
  61. package/lib/service/openai/vision.ts +0 -111
  62. package/lib/shims.d.ts +0 -4
  63. package/lib/templates.ts +0 -71
  64. package/lib/types.ts +0 -4
  65. package/lib/utils/error.ts +0 -14
  66. package/lib/utils/validate.ts +0 -64
  67. package/logo.ai +2 -1141
  68. package/logo.png +0 -0
  69. package/types/examples/basic.d.ts +0 -1
  70. package/types/examples/chat-demo.d.ts +0 -2
  71. package/types/examples/chat-for-llama.cpp-demo.d.ts +0 -2
  72. package/types/examples/chat-with-json-schema-demo.d.ts +0 -2
  73. package/types/examples/llama.cpp.d.ts +0 -2
  74. package/types/examples/plugin-demo.d.ts +0 -2
  75. package/types/examples/plugin.d.ts +0 -2
  76. package/types/examples/stream-for-llama.cpp-demo.d.ts +0 -2
  77. package/types/examples/vision-demo.d.ts +0 -2
  78. package/types/lib/broker/chat.d.ts +0 -150
  79. package/types/lib/core/parser.d.ts +0 -32
  80. package/types/lib/core/plugin.d.ts +0 -34
  81. package/types/lib/core/translator.d.ts +0 -67
  82. package/types/lib/ctod.d.ts +0 -32
  83. package/types/lib/index.d.ts +0 -34
  84. package/types/lib/plugins/index.d.ts +0 -47
  85. package/types/lib/plugins/limiter.d.ts +0 -36
  86. package/types/lib/plugins/print-log.d.ts +0 -5
  87. package/types/lib/plugins/retry.d.ts +0 -6
  88. package/types/lib/plugins/role.d.ts +0 -5
  89. package/types/lib/service/llama3.cpp/completion.d.ts +0 -61
  90. package/types/lib/service/llama3.cpp/index.d.ts +0 -19
  91. package/types/lib/service/openai/chat.d.ts +0 -110
  92. package/types/lib/service/openai/completion.d.ts +0 -59
  93. package/types/lib/service/openai/images-generation.d.ts +0 -35
  94. package/types/lib/service/openai/index.d.ts +0 -29
  95. package/types/lib/service/openai/vision.d.ts +0 -74
  96. package/types/lib/templates.d.ts +0 -20
  97. package/types/lib/types.d.ts +0 -1
  98. package/types/lib/utils/error.d.ts +0 -11
  99. package/types/lib/utils/validate.d.ts +0 -16
package/logo.png DELETED
Binary file
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,2 +0,0 @@
1
- /// <reference types="lib/shims" />
2
- export {};
@@ -1,150 +0,0 @@
1
- import { ChatBrokerPlugin } from '../core/plugin';
2
- import { Event, Hook, Log } from 'power-helper';
3
- import { Translator, TranslatorParams } from '../core/translator';
4
- import { ValidateCallback, ValidateCallbackOutputs } from '../utils/validate';
5
- export type Message = {
6
- role: 'system' | 'user' | 'assistant' | (string & Record<string, unknown>);
7
- name?: string;
8
- content: string;
9
- };
10
- export type ChatBrokerHooks<S extends ValidateCallback<any>, O extends ValidateCallback<any>, P extends ChatBrokerPlugin<any, any>, PS extends Record<string, ReturnType<P['use']>>> = {
11
- /**
12
- * @zh 第一次聊天的時候觸發
13
- * @en Triggered when chatting for the first time
14
- */
15
- start: {
16
- id: string;
17
- data: ValidateCallbackOutputs<S>;
18
- metadata: Map<string, any>;
19
- plugins: {
20
- [K in keyof PS]: {
21
- send: (data: PS[K]['__receiveData']) => void;
22
- };
23
- };
24
- schema: {
25
- input?: S;
26
- output: O;
27
- };
28
- messages: Message[];
29
- setPreMessages: (messages: (Omit<Message, 'content'> & {
30
- content: string | string[];
31
- })[]) => void;
32
- changeMessages: (messages: Message[]) => void;
33
- changeOutputSchema: (output: O) => void;
34
- };
35
- /**
36
- * @zh 發送聊天訊息給機器人前觸發
37
- * @en Triggered before sending chat message to bot
38
- */
39
- talkBefore: {
40
- id: string;
41
- data: ValidateCallbackOutputs<S>;
42
- messages: Message[];
43
- metadata: Map<string, any>;
44
- lastUserMessage: string;
45
- };
46
- /**
47
- * @zh 當聊天機器人回傳資料的時候觸發
48
- * @en Triggered when the chatbot returns data
49
- */
50
- talkAfter: {
51
- id: string;
52
- data: ValidateCallbackOutputs<S>;
53
- response: any;
54
- messages: Message[];
55
- parseText: string;
56
- metadata: Map<string, any>;
57
- lastUserMessage: string;
58
- /**
59
- * @zh 宣告解析失敗
60
- * @en Declare parsing failure
61
- */
62
- parseFail: (error: any) => void;
63
- changeParseText: (text: string) => void;
64
- };
65
- /**
66
- * @zh 當回傳資料符合規格時觸發
67
- * @en Triggered when the returned data meets the specifications
68
- */
69
- succeeded: {
70
- id: string;
71
- metadata: Map<string, any>;
72
- output: ValidateCallbackOutputs<O>;
73
- };
74
- /**
75
- * @zh 當回傳資料不符合規格,或是解析錯誤時觸發
76
- * @en Triggered when the returned data does not meet the specifications or parsing errors
77
- */
78
- parseFailed: {
79
- id: string;
80
- error: any;
81
- retry: () => void;
82
- count: number;
83
- response: any;
84
- metadata: Map<string, any>;
85
- parserFails: {
86
- name: string;
87
- error: any;
88
- }[];
89
- messages: Message[];
90
- lastUserMessage: string;
91
- changeMessages: (messages: Message[]) => void;
92
- };
93
- /**
94
- * @zh 不論成功失敗,執行結束的時候會執行。
95
- * @en It will be executed when the execution is completed, regardless of success or failure.
96
- */
97
- done: {
98
- id: string;
99
- metadata: Map<string, any>;
100
- };
101
- };
102
- export type RequestContext = {
103
- id: string;
104
- count: number;
105
- isRetry: boolean;
106
- metadata: Map<string, any>;
107
- onCancel: (cb: () => void) => void;
108
- schema: {
109
- input: any;
110
- output: any;
111
- };
112
- };
113
- export type Params<S extends ValidateCallback<any>, O extends ValidateCallback<any>, C extends Record<string, any>, P extends ChatBrokerPlugin<any, any>, PS extends Record<string, ReturnType<P['use']>>> = Omit<TranslatorParams<S, O>, 'parsers'> & {
114
- name?: string;
115
- plugins?: PS | (() => PS);
116
- request: (messages: Message[], context: RequestContext) => Promise<string>;
117
- install?: (context: {
118
- log: Log;
119
- attach: Hook<C>['attach'];
120
- attachAfter: Hook<C>['attachAfter'];
121
- translator: Translator<S, O>;
122
- }) => void;
123
- };
124
- export declare class ChatBroker<S extends ValidateCallback<any>, O extends ValidateCallback<any>, P extends ChatBrokerPlugin<any, any>, PS extends Record<string, ReturnType<P['use']>>, C extends ChatBrokerHooks<S, O, P, PS> = ChatBrokerHooks<S, O, P, PS>> {
125
- protected __hookType: C;
126
- protected log: Log;
127
- protected hook: Hook<C>;
128
- protected params: Params<S, O, C, P, PS>;
129
- protected plugins: PS;
130
- protected installed: boolean;
131
- protected translator: Translator<S, O>;
132
- protected event: Event<{
133
- cancel: {
134
- requestId: string;
135
- };
136
- cancelAll: any;
137
- }>;
138
- constructor(params: Params<S, O, C, P, PS>);
139
- protected _install(): any;
140
- cancel(requestId?: string): Promise<void>;
141
- requestWithId<T extends Translator<S, O>>(data: T['__schemeType']): {
142
- id: string;
143
- request: Promise<T['__outputType']>;
144
- };
145
- /**
146
- * @zh 將請求發出至聊天機器人。
147
- * @en Send request to chatbot.
148
- */
149
- request<T extends Translator<S, O>>(data: T['__schemeType']): Promise<T['__outputType']>;
150
- }
@@ -1,32 +0,0 @@
1
- type TextParserParams = {
2
- /**
3
- * @zh 解讀器名字。
4
- * @en The name of the parser.
5
- */
6
- name: string;
7
- /**
8
- * @zh 解讀文本。
9
- * @en Read the text.
10
- */
11
- handler: (text: string) => Promise<any>;
12
- };
13
- export declare class TextParser {
14
- private params;
15
- /**
16
- * @zh 盡可能將文字內的 json 解讀出來。
17
- * @en Try to read the json in the text as much as possible.
18
- */
19
- static JsonMessage(): TextParser;
20
- constructor(params: TextParserParams);
21
- /**
22
- * @zh 解讀器名字。
23
- * @en The name of the parser.
24
- */
25
- get name(): string;
26
- /**
27
- * @zh 解讀文本。
28
- * @en Read the text.
29
- */
30
- read(text: string): Promise<any>;
31
- }
32
- export {};
@@ -1,34 +0,0 @@
1
- import { Translator } from './translator';
2
- import { ChatBrokerHooks } from '../broker/chat';
3
- import { Log, Hook, Event } from 'power-helper';
4
- import { ValidateCallback, ValidateCallbackOutputs } from '../utils/validate';
5
- type BrokerHooks = ChatBrokerHooks<any, any, any, any>;
6
- type BrokerPluginParams<T extends ValidateCallback<any>, R extends ValidateCallback<any>> = {
7
- name: string;
8
- params: T;
9
- receiveData: R;
10
- onInstall: (context: {
11
- log: Log;
12
- params: ValidateCallbackOutputs<T>;
13
- attach: Hook<BrokerHooks>['attach'];
14
- attachAfter: Hook<BrokerHooks>['attachAfter'];
15
- translator: Translator<any, any>;
16
- receive: (callback: (params: {
17
- id: string;
18
- data: ValidateCallbackOutputs<R>;
19
- }) => void) => void;
20
- }) => void;
21
- };
22
- export declare class ChatBrokerPlugin<T extends ValidateCallback<any>, R extends ValidateCallback<any>> {
23
- _event: Event<Record<string, Record<string, any>>>;
24
- _params: BrokerPluginParams<T, R>;
25
- constructor(params: BrokerPluginParams<T, R>);
26
- use(params: ValidateCallbackOutputs<T>): {
27
- instance: any;
28
- params: ValidateCallbackOutputs<T, ReturnType<T>>;
29
- send: (data: ValidateCallbackOutputs<R>) => void;
30
- receive: (callback: any) => void;
31
- __receiveData: ValidateCallbackOutputs<R, ReturnType<R>>;
32
- };
33
- }
34
- export {};
@@ -1,67 +0,0 @@
1
- import { TextParser } from './parser';
2
- import { ValidateCallback, ValidateCallbackOutputs } from '../utils/validate';
3
- export type TranslatorParams<S extends ValidateCallback<any>, O extends ValidateCallback<any>> = {
4
- /**
5
- * @zh 輸入的資料格式。
6
- * @en The input data format.
7
- */
8
- input?: S;
9
- /**
10
- * @zh 輸出的資料格式。
11
- * @en The output data format.
12
- */
13
- output: O;
14
- /**
15
- * @zh 註冊解讀文字的解析器。
16
- * @en Register the parser to interpret the text.
17
- */
18
- parsers: TextParser[];
19
- /**
20
- * @zh 組合輸入資料成為提示文字。
21
- * @en Combine the input data into a prompt.
22
- */
23
- question?: (data: ValidateCallbackOutputs<S>, context: {
24
- schema: {
25
- input?: S;
26
- output: O;
27
- };
28
- }) => Promise<string | string[]>;
29
- };
30
- export declare class Translator<S extends ValidateCallback<any>, O extends ValidateCallback<any>> {
31
- private params;
32
- constructor(params: TranslatorParams<S, O>);
33
- get __schemeType(): ValidateCallbackOutputs<S>;
34
- get __outputType(): ValidateCallbackOutputs<O>;
35
- /**
36
- * @zh 組合輸入資料成為提示文字。
37
- * @en Combine the input data into a prompt.
38
- */
39
- compile(data: ValidateCallbackOutputs<S>, context: {
40
- schema: {
41
- input?: S;
42
- output: O;
43
- };
44
- }): Promise<{
45
- scheme: ValidateCallbackOutputs<S, ReturnType<S>>;
46
- prompt: string;
47
- }>;
48
- getValidate(): {
49
- input: S | undefined;
50
- output: O;
51
- };
52
- changeOutputSchema(schema: O): void;
53
- /**
54
- * @zh 將文字轉換成序列化資料。
55
- * @en Convert text to serialized data.
56
- */
57
- parse(text: string): Promise<{
58
- output: ReturnType<O> extends infer T ? { [K in keyof T]: ReturnType<O>[K] extends {
59
- __outputType: any;
60
- } ? ReturnType<O>[K]["__outputType"] : ReturnType<O>[K]; } : never;
61
- parserName: string;
62
- parserFails: {
63
- name: string;
64
- error: any;
65
- }[];
66
- }>;
67
- }
@@ -1,32 +0,0 @@
1
- import { ChatBroker, Message, Params as ChatBrokerParams, ChatBrokerHooks, RequestContext } from './broker/chat';
2
- import { ChatBrokerPlugin } from './core/plugin';
3
- import { Schema } from 'yup';
4
- import * as Yup from 'yup';
5
- type IO = any;
6
- export declare class CtoD<P extends ChatBrokerPlugin<IO, IO>, PS extends Record<string, ReturnType<P['use']>>> {
7
- params: {
8
- request: (messages: Message[], context: RequestContext) => Promise<string>;
9
- plugins?: (() => PS) | undefined;
10
- };
11
- constructor(params: {
12
- request: (messages: Message[], context: RequestContext) => Promise<string>;
13
- plugins?: () => PS;
14
- });
15
- createBrokerBuilder<I extends Record<string, any>>(params?: {
16
- install?: ChatBrokerParams<() => I, IO, ChatBrokerHooks<() => I, IO, P, PS>, P, PS>['install'];
17
- }): {
18
- create: <O extends Record<string, Schema<any, any, any, "">>>(install: (context: {
19
- id: string;
20
- yup: typeof Yup;
21
- data: I;
22
- plugins: { [K in keyof PS]: {
23
- send: (data: PS[K]["__receiveData"]) => void;
24
- }; };
25
- setMessages: (messages: (Omit<Message, 'content'> & {
26
- content: string | string[];
27
- })[]) => void;
28
- metadata: Map<string, any>;
29
- }) => Promise<O>) => ChatBroker<() => I, () => O, P, PS, ChatBrokerHooks<() => I, () => O, P, PS>>;
30
- };
31
- }
32
- export {};
@@ -1,34 +0,0 @@
1
- export * as plugins from './plugins';
2
- export * as templates from './templates';
3
- export { CtoD } from './ctod';
4
- export { validateToJsonSchema, defineYupSchema, ValidateCallback } from './utils/validate';
5
- export { OpenAI } from './service/openai';
6
- export { Llama3Cpp } from './service/llama3.cpp';
7
- export { TextParser } from './core/parser';
8
- export { ChatGPTMessage } from './service/openai/chat';
9
- export { ChatBroker } from './broker/chat';
10
- export { ChatBrokerPlugin } from './core/plugin';
11
- export { Translator, TranslatorParams } from './core/translator';
12
- import * as plugins from './plugins';
13
- import * as templates from './templates';
14
- import { OpenAI } from './service/openai';
15
- import { CtoD } from './ctod';
16
- import { Llama3Cpp } from './service/llama3.cpp';
17
- import { Translator } from './core/translator';
18
- import { TextParser } from './core/parser';
19
- import { ChatBroker } from './broker/chat';
20
- import { ChatBrokerPlugin } from './core/plugin';
21
- export declare const ctod: {
22
- CtoD: typeof CtoD;
23
- OpenAI: typeof OpenAI;
24
- Llama3Cpp: typeof Llama3Cpp;
25
- plugins: typeof plugins;
26
- templates: typeof templates;
27
- ChatBroker: typeof ChatBroker;
28
- Translator: typeof Translator;
29
- TextParser: typeof TextParser;
30
- ChatBrokerPlugin: typeof ChatBrokerPlugin;
31
- defineYupSchema: <T extends Record<string, import("yup").Schema<any, any, any, "">>>(cb: import("./utils/validate").ValidateCallback<T>) => T;
32
- validateToJsonSchema: <T_1 extends import("./utils/validate").ValidateCallback<any>>(cb: T_1) => import("json-schema").JSONSchema7;
33
- };
34
- export default ctod;
@@ -1,47 +0,0 @@
1
- /**
2
- * @zh 一個基於印出 log 的 plugin。
3
- * @en A plugin based on printing log.
4
- */
5
- export declare const PrintLogPlugin: import("..").ChatBrokerPlugin<(yup: typeof import("yup")) => {
6
- detail: import("yup").BooleanSchema<boolean | undefined, import("yup").AnyObject, false, "d">;
7
- }, () => {}>;
8
- /**
9
- * @zh 當解析失敗時,會自動重試的對話。
10
- * @en A conversation that will automatically retry when parsing fails.
11
- */
12
- export declare const RetryPlugin: import("..").ChatBrokerPlugin<(yup: typeof import("yup")) => {
13
- retry: import("yup").NumberSchema<number, import("yup").AnyObject, 1, "d">;
14
- printWarn: import("yup").BooleanSchema<NonNullable<boolean | undefined>, import("yup").AnyObject, true, "d">;
15
- }, () => {}>;
16
- /**
17
- * @zh 限制使用流量,這個 plugin 可以有效讓所有對話不會再限制內同時發送,可用於在開發過程中遭遇伺服器因頻率過高而阻擋請求。
18
- * @en Limit the use of traffic. This plugin can effectively prevent all conversations from being sent at the same time within the limit, and can be used when the server blocks requests due to high frequency during development.
19
- */
20
- export declare const LimiterPlugin: import("..").ChatBrokerPlugin<() => {}, () => {}>;
21
- /**
22
- * @zh 排程系統將全域託管,有什麼必要設定可以來更動它的狀態,例如:關閉排程。
23
- * @en The scheduling system will be globally hosted. What is necessary to set can come to change its status, for example: close the schedule.
24
- */
25
- export declare const LimiterPluginGlobState: {
26
- event: import("power-helper").Event<{
27
- run: {
28
- id: string;
29
- };
30
- waitTimeChange: {
31
- waitTime: number;
32
- };
33
- }>;
34
- config: {
35
- limit: number;
36
- interval: number;
37
- };
38
- closeSchedule: () => void;
39
- plugin: import("..").ChatBrokerPlugin<() => {}, () => {}>;
40
- };
41
- /**
42
- * @zh 設定角色扮演。
43
- * @en Set role play.
44
- */
45
- export declare const RolePlugin: import("..").ChatBrokerPlugin<(yup: typeof import("yup")) => {
46
- role: import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
47
- }, () => {}>;
@@ -1,36 +0,0 @@
1
- import { ChatBrokerPlugin } from '../core/plugin';
2
- import { Event } from 'power-helper';
3
- type Events = {
4
- run: {
5
- id: string;
6
- };
7
- waitTimeChange: {
8
- waitTime: number;
9
- };
10
- };
11
- declare const _default: {
12
- /**
13
- * @zh 你可以監聽一些事件行為,例如還需要等待多少時間。
14
- * @en You can listen for some event behaviors, such as how long you still need to wait.
15
- */
16
- event: Event<Events>;
17
- /**
18
- * @zh 預設是每分鐘限制3次,你可以在設定中改變限制流量。
19
- * @en By default, the limit is 3 times per minute, and you can change the limit flow in the settings.
20
- */
21
- config: {
22
- limit: number;
23
- interval: number;
24
- };
25
- /**
26
- * @zh 由於排程會在背景持續倒數,如果有關閉程式的需求,需要手動進行移除。
27
- * @en Since the schedule will continue to count down in the background, if there is a need to close the program, you need to manually remove it.
28
- */
29
- closeSchedule: () => void;
30
- /**
31
- * @zh Plugin 的接口
32
- * @en Plugin interface
33
- */
34
- plugin: ChatBrokerPlugin<() => {}, () => {}>;
35
- };
36
- export default _default;
@@ -1,5 +0,0 @@
1
- import { ChatBrokerPlugin } from '../core/plugin';
2
- declare const _default: ChatBrokerPlugin<(yup: typeof import("yup")) => {
3
- detail: import("yup").BooleanSchema<boolean | undefined, import("yup").AnyObject, false, "d">;
4
- }, () => {}>;
5
- export default _default;
@@ -1,6 +0,0 @@
1
- import { ChatBrokerPlugin } from '../core/plugin';
2
- declare const _default: ChatBrokerPlugin<(yup: typeof import("yup")) => {
3
- retry: import("yup").NumberSchema<number, import("yup").AnyObject, 1, "d">;
4
- printWarn: import("yup").BooleanSchema<NonNullable<boolean | undefined>, import("yup").AnyObject, true, "d">;
5
- }, () => {}>;
6
- export default _default;
@@ -1,5 +0,0 @@
1
- import { ChatBrokerPlugin } from '../core/plugin';
2
- declare const _default: ChatBrokerPlugin<(yup: typeof import("yup")) => {
3
- role: import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
4
- }, () => {}>;
5
- export default _default;
@@ -1,61 +0,0 @@
1
- import { Llama3Cpp } from './index';
2
- type Message = {
3
- role: string;
4
- content: string;
5
- };
6
- type Options = any;
7
- export type Config = {
8
- baseUrl: string;
9
- headers: Record<string, string>;
10
- autoConvertTraditionalChinese: boolean;
11
- };
12
- type Stream = {
13
- onMessage: (data: {
14
- message: string;
15
- }) => void;
16
- onEnd?: () => void;
17
- onWarn?: (error: any) => void;
18
- onError?: (error: any) => void;
19
- };
20
- export declare class Llama3CppCompletion {
21
- core: Llama3Cpp;
22
- config: Config;
23
- constructor(core: Llama3Cpp);
24
- setConfig(config: Partial<Config>): void;
25
- completion(params: {
26
- options?: Options;
27
- messages: Message[];
28
- }): {
29
- run: () => Promise<{
30
- message: string;
31
- fullMessage: string;
32
- }>;
33
- cancel: () => void;
34
- };
35
- completionStream(params: Stream & {
36
- messages: Message[];
37
- options?: Options;
38
- }): {
39
- cancel: () => void;
40
- };
41
- talk(params: {
42
- options?: Options;
43
- messages: Message[];
44
- response_format?: {
45
- type: 'json_object';
46
- schema: any;
47
- };
48
- }): {
49
- run: () => Promise<{
50
- message: string;
51
- }>;
52
- cancel: () => void;
53
- };
54
- talkStream(params: Stream & {
55
- options?: Options;
56
- messages: Message[];
57
- }): {
58
- cancel: () => void;
59
- };
60
- }
61
- export {};
@@ -1,19 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { Llama3CppCompletion, Config } from './completion';
3
- export declare class Llama3Cpp {
4
- _axios: AxiosInstance;
5
- static createChatRequest(params: {
6
- config: Partial<Config> | (() => Promise<Partial<Config>>);
7
- talkOptions?: any;
8
- }): (messages: any[], { schema, onCancel }: any) => Promise<string>;
9
- /**
10
- * @zh 如果你有需要特別設定 axios,請使用這方法。
11
- * @en If you need to set axios, please use this method.
12
- */
13
- setAxios(axios: AxiosInstance): void;
14
- /**
15
- * @zh 建立 補強/ 對話物件。
16
- * @en Create completion object.
17
- */
18
- createCompletion(): Llama3CppCompletion;
19
- }