Skip to content

Commit f4b1af2

Browse files
committed
fix: 0.6.4 — Docker/ollama compatibility & better error messages
- demo: read OLLAMA_BASE_URL env for Docker detection - MCP: compose_workflow reads AO_PROVIDER/AO_MODEL from env - ollama: friendly error on ECONNREFUSED (hint Docker config) - ollama: detect "model not found" and suggest `ollama pull`
1 parent 7d4ef07 commit f4b1af2

5 files changed

Lines changed: 34 additions & 21 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agency-orchestrator",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"description": "Multi-agent YAML workflow engine — 211 AI roles, auto DAG parallelism, zero code. One sentence → multiple AI roles collaborate → complete plan in minutes. 10 LLM providers, 7 need no API key.",
55
"keywords": [
66
"multi-agent",

src/cli/demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ export async function detectAvailableLLMs(): Promise<DetectedLLM[]> {
167167
try {
168168
const controller = new AbortController();
169169
const timeout = setTimeout(() => controller.abort(), 2000);
170-
const res = await fetch('http://localhost:11434/api/tags', {
170+
const ollamaUrl = process.env.OLLAMA_BASE_URL || 'http://localhost:11434';
171+
const res = await fetch(`${ollamaUrl.replace(/\/+$/, '')}/api/tags`, {
171172
signal: controller.signal,
172173
});
173174
clearTimeout(timeout);

src/connectors/ollama.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,36 @@ export class OllamaConnector implements LLMConnector {
1212
}
1313

1414
async chat(systemPrompt: string, userMessage: string, config: LLMConfig): Promise<LLMResult> {
15-
const response = await fetch(`${this.baseUrl}/api/chat`, {
16-
method: 'POST',
17-
headers: { 'Content-Type': 'application/json' },
18-
body: JSON.stringify({
19-
model: config.model || 'llama3.1',
20-
messages: [
21-
{ role: 'system', content: systemPrompt },
22-
{ role: 'user', content: userMessage },
23-
],
24-
stream: false,
25-
options: {
26-
num_predict: config.max_tokens || 2048,
27-
},
28-
}),
29-
});
15+
let response: Response;
16+
try {
17+
response = await fetch(`${this.baseUrl}/api/chat`, {
18+
method: 'POST',
19+
headers: { 'Content-Type': 'application/json' },
20+
body: JSON.stringify({
21+
model: config.model || 'llama3.1',
22+
messages: [
23+
{ role: 'system', content: systemPrompt },
24+
{ role: 'user', content: userMessage },
25+
],
26+
stream: false,
27+
options: {
28+
num_predict: config.max_tokens || 2048,
29+
},
30+
}),
31+
});
32+
} catch (err: any) {
33+
if (err?.cause?.code === 'ECONNREFUSED' || err?.message?.includes('ECONNREFUSED')) {
34+
throw new Error(`无法连接 Ollama (${this.baseUrl}),请确认 ollama 已启动。Docker 环境请设置 OLLAMA_BASE_URL=http://host.docker.internal:11434`);
35+
}
36+
throw err;
37+
}
3038

3139
if (!response.ok) {
3240
const text = await response.text();
41+
if (response.status === 404 && text.includes('not found')) {
42+
const model = config.model || 'llama3.1';
43+
throw new Error(`Ollama 模型 "${model}" 未找到,请先运行: ollama pull ${model}`);
44+
}
3345
throw new Error(`Ollama error ${response.status}: ${text}`);
3446
}
3547

src/mcp/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,14 @@ export async function startServer(verbose = false): Promise<void> {
269269
async ({ description, provider, model }) => {
270270
try {
271271
const agentsDir = findAgentsDir();
272-
const llmProvider = provider || 'deepseek';
272+
const llmProvider = provider || process.env.AO_PROVIDER as any || 'deepseek';
273273
const defaultModels: Record<string, string> = {
274274
deepseek: 'deepseek-chat',
275275
claude: 'claude-sonnet-4-20250514',
276276
openai: 'gpt-4o',
277277
ollama: 'llama3',
278278
};
279-
const llmModel = model || defaultModels[llmProvider] || 'gpt-4o';
279+
const llmModel = model || process.env.AO_MODEL || defaultModels[llmProvider] || 'gpt-4o';
280280

281281
const result = await silentCall(() =>
282282
composeWorkflow({

0 commit comments

Comments
 (0)