@graf-research/llm-runner 0.0.3 → 0.0.5
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/multistep.d.ts +3 -1
- package/dist/multistep.js +25 -3
- package/package.json +1 -1
package/dist/multistep.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export declare namespace NativeStep {
|
|
|
13
13
|
function askChoose(llm: LLMRunner.BaseLLM, q: string, options: string[], session_id?: string): Promise<string>;
|
|
14
14
|
function streamAskChoose(llm: LLMRunner.BaseLLM, q: string, options: string[], session_id?: string): Promise<StreamResponseWithFinalAnswer<string>>;
|
|
15
15
|
function askMultipleChoiceAnswer(llm: LLMRunner.BaseLLM, q: string, options: string[], session_id?: string): Promise<string[]>;
|
|
16
|
-
function
|
|
16
|
+
function streamMultipleChoiceAnswer(llm: LLMRunner.BaseLLM, q: string, options: string[], session_id?: string): Promise<StreamResponseWithFinalAnswer<string[]>>;
|
|
17
|
+
function askOpenListAnswer(llm: LLMRunner.BaseLLM, q: string, session_id?: string): Promise<string[]>;
|
|
18
|
+
function streamOpenListAnswer(llm: LLMRunner.BaseLLM, q: string, session_id?: string): Promise<StreamResponseWithFinalAnswer<string[]>>;
|
|
17
19
|
function askPlan(llm: LLMRunner.BaseLLM, q: string, session_id?: string): Promise<string[]>;
|
|
18
20
|
function streamPlan(llm: LLMRunner.BaseLLM, q: string, session_id?: string): Promise<StreamResponseWithFinalAnswer<string[]>>;
|
|
19
21
|
}
|
package/dist/multistep.js
CHANGED
|
@@ -116,7 +116,9 @@ var NativeStep;
|
|
|
116
116
|
function generateMultipleChoiceAnswerResolver(options) {
|
|
117
117
|
return (response) => __awaiter(this, void 0, void 0, function* () {
|
|
118
118
|
const list_options_answer = response.trim().split(/[\n,]/).map(s => s.trim());
|
|
119
|
-
|
|
119
|
+
const sorted_list = [...options].sort((a, b) => b.length - a.length);
|
|
120
|
+
const selected_data = sorted_list.filter(a => list_options_answer.includes(a));
|
|
121
|
+
return options.filter(b => selected_data.includes(b));
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
function askMultipleChoiceAnswer(llm, q, options, session_id) {
|
|
@@ -126,13 +128,33 @@ var NativeStep;
|
|
|
126
128
|
});
|
|
127
129
|
}
|
|
128
130
|
NativeStep.askMultipleChoiceAnswer = askMultipleChoiceAnswer;
|
|
129
|
-
function
|
|
131
|
+
function streamMultipleChoiceAnswer(llm, q, options, session_id) {
|
|
130
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
133
|
const prompt = `Respond this question: ${q}, choose on or more from this options as answer: ${options.map(a => `"${a}"`).join(',')}. Put all the answers into one line each. Don't make up an answer, only choose from available options`;
|
|
132
134
|
return yield stream(llm, prompt, generateMultipleChoiceAnswerResolver(options), session_id);
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
|
-
NativeStep.
|
|
137
|
+
NativeStep.streamMultipleChoiceAnswer = streamMultipleChoiceAnswer;
|
|
138
|
+
// ================================= //
|
|
139
|
+
// Open List Answer
|
|
140
|
+
// ================================= //
|
|
141
|
+
const open_list_answer_resolver = (response) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
return response.trim().split(/\n+/).map(s => s.trim());
|
|
143
|
+
});
|
|
144
|
+
function askOpenListAnswer(llm, q, session_id) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const prompt = `Respond this question: ${q}, give answers as list line by line, remember: one line is one answer.`;
|
|
147
|
+
return yield ask(llm, prompt, open_list_answer_resolver, session_id);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
NativeStep.askOpenListAnswer = askOpenListAnswer;
|
|
151
|
+
function streamOpenListAnswer(llm, q, session_id) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const prompt = `Respond this question: ${q}, give answers as list line by line, remember: one line is one answer.`;
|
|
154
|
+
return yield stream(llm, prompt, open_list_answer_resolver, session_id);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
NativeStep.streamOpenListAnswer = streamOpenListAnswer;
|
|
136
158
|
// ================================= //
|
|
137
159
|
// Plan
|
|
138
160
|
// ================================= //
|