大模型
dev.to ·
@Shakar Bisetty
用 host.docker.internal 让 Mule 访问本地 Ollama
文章记录了一个具体排错过程:MuleSoft Inference Connector 使用 http://localhost:11434/v1 作为 base URL 访问本地 Ollama 时报连接拒绝,改用 host.docker.internal 后成功。文中给出了可运行的 Mule XML 配置片段和文本生成请求示例,对在 Mule 中集成本地 Ollama 的开发者有直接参考价值。
AI推荐理由 文章解决一个具体工程问题:在 MuleSoft Inference Connector 中配置 http://localhost:11434/v1 访问本地 Ollama 时出现连接拒绝,改用 host.docker.internal 后成功。给出了可运行的 XML 配置片段和请求示例,对使用 Mule 集成本地 Ollama 的开发者有直接参考价值。内容范围较窄,属于操作型排错记录,未涉及性能或安全讨论。
60
正文
Problem
The flow failed with a connection refused error when the configuration used http://localhost:11434/v1 as the base URL. The MuleSoft Inference Connector enables text generation workflows docs.
Input
{
"prompt": "Reply with exactly one word: pong"
}
Enter fullscreen mode
Exit fullscreen mode
Working configuration
#[payload.prompt]
Enter fullscreen mode
Exit fullscreen mode
Output
{"response": {"response": "Pong"}, "status": 200}
Enter fullscreen mode
Exit fullscreen mode
The response field contains the model output, and status shows 200.
The trap
Using http://localhost:11434/v1 as the base URL causes a connection refused error.
What I do now
I configure openAICompatibleURL to http://host.docker.internal:11434/v1 in the connector configuration.
Runs shown: Mule 4 Community kernel 4.12.0
104 DataWeave patterns + 8 Exchange modules with 208 MUnit tests: github.com/shakarbisetty/mulesoft-cookbook | 60-second walkthroughs: youtube.com/@SanThaParv