"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    anthropicSummaryPrompt: function() {
        return anthropicSummaryPrompt;
    },
    anthropicTextQaPrompt: function() {
        return anthropicTextQaPrompt;
    },
    buildToolsText: function() {
        return buildToolsText;
    },
    defaultChoiceSelectPrompt: function() {
        return defaultChoiceSelectPrompt;
    },
    defaultCondenseQuestionPrompt: function() {
        return defaultCondenseQuestionPrompt;
    },
    defaultContextSystemPrompt: function() {
        return defaultContextSystemPrompt;
    },
    defaultKeywordExtractPrompt: function() {
        return defaultKeywordExtractPrompt;
    },
    defaultQueryKeywordExtractPrompt: function() {
        return defaultQueryKeywordExtractPrompt;
    },
    defaultRefinePrompt: function() {
        return defaultRefinePrompt;
    },
    defaultSubQuestionPrompt: function() {
        return defaultSubQuestionPrompt;
    },
    defaultSummaryPrompt: function() {
        return defaultSummaryPrompt;
    },
    defaultTextQaPrompt: function() {
        return defaultTextQaPrompt;
    },
    defaultTreeSummarizePrompt: function() {
        return defaultTreeSummarizePrompt;
    },
    messagesToHistoryStr: function() {
        return messagesToHistoryStr;
    }
});
const defaultTextQaPrompt = ({ context = "", query = "" })=>{
    return `Context information is below.
---------------------
${context}
---------------------
Given the context information and not prior knowledge, answer the query.
Query: ${query}
Answer:`;
};
const anthropicTextQaPrompt = ({ context = "", query = "" })=>{
    return `Context information:
<context>
${context}
</context>
Given the context information and not prior knowledge, answer the query.
Query: ${query}`;
};
const defaultSummaryPrompt = ({ context = "" })=>{
    return `Write a summary of the following. Try to use only the information provided. Try to include as many key details as possible.


${context}


SUMMARY:"""
`;
};
const anthropicSummaryPrompt = ({ context = "" })=>{
    return `Summarize the following text. Try to use only the information provided. Try to include as many key details as possible.
<original-text>
${context}
</original-text>

SUMMARY:
`;
};
const defaultRefinePrompt = ({ query = "", existingAnswer = "", context = "" })=>{
    return `The original query is as follows: ${query}
We have provided an existing answer: ${existingAnswer}
We have the opportunity to refine the existing answer (only if needed) with some more context below.
------------
${context}
------------
Given the new context, refine the original answer to better answer the query. If the context isn't useful, return the original answer.
Refined Answer:`;
};
const defaultTreeSummarizePrompt = ({ context = "", query = "" })=>{
    return `Context information from multiple sources is below.
---------------------
${context}
---------------------
Given the information from multiple sources and not prior knowledge, answer the query.
Query: ${query}
Answer:`;
};
const defaultChoiceSelectPrompt = ({ context = "", query = "" })=>{
    return `A list of documents is shown below. Each document has a number next to it along 
with a summary of the document. A question is also provided.
Respond with the numbers of the documents
you should consult to answer the question, in order of relevance, as well
as the relevance score. The relevance score is a number from 1-10 based on
how relevant you think the document is to the question.
Do not include any documents that are not relevant to the question.
Example format:
Document 1:
<summary of document 1>

Document 2:
<summary of document 2>

...

Document 10:\n<summary of document 10>

Question: <question>
Answer:
Doc: 9, Relevance: 7
Doc: 3, Relevance: 4
Doc: 7, Relevance: 3

Let's try this now:

${context}
Question: ${query}
Answer:`;
};
function buildToolsText(tools) {
    const toolsObj = tools.reduce((acc, tool)=>{
        acc[tool.name] = tool.description;
        return acc;
    }, {});
    return JSON.stringify(toolsObj, null, 4);
}
const exampleTools = [
    {
        name: "uber_10k",
        description: "Provides information about Uber financials for year 2021"
    },
    {
        name: "lyft_10k",
        description: "Provides information about Lyft financials for year 2021"
    }
];
const exampleQueryStr = `Compare and contrast the revenue growth and EBITDA of Uber and Lyft for year 2021`;
const exampleOutput = [
    {
        subQuestion: "What is the revenue growth of Uber",
        toolName: "uber_10k"
    },
    {
        subQuestion: "What is the EBITDA of Uber",
        toolName: "uber_10k"
    },
    {
        subQuestion: "What is the revenue growth of Lyft",
        toolName: "lyft_10k"
    },
    {
        subQuestion: "What is the EBITDA of Lyft",
        toolName: "lyft_10k"
    }
];
const defaultSubQuestionPrompt = ({ toolsStr = "", queryStr = "" })=>{
    return `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 1
<Tools>
\`\`\`json
${buildToolsText(exampleTools)}
\`\`\`

<User Question>
${exampleQueryStr}

<Output>
\`\`\`json
${JSON.stringify(exampleOutput, null, 4)}
\`\`\`

# Example 2
<Tools>
\`\`\`json
${toolsStr}
\`\`\`

<User Question>
${queryStr}

<Output>
`;
};
const defaultCondenseQuestionPrompt = ({ chatHistory = "", question = "" })=>{
    return `Given a conversation (between Human and Assistant) and a follow up message from Human, rewrite the message to be a standalone question that captures all relevant context from the conversation.

<Chat History>
${chatHistory}

<Follow Up Message>
${question}

<Standalone question>
`;
};
function messagesToHistoryStr(messages) {
    return messages.reduce((acc, message)=>{
        acc += acc ? "\n" : "";
        if (message.role === "user") {
            acc += `Human: ${message.content}`;
        } else {
            acc += `Assistant: ${message.content}`;
        }
        return acc;
    }, "");
}
const defaultContextSystemPrompt = ({ context = "" })=>{
    if (!context) return "";
    return `Context information is below.
---------------------
${context}
---------------------`;
};
const defaultKeywordExtractPrompt = ({ context = "", maxKeywords = 10 })=>{
    return `
Some text is provided below. Given the text, extract up to ${maxKeywords} keywords from the text. Avoid stopwords.
---------------------
${context}
---------------------
Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'
`;
};
const defaultQueryKeywordExtractPrompt = ({ question = "", maxKeywords = 10 })=>{
    return `(
  "A question is provided below. Given the question, extract up to ${maxKeywords} "
  "keywords from the text. Focus on extracting the keywords that we can use "
  "to best lookup answers to the question. Avoid stopwords."
  "---------------------"
  "${question}"
  "---------------------"
  "Provide keywords in the following comma-separated format: 'KEYWORDS: <keywords>'"
)`;
};
