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