@graf-research/llm-runner 0.0.2 → 0.0.4

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.
@@ -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 streamAskMultipleChoiceAnswer(llm: LLMRunner.BaseLLM, q: string, options: string[], session_id?: string): Promise<StreamResponseWithFinalAnswer<string[]>>;
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
@@ -115,7 +115,7 @@ var NativeStep;
115
115
  // ================================= //
116
116
  function generateMultipleChoiceAnswerResolver(options) {
117
117
  return (response) => __awaiter(this, void 0, void 0, function* () {
118
- const list_options_answer = response.trim().split('\n').map(s => s.trim());
118
+ const list_options_answer = response.trim().split(/[\n,]/).map(s => s.trim());
119
119
  return options.sort((a, b) => b.length - a.length).filter(a => list_options_answer.includes(a));
120
120
  });
121
121
  }
@@ -126,13 +126,33 @@ var NativeStep;
126
126
  });
127
127
  }
128
128
  NativeStep.askMultipleChoiceAnswer = askMultipleChoiceAnswer;
129
- function streamAskMultipleChoiceAnswer(llm, q, options, session_id) {
129
+ function streamMultipleChoiceAnswer(llm, q, options, session_id) {
130
130
  return __awaiter(this, void 0, void 0, function* () {
131
131
  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
132
  return yield stream(llm, prompt, generateMultipleChoiceAnswerResolver(options), session_id);
133
133
  });
134
134
  }
135
- NativeStep.streamAskMultipleChoiceAnswer = streamAskMultipleChoiceAnswer;
135
+ NativeStep.streamMultipleChoiceAnswer = streamMultipleChoiceAnswer;
136
+ // ================================= //
137
+ // Open List Answer
138
+ // ================================= //
139
+ const open_list_answer_resolver = (response) => __awaiter(this, void 0, void 0, function* () {
140
+ return response.trim().split(/\n+/).map(s => s.trim());
141
+ });
142
+ function askOpenListAnswer(llm, q, session_id) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ const prompt = `Respond this question: ${q}, give answers as list line by line, remember: one line is one answer.`;
145
+ return yield ask(llm, prompt, open_list_answer_resolver, session_id);
146
+ });
147
+ }
148
+ NativeStep.askOpenListAnswer = askOpenListAnswer;
149
+ function streamOpenListAnswer(llm, q, session_id) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const prompt = `Respond this question: ${q}, give answers as list line by line, remember: one line is one answer.`;
152
+ return yield stream(llm, prompt, open_list_answer_resolver, session_id);
153
+ });
154
+ }
155
+ NativeStep.streamOpenListAnswer = streamOpenListAnswer;
136
156
  // ================================= //
137
157
  // Plan
138
158
  // ================================= //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graf-research/llm-runner",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc",