Browse Source
Update docs
Signed-off-by: junjie.jiang <junjie.jiang@zilliz.com>
main
2 changed files with
7 additions and
3 deletions
-
README.md
-
qa_prompt.py
|
|
@ -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] |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
@ -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}] |
|
|
|