logo
Browse Source

Unifiy prompt params

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

4
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]
```

3
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):

Loading…
Cancel
Save