01.AI는 Dr. Kai-Fu Lee가 설립한 AI 2.0의 최전선에 있는 글로벌 기업입니다. 6B부터 수천억 개의 parameter에 이르는 Yi 시리즈를 포함한 최첨단 large language model을 제공합니다. 01.AI는 또한 multimodal model, open API platform, 그리고 Yi-34B/9B/6B 및 Yi-VL과 같은 open-source 옵션을 제공합니다.
Copy
## Installing the langchain packages needed to use the integrationpip install -qU langchain-community
import osos.environ["YI_API_KEY"] = "YOUR_API_KEY"from langchain_community.llms import YiLLM# Load the modelllm = YiLLM(model="yi-large")# You can specify the region if needed (default is "auto")# llm = YiLLM(model="yi-large", region="domestic") # or "international"# Basic usageres = llm.invoke("What's your name?")print(res)
Copy
# Generate methodres = llm.generate( prompts=[ "Explain the concept of large language models.", "What are the potential applications of AI in healthcare?", ])print(res)
Copy
# Streamingfor chunk in llm.stream("Describe the key features of the Yi language model series."): print(chunk, end="", flush=True)
Copy
# Asynchronous streamingimport asyncioasync def run_aio_stream(): async for chunk in llm.astream( "Write a brief on the future of AI according to Dr. Kai-Fu Lee's vision." ): print(chunk, end="", flush=True)asyncio.run(run_aio_stream())
Copy
# Adjusting parametersllm_with_params = YiLLM( model="yi-large", temperature=0.7, top_p=0.9,)res = llm_with_params( "Propose an innovative AI application that could benefit society.")print(res)