Skip to content

Commit 603526a

Browse files
authored
Merge pull request #8 from Rutik7066/main
feat: ollama full support for golem and wasm
2 parents 3ba4064 + 9fbae33 commit 603526a

File tree

32 files changed

+2166
-236
lines changed

32 files changed

+2166
-236
lines changed

.github/workflows/ci.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,76 @@ jobs:
8484
run: cargo binstall --force --locked cargo-component@0.20.0
8585
- name: Build all test components
8686
run: cargo make build-test-components
87+
ollama-integration-tests:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: actions/cache@v3
92+
with:
93+
path: |
94+
~/.cargo/bin/
95+
~/.cargo/registry/index/
96+
~/.cargo/registry/cache/
97+
~/.cargo/git/db/
98+
target/
99+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-ollama-integration
100+
- name: Setup Rust
101+
uses: actions-rs/toolchain@v1
102+
with:
103+
toolchain: stable
104+
override: true
105+
- uses: davidB/rust-cargo-make@v1
106+
- uses: cargo-bins/cargo-binstall@main
107+
- name: Install tools
108+
run: |
109+
set -e
110+
cargo binstall --force --locked cargo-component@0.20.0
111+
cargo binstall golem-cli@1.2.2-dev.11 --locked --force --no-confirm
112+
cargo binstall wac-cli --locked --force --no-confirm
113+
- name: Start Ollama in Docker
114+
run: |
115+
set -e
116+
docker run -d --name ollama -p 11434:11434 ollama/ollama:latest
117+
timeout 60 bash -c 'until curl -f http://localhost:11434/api/version; do sleep 2; done'
118+
echo "Pulling Qwen2.5:1.5b"
119+
docker exec ollama ollama pull qwen2.5:1.5b
120+
echo "Pulling Gemma2:2b"
121+
docker exec ollama ollama pull gemma2:2b
122+
echo "Verifying models are available"
123+
docker exec ollama ollama list | grep -q "qwen2.5:1.5b" || exit 1
124+
docker exec ollama ollama list | grep -q "gemma2:2b" || exit 1
125+
echo "Ollama setup completed."
126+
- name: Install and Run latest Golem Server
127+
run: |
128+
set -e
129+
echo "Installing Golem server"
130+
sudo curl -L https://github.com/golemcloud/golem-cli/releases/download/v1.2.3/golem-x86_64-unknown-linux-gnu -o ./golem
131+
sudo chmod +x ./golem
132+
sudo mv ./golem /usr/local/bin/golem
133+
golem --version
134+
golem profile switch local
135+
nohup golem server run >golem-server.log 2>&1 &
136+
echo "Golem server started."
137+
- name: Build and test Ollama integration
138+
run: |
139+
set -e
140+
cargo make build-ollama
141+
cd test
142+
golem-cli app build -b ollama-debug
143+
golem-cli app deploy -b ollama-debug
144+
golem-cli worker new -e GOLEM_OLLAMA_BASE_URL=http://localhost:11434 test:llm/ollama-1
145+
golem-cli worker invoke test:llm/ollama-1 test1
146+
golem-cli worker invoke test:llm/ollama-1 test2
147+
golem-cli worker invoke test:llm/ollama-1 test3
148+
golem-cli worker invoke test:llm/ollama-1 test4
149+
golem-cli worker invoke test:llm/ollama-1 test5
150+
golem-cli worker invoke test:llm/ollama-1 test6
151+
golem-cli worker invoke test:llm/ollama-1 test7
87152
publish-all:
88153
needs:
89154
- tests
90155
- build-test-components
156+
- ollama-integration-tests
91157
runs-on: ubuntu-latest
92158
permissions:
93159
contents: write

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[workspace]
22
resolver = "2"
33

4-
members = ["llm", "llm-anthropic", "llm-grok", "llm-openai", "llm-openrouter"]
4+
members = ["llm", "llm-anthropic", "llm-grok", "llm-ollama", "llm-openai", "llm-openrouter"]
55

66
[profile.release]
77
debug = false

Makefile.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ args = ["clean"]
1010
command = "cargo"
1111
args = ["test"]
1212

