logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 1 year ago

prompt

question-answer


Desription

Prompt to answer a question.


Code Example

Example


from towhee import ops, pipe
import requests

towhee_docs = requests.get('https://raw.githubusercontent.com/towhee-io/towhee/main/README.md').content


p = (
    pipe.input('question', 'docs', 'history')
    .map('docs', 'docs', lambda x: x[:2000])
    .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]
print(an1)

an2 = p('How to use it', towhee_docs, [('Tell me something about Towhee', an1)]).get()[0]
print(an2)

Factory Constructor

Create the operator via the following factory method:

ops.prompt.question_answer()

Args:

Args:

temp: str

User-defined prompt, must contain {context} and {question}"

llm_name: str

Pre-defined prompt, currently supports openai and dolly, openai prompt is used by default."


Returns: List[Dict]

junjie.jiang a1f281ce61 Add ernie_prompt 11 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 1 year ago
file-icon README.md
1.1 KiB
download-icon
Update readme 1 year ago
file-icon __init__.py
130 B
download-icon
Add dolly prompt 1 year ago
file-icon qa_prompt.py
2.3 KiB
download-icon
Add ernie_prompt 1 year ago