From 4ae8e063786e5ee27926837de9b587299f9f1b17 Mon Sep 17 00:00:00 2001 From: ChengZi Date: Fri, 20 Oct 2023 14:13:17 +0800 Subject: [PATCH] update readme Signed-off-by: ChengZi --- README.md | 20 ++++++++++---------- ernie_chat.py | 4 ++-- requirements.txt | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 87b1774..777a965 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ ## Description 描述 A LLM operator generates answer given prompt in messages using a large language model or service. -This operator is implemented with Ernie Bot from [Baidu](https://cloud.baidu.com/wenxin.html). -Please note you will need [Ernie API key & Secret key](https://ai.baidu.com/ai-doc/REFERENCE/Lkru0zoz4) to access the service. +This operator is implemented with [Ernie Bot SDK from Baidu](https://github.com/PaddlePaddle/ERNIE-Bot-SDK). +Please note you will need [EB_API_TYPE & EB_ACCESS_TOKEN](https://github.com/PaddlePaddle/ERNIE-Bot-SDK/blob/develop/docs/authentication.md) to access the service. -LLM 算子使用大语言模型或服务,为输入的问题或提示生成答案。LLM/Ernie 利用了来自百度的[文心一言](https://cloud.baidu.com/wenxin.html)。请注意,您需要[文心一言服务的 API Key 和 Secret Key](https://ai.baidu.com/ai-doc/REFERENCE/Lkru0zoz4)才能访问该服务。 +LLM 算子使用大语言模型或服务,为输入的问题或提示生成答案。LLM/Ernie 利用了来自百度的[Ernie Bot SDK](https://github.com/PaddlePaddle/ERNIE-Bot-SDK) 。请注意,您需要文心一言服务的 [EB_API_TYPE & EB_ACCESS_TOKEN](https://github.com/PaddlePaddle/ERNIE-Bot-SDK/blob/develop/docs/authentication.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, temperature=0.5)) + .map('messages', 'answer', ops.LLM.Ernie(api_type=EB_API_TYPE, access_token=EB_ACCESS_TOKEN)) .output('answer') ) @@ -58,7 +58,7 @@ 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) + ops.LLM.Ernie(api_type=EB_API_TYPE, access_token=EB_ACCESS_TOKEN) ) .output('answer') ) @@ -72,18 +72,18 @@ answer = p(question, docs, history).get()[0] Create the operator via the following factory method: -***LLM.Ernie(api_key: str, secret_key: str)*** +***LLM.Ernie(api_type: str, access_token: str)*** **Parameters:** -***api_key***: *str=None* +***api_type***: *str=None* -The Ernie API key in string, defaults to None. If None, it will use the environment variable `ERNIE_API_KEY`. +The API type in string, defaults to None. If None, it will use the environment variable `EB_API_TYPE`. Refer to [authentication](https://github.com/PaddlePaddle/ERNIE-Bot-SDK/blob/develop/docs/authentication.md) for more details. -***secret_key***: *str=None* +***access_token***: *str=None* -The Ernie Secret key in string, defaults to None. If None, it will use the environment variable `ERNIE_SECRET_KEY`. +The access token in string, defaults to None. If None, it will use the environment variable `EB_ACCESS_TOKEN`. Refer to [authentication](https://github.com/PaddlePaddle/ERNIE-Bot-SDK/blob/develop/docs/authentication.md) for more details. ***\*\*kwargs*** diff --git a/ernie_chat.py b/ernie_chat.py index 654da56..e2df888 100644 --- a/ernie_chat.py +++ b/ernie_chat.py @@ -29,8 +29,8 @@ class ErnieChat(PyOperator): access_token: str = None, **kwargs ): - erniebot.api_type = api_type or os.getenv('ERNIEBOT_API_TYPE') - erniebot.access_token = access_token or os.getenv('ERNIEBOT_ACCESS_TOKEN') + erniebot.api_type = api_type or os.getenv('EB_API_TYPE') + erniebot.access_token = access_token or os.getenv('EB_ACCESS_TOKEN') self._model = model_name self.stream = kwargs.pop('stream') if 'stream' in kwargs else False self.kwargs = kwargs diff --git a/requirements.txt b/requirements.txt index 663bd1f..2cc426b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -requests \ No newline at end of file +requests +erniebot \ No newline at end of file