mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 03:26:17 +00:00
docs: Fix QianfanLLMEndpoint and Tongyi input text (#25529)
- **Description:** Fix `QianfanLLMEndpoint` and `Tongyi` input text.
This commit is contained in:
@@ -69,30 +69,26 @@ class QianfanLLMEndpoint(LLM):
|
|||||||
Invoke:
|
Invoke:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
messages = [
|
input_text = "用50个字左右阐述,生命的意义在于"
|
||||||
("system", "你是一名专业的翻译家,可以将用户的中文翻译为英文。"),
|
llm.invoke(input_text)
|
||||||
("human", "我喜欢编程。"),
|
|
||||||
]
|
|
||||||
llm.invoke(messages)
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
'I like programming.'
|
'生命的意义在于体验、成长、爱与被爱、贡献与传承,以及对未知的勇敢探索与自我超越。'
|
||||||
|
|
||||||
Stream:
|
Stream:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
for chunk in llm.stream(messages):
|
for chunk in llm.stream(input_text):
|
||||||
print(chunk)
|
print(chunk)
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
I like
|
生命的意义 | 在于不断探索 | 与成长 | ,实现 | 自我价值,| 给予爱 | 并接受 | 爱, | 在经历 | 中感悟 | ,让 | 短暂的存在 | 绽放出无限 | 的光彩 | 与温暖 | 。
|
||||||
programming.
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
stream = llm.stream(messages)
|
stream = llm.stream(input_text)
|
||||||
full = next(stream)
|
full = next(stream)
|
||||||
for chunk in stream:
|
for chunk in stream:
|
||||||
full += chunk
|
full += chunk
|
||||||
@@ -100,23 +96,23 @@ class QianfanLLMEndpoint(LLM):
|
|||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
'I like programming.'
|
'生命的意义在于探索、成长、爱与被爱、贡献价值、体验世界之美,以及在有限的时间里追求内心的平和与幸福。'
|
||||||
|
|
||||||
Async:
|
Async:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
await llm.ainvoke(messages)
|
await llm.ainvoke(input_text)
|
||||||
|
|
||||||
# stream:
|
# stream:
|
||||||
# async for chunk in llm.astream(messages):
|
# async for chunk in llm.astream(input_text):
|
||||||
# print(chunk)
|
# print(chunk)
|
||||||
|
|
||||||
# batch:
|
# batch:
|
||||||
# await llm.abatch([messages])
|
# await llm.abatch([input_text])
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
'I like programming.'
|
'生命的意义在于探索、成长、爱与被爱、贡献社会,在有限的时间里追寻无限的可能,实现自我价值,让生活充满色彩与意义。'
|
||||||
|
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
|
|
||||||
|
@@ -199,44 +199,38 @@ class Tongyi(BaseLLM):
|
|||||||
Invoke:
|
Invoke:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
messages = [
|
input_text = "用50个字左右阐述,生命的意义在于"
|
||||||
("system", "你是一名专业的翻译家,可以将用户的中文翻译为英文。"),
|
llm.invoke(input_text)
|
||||||
("human", "我喜欢编程。"),
|
|
||||||
]
|
|
||||||
llm.invoke(messages)
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
'I enjoy programming.'
|
'探索、成长、连接与爱——在有限的时间里,不断学习、体验、贡献并寻找与世界和谐共存之道,让每一刻充满价值与意义。'
|
||||||
|
|
||||||
Stream:
|
Stream:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
for chunk in llm.stream(messages):
|
for chunk in llm.stream(input_text):
|
||||||
print(chunk)
|
print(chunk)
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
I
|
探索 | 、 | 成长 | 、连接与爱。 | 在有限的时间里,寻找个人价值, | 贡献于他人,共同体验世界的美好 | ,让世界因自己的存在而更 | 温暖。
|
||||||
enjoy
|
|
||||||
programming
|
|
||||||
.
|
|
||||||
|
|
||||||
Async:
|
Async:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
await llm.ainvoke(messages)
|
await llm.ainvoke(input_text)
|
||||||
|
|
||||||
# stream:
|
# stream:
|
||||||
# async for chunk in llm.astream(messages):
|
# async for chunk in llm.astream(input_text):
|
||||||
# print(chunk)
|
# print(chunk)
|
||||||
|
|
||||||
# batch:
|
# batch:
|
||||||
# await llm.abatch([messages])
|
# await llm.abatch([input_text])
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
'I enjoy programming.'
|
'探索、成长、连接与爱。在有限的时间里,寻找个人价值,贡献于他人和社会,体验丰富多彩的情感与经历,不断学习进步,让世界因自己的存在而更美好。'
|
||||||
|
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user