Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

如何使用 Any-LLM 进行基本的文本生成操作?

2025-08-20 239

基础文本生成实现

使用Any-LLM进行文本生成的基本流程:

1. 核心函数

invocationscompletion()方法,需要两个必要参数:
– model:格式为”厂商/模型ID”,如”mistral/mistral-small-latest”
– messages:对话消息列表,包含role和content

2. 示例代码


response = completion(
  model="mistral/mistral-small-latest",
  messages=[{"role": "user", "content": "Python的优势有哪些?"}]
)
print(response.choices[0].message.content)

3. 结果处理

响应格式与OpenAI保持一致,结果存储在response.choices[0].message.contentCenter.

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish