From c689949ecc7c519a431af3bb83d67a50380f89da Mon Sep 17 00:00:00 2001 From: "junjie.jiang" Date: Wed, 31 May 2023 20:00:10 +0800 Subject: [PATCH] Unifiy prompt params Signed-off-by: junjie.jiang --- README.md | 4 ++-- qa_prompt.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 045f768..f7f8c18 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ p = ( .output('answer') ) -an1 = p('Tell me something about Towhee', [towhee_docs], []).get()[0] +an1 = p('Tell me something about Towhee', towhee_docs, []).get()[0] -an2 = p('Give an example', [towhee_docs], [('Tell me something about Towhee', 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 26af6e9..7853567 100644 --- a/qa_prompt.py +++ b/qa_prompt.py @@ -38,12 +38,11 @@ class QAPrompt(PyOperator): logger.warning('Unkown llm_name, use default prompt') self._template = gpt_prompt - def __call__(self, question: str, docs: List[str], history=Optional[List[Tuple]]) -> List[Dict[str, str]]: + def __call__(self, question: str, context: 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}] if not isinstance(history, list):