13+
[tasks.build-ollama]
14+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
15+
command = "cargo-component"
16+
args = ["build", "-p", "golem-llm-ollama"]
17+
18+
19+
[tasks.build-ollama-portable]
20+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
21+
command = "cargo-component"
22+
args = ["build", "-p", "golem-llm-ollama", "--no-default-features"]
23+
24+
1325
[tasks.build-anthropic]
1426
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
1527
command = "cargo-component"
@@ -56,6 +68,7 @@ dependencies = [
5668
"build-grok",
5769
"build-openai",
5870
"build-openrouter",
71+
"build-ollama",
5972
]
6073

6174
[tasks.build-portable]
@@ -64,6 +77,7 @@ dependencies = [
6477
"build-grok-portable",
6578
"build-openai-portable",
6679
"build-openrouter-portable",
80+
"build-ollama-portable",
6781
]
6882

6983
[tasks.build-all]
@@ -78,6 +92,7 @@ cp target/wasm32-wasip1/debug/golem_llm_anthropic.wasm components/debug/golem_ll
7892
cp target/wasm32-wasip1/debug/golem_llm_grok.wasm components/debug/golem_llm_grok.wasm
7993
cp target/wasm32-wasip1/debug/golem_llm_openai.wasm components/debug/golem_llm_openai.wasm
8094
cp target/wasm32-wasip1/debug/golem_llm_openrouter.wasm components/debug/golem_llm_openrouter.wasm
95+
cp target/wasm32-wasip1/debug/golem_llm_ollama.wasm components/debug/golem_llm_ollama.wasm
8196
8297
cm_run_task clean
8398
cm_run_task build-portable
@@ -86,8 +101,20 @@ cp target/wasm32-wasip1/debug/golem_llm_anthropic.wasm components/debug/golem_ll
86101
cp target/wasm32-wasip1/debug/golem_llm_grok.wasm components/debug/golem_llm_grok-portable.wasm
87102
cp target/wasm32-wasip1/debug/golem_llm_openai.wasm components/debug/golem_llm_openai-portable.wasm
88103
cp target/wasm32-wasip1/debug/golem_llm_openrouter.wasm components/debug/golem_llm_openrouter-portable.wasm
104+
cp target/wasm32-wasip1/debug/golem_llm_ollama.wasm components/debug/golem_llm_ollama-portable.wasm
89105
'''
90106

107+
[tasks.release-build-ollama]
108+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
109+
command = "cargo-component"
110+
args = ["build", "-p", "golem-llm-ollama", "--release"]
111+
112+
[tasks.release-build-ollama-portable]
113+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
114+
command = "cargo-component"
115+
args = ["build", "-p", "golem-llm-ollama", "--release", "--no-default-features"]
116+
117+
91118
[tasks.release-build-anthropic]
92119
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
93120
command = "cargo-component"
@@ -146,6 +173,7 @@ dependencies = [
146173
"release-build-grok",
147174
"release-build-openai",
148175
"release-build-openrouter",
176+
"release-build-ollama",
149177
]
150178

151179
[tasks.release-build-portable]
@@ -154,6 +182,7 @@ dependencies = [
154182
"release-build-grok-portable",
155183
"release-build-openai-portable",
156184
"release-build-openrouter-portable",
185+
"release-build-ollama-portable",
157186
]
158187

159188
[tasks.release-build-all]
@@ -170,6 +199,7 @@ cp target/wasm32-wasip1/release/golem_llm_anthropic.wasm components/release/gole
170199
cp target/wasm32-wasip1/release/golem_llm_grok.wasm components/release/golem_llm_grok.wasm
171200
cp target/wasm32-wasip1/release/golem_llm_openai.wasm components/release/golem_llm_openai.wasm
172201
cp target/wasm32-wasip1/release/golem_llm_openrouter.wasm components/release/golem_llm_openrouter.wasm
202+
cp target/wasm32-wasip1/release/golem_llm_ollama.wasm components/release/golem_llm_ollama.wasm
173203
174204
cm_run_task clean
175205
cm_run_task release-build-portable
@@ -178,6 +208,7 @@ cp target/wasm32-wasip1/release/golem_llm_anthropic.wasm components/release/gole
178208
cp target/wasm32-wasip1/release/golem_llm_grok.wasm components/release/golem_llm_grok-portable.wasm
179209
cp target/wasm32-wasip1/release/golem_llm_openai.wasm components/release/golem_llm_openai-portable.wasm
180210
cp target/wasm32-wasip1/release/golem_llm_openrouter.wasm components/release/golem_llm_openrouter-portable.wasm
211+
cp target/wasm32-wasip1/release/golem_llm_ollama.wasm components/release/golem_llm_ollama-portable.wasm
181212
'''
182213

