Skip to content

Commit 3ba3efd

Browse files
committed
feat(providers): add local ollama support for the ballerina-interpreter
1 parent a1ec3b7 commit 3ba3efd

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

ballerina-interpreter/Dependencies.toml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[ballerina]
77
dependencies-toml-version = "2"
8-
distribution-version = "2201.12.10"
8+
distribution-version = "2201.13.4"
99

1010
[[package]]
1111
org = "ballerina"
@@ -77,7 +77,7 @@ dependencies = [
7777
[[package]]
7878
org = "ballerina"
7979
name = "crypto"
80-
version = "2.11.0"
80+
version = "2.12.1"
8181
dependencies = [
8282
{org = "ballerina", name = "jballerina.java"},
8383
{org = "ballerina", name = "time"}
@@ -115,7 +115,7 @@ modules = [
115115
[[package]]
116116
org = "ballerina"
117117
name = "file"
118-
version = "1.12.0"
118+
version = "1.13.0"
119119
dependencies = [
120120
{org = "ballerina", name = "io"},
121121
{org = "ballerina", name = "jballerina.java"},
@@ -129,7 +129,7 @@ modules = [
129129
[[package]]
130130
org = "ballerina"
131131
name = "http"
132-
version = "2.14.11"
132+
version = "2.16.3"
133133
dependencies = [
134134
{org = "ballerina", name = "auth"},
135135
{org = "ballerina", name = "cache"},
@@ -286,7 +286,7 @@ dependencies = [
286286
[[package]]
287287
org = "ballerina"
288288
name = "log"
289-
version = "2.14.0"
289+
version = "2.17.0"
290290
dependencies = [
291291
{org = "ballerina", name = "io"},
292292
{org = "ballerina", name = "jballerina.java"},
@@ -315,7 +315,7 @@ dependencies = [
315315
[[package]]
316316
org = "ballerina"
317317
name = "mime"
318-
version = "2.12.1"
318+
version = "2.12.2"
319319
dependencies = [
320320
{org = "ballerina", name = "io"},
321321
{org = "ballerina", name = "jballerina.java"},
@@ -326,7 +326,7 @@ dependencies = [
326326
[[package]]
327327
org = "ballerina"
328328
name = "oauth2"
329-
version = "2.14.1"
329+
version = "2.15.0"
330330
dependencies = [
331331
{org = "ballerina", name = "cache"},
332332
{org = "ballerina", name = "crypto"},
@@ -339,7 +339,7 @@ dependencies = [
339339
[[package]]
340340
org = "ballerina"
341341
name = "observe"
342-
version = "1.6.0"
342+
version = "1.7.1"
343343
dependencies = [
344344
{org = "ballerina", name = "jballerina.java"}
345345
]
@@ -368,7 +368,7 @@ dependencies = [
368368
[[package]]
369369
org = "ballerina"
370370
name = "task"
371-
version = "2.11.1"
371+
version = "2.11.2"
372372
dependencies = [
373373
{org = "ballerina", name = "jballerina.java"},
374374
{org = "ballerina", name = "time"},
@@ -392,7 +392,7 @@ modules = [
392392
[[package]]
393393
org = "ballerina"
394394
name = "time"
395-
version = "2.8.1"
395+
version = "2.8.0"
396396
dependencies = [
397397
{org = "ballerina", name = "jballerina.java"}
398398
]
@@ -422,7 +422,7 @@ dependencies = [
422422
[[package]]
423423
org = "ballerina"
424424
name = "websub"
425-
version = "2.14.0"
425+
version = "2.15.0"
426426
dependencies = [
427427
{org = "ballerina", name = "crypto"},
428428
{org = "ballerina", name = "http"},
@@ -442,7 +442,7 @@ modules = [
442442
[[package]]
443443
org = "ballerina"
444444
name = "websubhub"
445-
version = "1.15.2"
445+
version = "1.16.0"
446446
scope = "testOnly"
447447
dependencies = [
448448
{org = "ballerina", name = "crypto"},
@@ -500,6 +500,21 @@ modules = [
500500
{org = "ballerinax", packageName = "ai.anthropic", moduleName = "ai.anthropic"}
501501
]
502502

503+
[[package]]
504+
org = "ballerinax"
505+
name = "ai.ollama"
506+
version = "1.2.3"
507+
dependencies = [
508+
{org = "ballerina", name = "ai"},
509+
{org = "ballerina", name = "data.jsondata"},
510+
{org = "ballerina", name = "http"},
511+
{org = "ballerina", name = "jballerina.java"},
512+
{org = "ballerina", name = "lang.array"}
513+
]
514+
modules = [
515+
{org = "ballerinax", packageName = "ai.ollama", moduleName = "ai.ollama"}
516+
]
517+
503518
[[package]]
504519
org = "ballerinax"
505520
name = "ai.openai"
@@ -564,6 +579,7 @@ dependencies = [
564579
{org = "ballerina", name = "websubhub"},
565580
{org = "ballerinai", name = "observe"},
566581
{org = "ballerinax", name = "ai.anthropic"},
582+
{org = "ballerinax", name = "ai.ollama"},
567583
{org = "ballerinax", name = "ai.openai"}
568584
]
569585
modules = [

ballerina-interpreter/agent.bal

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import ballerina/os;
2222
import ballerina/http;
2323
import ballerinax/ai.anthropic;
2424
import ballerinax/ai.openai;
25-
25+
import ballerinax/ai.ollama;
2626
function createAgent(AFMRecord afmRecord, string afmFileDir) returns ai:Agent|error {
2727
AFMRecord {metadata, role, instructions} = afmRecord;
2828

@@ -127,6 +127,15 @@ function getModel(Model? model) returns ai:ModelProvider|error {
127127
model.url ?: "https://api.anthropic.com/v1"
128128
);
129129
}
130+
"ollama" => {
131+
return new ollama:ModelProvider(
132+
check name.ensureType(),
133+
model.url ?: "http://localhost:11434"
134+
);
135+
}
136+
"gemini" => {
137+
return error("Gemini model is not yet supported by the Ballerina interpreter");
138+
}
130139
}
131140
return error(string `Model provider: ${provider} not yet supported`);
132141
}

0 commit comments

Comments
 (0)