Skip navigation links

Package cn.hutool.ai.model.ollama

对Ollama的封装实现.

See: Description

Package cn.hutool.ai.model.ollama Description

对Ollama的封装实现.

使用方法: // 创建AI服务


 OllamaService aiService = AIServiceFactory.getAIService(
 new AIConfigBuilder(ModelName.OLLAMA.getValue())
 .setApiUrl("http://localhost:11434")
 .setModel("qwen2.5-coder:32b")
 .build(),
 OllamaService.class
 );

 // 构造上下文
 List<Message> messageList=new ArrayList<>();
 messageList.add(new Message("system","你是一个疯疯癫癫的机器人"));
 messageList.add(new Message("user","你能帮我做什么"));

 // 输出对话结果
 Console.log(aiService.chat(messageList));
 
Since:
5.8.40
Author:
yangruoyu-yumeisoft
Skip navigation links

Copyright © 2025. All rights reserved.