community[minor]: integrate with model Yuan2.0 (#15411)

1. integrate with
[`Yuan2.0`](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/README-EN.md)
2. update `langchain.llms`
3. add a new doc for [Yuan2.0
integration](docs/docs/integrations/llms/yuan2.ipynb)

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
wulixuan
2024-02-15 03:46:20 +08:00
committed by GitHub
parent d07db457fc
commit c776cfc599
6 changed files with 354 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
"""Test Yuan2.0 API wrapper."""
from langchain_core.outputs import LLMResult
from langchain_community.llms import Yuan2
def test_yuan2_call_method() -> None:
"""Test valid call to Yuan2.0."""
llm = Yuan2(
infer_api="http://127.0.0.1:8000/yuan",
max_tokens=1024,
temp=1.0,
top_p=0.9,
top_k=40,
use_history=False,
)
output = llm("写一段快速排序算法。")
assert isinstance(output, str)
def test_yuan2_generate_method() -> None:
"""Test valid call to Yuan2.0 inference api."""
llm = Yuan2(
infer_api="http://127.0.0.1:8000/yuan",
max_tokens=1024,
temp=1.0,
top_p=0.9,
top_k=40,
use_history=False,
)
output = llm.generate(["who are you?"])
assert isinstance(output, LLMResult)
assert isinstance(output.generations, list)