From 23e1777abce22008d012362aca76d21b8ecd9860 Mon Sep 17 00:00:00 2001 From: "junjie.jiang" Date: Mon, 29 May 2023 20:01:49 +0800 Subject: [PATCH] Update readme Signed-off-by: junjie.jiang --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/README.md b/README.md index e675411..984e27a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,51 @@ # question-answer +
+ + + +## Desription + +Prompt to answer a question. + + +
+ + + +## Code Example + +### Example + + +```python + +from towhee import ops, pipe +import requests + +towhee_docs = requests.get('https://raw.githubusercontent.com/towhee-io/towhee/main/README.md').context + + +p = ( + pipe.input('question', 'docs', 'history') + .map(('question', 'docs', 'history'), 'prompt', ops.prompt.question_answer()) + .map('prompt', 'answer', ops.LLM.OpenAI()) + .output('answer') +) + +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] + +``` + +## Factory Constructor + +Create the operator via the following factory method: + +***ops.prompt.question_answer()*** + +
+ + +**Returns:** *List[Dict]* \ No newline at end of file