183214
[tasks.wit-update]
@@ -221,6 +252,11 @@ rm -r llm-openrouter/wit/deps
221252
mkdir llm-openrouter/wit/deps/golem-llm
222253
cp wit/golem-llm.wit llm-openrouter/wit/deps/golem-llm/golem-llm.wit
223254
cp wit/deps/wasi:io llm-openrouter/wit/deps
255+
rm -r llm-ollama/wit/deps
256+
mkdir llm-ollama/wit/deps/golem-llm
257+
cp wit/golem-llm.wit llm-ollama/wit/deps/golem-llm/golem-llm.wit
258+
cp wit/deps/wasi:io llm-ollama/wit/deps
259+
224260
225261
rm -r test/wit
226262
mkdir test/wit/deps/golem-llm
@@ -289,8 +325,11 @@ golem-cli app clean
289325
golem-cli app build -b openai-debug
290326
golem-cli app clean
291327
golem-cli app build -b openrouter-debug
328+
golem-cli app clean
329+
golem-cli app build -b ollama-debug
292330
'''
293331

332+
294333
[tasks.set-version]
295334
description = "Sets the version in all Cargo.toml files to the value of the VERSION environment variable"
296335
condition = { env_set = ["VERSION"] }

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ There are 8 published WASM files for each release:
99
| Name | Description |
1010
|--------------------------------------|--------------------------------------------------------------------------------------|
1111
| `golem-llm-anthropic.wasm` | LLM implementation for Anthropic AI, using custom Golem specific durability features |
12+
| `golem-llm-ollama.wasm` | LLM implementation for Ollama, using custom Golem specific durability features |
1213
| `golem-llm-grok.wasm` | LLM implementation for xAI (Grok), using custom Golem specific durability features |
1314
| `golem-llm-openai.wasm` | LLM implementation for OpenAI, using custom Golem specific durability features |
1415
| `golem-llm-openrouter.wasm` | LLM implementation for OpenRouter, using custom Golem specific durability features |
1516
| `golem-llm-anthropic-portable.wasm` | LLM implementation for Anthropic AI, with no Golem specific dependencies. |
17+
| `golem-llm-ollama-portable.wasm` | LLM implementation for Ollama, with no Golem specific dependencies. |
1618
| `golem-llm-grok-portable.wasm` | LLM implementation for xAI (Grok), with no Golem specific dependencies. |
1719
| `golem-llm-openai-portable.wasm` | LLM implementation for OpenAI, with no Golem specific dependencies. |
1820
| `golem-llm-openrouter-portable.wasm` | LLM implementation for OpenRouter, with no Golem specific dependencies. |
@@ -34,6 +36,7 @@ Each provider has to be configured with an API key passed as an environment vari
3436
| Grok | `XAI_API_KEY` |
3537
| OpenAI | `OPENAI_API_KEY` |
3638
| OpenRouter | `OPENROUTER_API_KEY` |
39+
| Ollama | `GOLEM_OLLAMA_BASE_URL` |
3740

3841
Additionally, setting the `GOLEM_LLM_LOG=trace` environment variable enables trace logging for all the communication
3942
with the underlying LLM provider.
@@ -134,6 +137,8 @@ Then build and deploy the _test application_. Select one of the following profil
134137
|--------------|-----------------------------------------------------------------------------------------------|
135138
| `anthropic-debug` | Uses the Anthropic LLM implementation and compiles the code in debug profile |
136139
| `anthropic-release` | Uses the Anthropic LLM implementation and compiles the code in release profile |
140+
| `ollama-debug` | Uses the Ollama LLM implementation and compiles the code in debug profile |
141+
| `ollama-release` | Uses the Ollama LLM implementation and compiles the code in release profile |
137142
| `grok-debug` | Uses the Grok LLM implementation and compiles the code in debug profile |
138143
| `grok-release` | Uses the Grok LLM implementation and compiles the code in release profile |
139144
| `openai-debug` | Uses the OpenAI LLM implementation and compiles the code in debug profile |

0 commit comments

Comments
 (0)