From 58c448d0daaba54fd17ff35626a5c23c0f03415b Mon Sep 17 00:00:00 2001 From: "junjie.jiang" Date: Mon, 29 May 2023 20:09:16 +0800 Subject: [PATCH] Update docs Signed-off-by: junjie.jiang --- README.md | 2 +- qa_prompt.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 984e27a..fc723ed 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ p = ( an1 = p('Tell me something about Towhee', [towhee_docs], []).get()[0] -an2 = p('Give an example', [towhee_docs], [{'question': 'Tell me something about Towhee', 'answer': an1}]).get()[0] +an2 = p('Give an example', [towhee_docs], [('Tell me something about Towhee', an1)]).get()[0] ``` diff --git a/qa_prompt.py b/qa_prompt.py index 213dc25..bb5ad4e 100644 --- a/qa_prompt.py +++ b/qa_prompt.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Dict +from typing import List, Tuple, Dict, Optional class QAPrompt: @@ -16,7 +16,11 @@ Question: {question} Helpful Answer:' """ - def __call__(self, question: str, docs: List[str], history=None) -> List[Dict[str, str]]: + def __call__(self, question: str, docs: List[str], history=Optional[List[Tuple]]) -> List[Dict[str, str]]: + """ + history: + List[Tuple]: [(question1, answer1), (question2, answer2)] + """ context = '\n'.join(docs) prompt_str = self._template.format(context=context, question=question) ret = [{'question': prompt_str}]