Skip to content
Snippets Groups Projects
Commit 407069ca authored by Yi Ding's avatar Yi Ding
Browse files

prompt work for question generator

parent 29d04217
No related branches found
No related tags found
No related merge requests found
...@@ -114,3 +114,82 @@ ${context} ...@@ -114,3 +114,82 @@ ${context}
Question: ${query} Question: ${query}
Answer:`; Answer:`;
}; };
/*
PREFIX = """\
Given a user question, and a list of tools, output a list of relevant sub-questions \
that when composed can help answer the full user question:
"""
example_query_str = (
"Compare and contrast the revenue growth and EBITDA of Uber and Lyft for year 2021"
)
example_tools = [
ToolMetadata(
name="uber_10k",
description="Provides information about Uber financials for year 2021",
),
ToolMetadata(
name="lyft_10k",
description="Provides information about Lyft financials for year 2021",
),
]
example_tools_str = build_tools_text(example_tools)
example_output = [
SubQuestion(
sub_question="What is the revenue growth of Uber", tool_name="uber_10k"
),
SubQuestion(sub_question="What is the EBITDA of Uber", tool_name="uber_10k"),
SubQuestion(
sub_question="What is the revenue growth of Lyft", tool_name="lyft_10k"
),
SubQuestion(sub_question="What is the EBITDA of Lyft", tool_name="lyft_10k"),
]
example_output_str = json.dumps([x.dict() for x in example_output], indent=4)
EXAMPLES = (
"""\
# Example 1
<Tools>
```json
{tools_str}
```
<User Question>
{query_str}
<Output>
```json
{output_str}
```
""".format(
query_str=example_query_str,
tools_str=example_tools_str,
output_str=example_output_str,
)
.replace("{", "{{")
.replace("}", "}}")
)
SUFFIX = """\
# Example 2
<Tools>
```json
{tools_str}
```
<User Question>
{query_str}
<Output>
"""
DEFAULT_SUB_QUESTION_PROMPT_TMPL = PREFIX + EXAMPLES + SUFFIX
*/
export const defaultSubQuestionPrompt: SimplePrompt = (input) => {
return "";
};
import { BaseLLMPredictor } from "./LLMPredictor"; import { BaseLLMPredictor, ChatGPTLLMPredictor } from "./LLMPredictor";
import { SimplePrompt } from "./Prompt"; import { SimplePrompt, defaultSubQuestionPrompt } from "./Prompt";
import { ToolMetadata } from "./Tool"; import { ToolMetadata } from "./Tool";
export interface BaseQuestionGenerator { export interface BaseQuestionGenerator {
...@@ -11,8 +11,8 @@ export class LLMQuestionGenerator implements BaseQuestionGenerator { ...@@ -11,8 +11,8 @@ export class LLMQuestionGenerator implements BaseQuestionGenerator {
prompt: SimplePrompt; prompt: SimplePrompt;
constructor(init?: Partial<LLMQuestionGenerator>) { constructor(init?: Partial<LLMQuestionGenerator>) {
this.llmPredictor = init?.llmPredictor ?? new BaseLLMPredictor(); this.llmPredictor = init?.llmPredictor ?? new ChatGPTLLMPredictor();
this.prompt = init?.prompt ?? new SimplePrompt(); this.prompt = init?.prompt ?? defaultSubQuestionPrompt;
} }
async agenerate( async agenerate(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment