logo
OpenAI
repo-copy-icon

copied

Browse Source

Update README

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 1 year ago
parent
commit
c645bfdd87
  1. 35
      README.md

35
README.md

@ -34,6 +34,41 @@ 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 = '''Use the following pieces of context to answer the question at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
{context}
Question: {question}
Helpful Answer:
'''
docs = ['You can install towhee via command `pip install towhee`.']
history = [
('What is Towhee?', 'Towhee is an open-source machine learning pipeline that helps you encode your unstructured data into embeddings.')
]
question = 'How to install it?'
p = (
pipe.input('question', 'docs', 'history')
.map(('question', 'docs', 'history'), 'prompt', ops.prompt.template(temp, ['question', 'context']))
.map('prompt', 'answer',
ops.LLM.OpenAI(api_key=OPENAI_API_KEY, temperature=0.5, max_tokens=100)
)
.output('answer')
)
answer = p(question, docs, history).get()[0]
```
<br />
## Factory Constructor

Loading…
Cancel
Save