logo
Ernie
repo-copy-icon

copied

Browse Source

Add pipeline example

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 2 years ago
parent
commit
97899aba74
  1. 36
      README.md

36
README.md

@ -23,7 +23,7 @@ from towhee import pipe, ops
p = (
pipe.input('messages')
.map('messages', 'answer', ops.LLM.Ernie(api_key=ERNIE_API_KEY, secret_key=ERNIE_SECRET_KEY))
.map('messages', 'answer', ops.LLM.Ernie(api_key=ERNIE_API_KEY, secret_key=ERNIE_SECRET_KEY, temperature=0.5))
.output('answer')
)
@ -34,6 +34,38 @@ messages=[
answer = p(messages).get()[0]
```
*Write a [retrieval-augmented generation pipeline](https://towhee.io/tasks/detail/pipeline/retrieval-augmented-generation) with explicit inputs/outputs name specifications:*
```python
from towhee import pipe, ops
temp = '''根据以下材料回答最末尾的问题:
{context}
问题:{question}
'''
docs = ['你可以通过`pip install towhee` 安装 Towhee。']
history = [
('什么是 Towhee?', 'Towhee 是一个开源项目,可以将非结构化数据转换为向量。')
]
question = '怎么安装它?'
p = (
pipe.input('question', 'docs', 'history')
.map(('question', 'docs', 'history'), 'prompt', ops.prompt.template(temp, ['question', 'context']))
.map('prompt', 'answer',
ops.LLM.Ernie(api_key=ERNIE_API_KEY, secret_key=ERNIE_SECRET_KEY)
)
.output('answer')
)
answer = p(question, docs, history).get()[0]
```
<br />
## Factory Constructor 接口说明
@ -55,7 +87,7 @@ The Ernie Secret key in string, defaults to None. If None, it will use the envir
***\*\*kwargs***
Other OpenAI parameters such as temperature, etc.
Other Ernie parameters such as temperature, etc.
<br />

Loading…
Cancel
Save