logo
Browse Source

Update docs

Signed-off-by: junjie.jiang <junjie.jiang@zilliz.com>
main
junjie.jiang 1 year ago
parent
commit
58c448d0da
  1. 2
      README.md
  2. 8
      qa_prompt.py

2
README.md

@ -35,7 +35,7 @@ p = (
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], [{'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]
``` ```

8
qa_prompt.py

@ -1,4 +1,4 @@
from typing import List, Tuple, Dict
from typing import List, Tuple, Dict, Optional
class QAPrompt: class QAPrompt:
@ -16,7 +16,11 @@ Question: {question}
Helpful Answer:' 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) context = '\n'.join(docs)
prompt_str = self._template.format(context=context, question=question) prompt_str = self._template.format(context=context, question=question)
ret = [{'question': prompt_str}] ret = [{'question': prompt_str}]

Loading…
Cancel
Save