Skip to content

Commit 574cf70

Browse files
authored
Deploy Ollama to run examples (#629)
* Deploy ollama on GH Actions and run against tests Signed-off-by: Jing Chen <[email protected]> * Set up nightly tests Signed-off-by: Jing Chen <[email protected]> * Update checks Signed-off-by: Jing Chen <[email protected]> * Address no disk space Signed-off-by: Jing Chen <[email protected]> * Rm failing test Signed-off-by: Jing Chen <[email protected]> --------- Signed-off-by: Jing Chen <[email protected]>
1 parent 2bf2aa0 commit 574cf70

27 files changed

+422
-22
lines changed

.github/workflows/run-examples.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- cron: '0 1 * * *'
77
workflow_dispatch:
88

9+
910
jobs:
1011
tests:
1112
name: Execution tests
@@ -16,6 +17,56 @@ jobs:
1617
python-version: ['3.11', '3.12', '3.13']
1718

1819
steps:
20+
21+
# Free up some disk space
22+
- name: Remove unnecessary files
23+
run: |
24+
sudo rm -rf /usr/share/dotnet
25+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
26+
27+
# Set up Ollama
28+
- name: Install Ollama and start server
29+
shell: bash
30+
run: |
31+
curl -fsSL https://ollama.com/install.sh | sudo -E sh
32+
33+
- name: Pull models in examples/
34+
shell: bash
35+
run: |
36+
ollama pull granite-code:8b
37+
ollama pull granite3-dense:8b
38+
ollama pull granite3.1-dense
39+
ollama pull granite3.2:2b
40+
ollama pull granite3.2
41+
ollama pull granite3.2:8b
42+
ollama pull mxbai-embed-large
43+
ollama list
44+
45+
- name: Check that all required models are available
46+
shell: bash
47+
run: |
48+
models=("granite-code" "granite3-dense" "granite3.1-dense" "mxbai-embed-large" "granite3.2:2b" "granite3.2" "granite3.2:8b")
49+
missing=0
50+
for model in "${models[@]}"; do
51+
if ! ollama list | awk 'NR>1 {print $1}' | grep -q "$model"; then
52+
echo "❌ Model $model (or substring) is missing!"
53+
missing=1
54+
fi
55+
done
56+
57+
if [ "$missing" -eq 1 ]; then
58+
exit 1
59+
else
60+
echo "✅ All expected models are available."
61+
fi
62+
63+
- name: Wait for Ollama server
64+
shell: bash
65+
run: |
66+
sleep 10
67+
time curl -i http://localhost:11434
68+
69+
# Run tests
1970
- uses: actions/checkout@v4
2071
- name: Set up Python ${{ matrix.python-version }}
2172
uses: actions/setup-python@v5
@@ -45,4 +96,4 @@ jobs:
4596
WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }}
4697
WATSONX_URL: ${{ secrets.WATSONX_URL }}
4798
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
48-
run: py.test -v --capture=tee-sys tests/test_examples_run.py
99+
run: py.test -v --capture=tee-sys -rfE -s tests/test_examples_run.py

examples/granite/multi_round_chat.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ text:
1818

1919
${ prompt }
2020
# Use replicate.com to run the Granite model on the context, outputting the result
21-
- model: replicate/ibm-granite/granite-3.1-8b-instruct
21+
- model: ollama/granite3.1-dense
2222
parameters:
2323
# Use no LLM model creativity (0 is the default)
2424
temperature: 0

examples/hello/hello-code-pdl.pdl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ code: |
44
description: Hello world
55
text:
66
- "Hello\n"
7-
- model: replicate/ibm-granite/granite-3.1-8b-instruct
8-
7+
- model: ollama/granite-code:8b
8+
parameters:
9+
temperature: 0

examples/rag/tfidf_rag.pdl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ text:
4141
- |-
4242

4343
Q: ${ TEST_PROMPT }
44-
A:
45-
- model: replicate/ibm-granite/granite-3.0-8b-instruct
44+
A:
45+
- model: ollama/granite3.2:8b
46+
parameters:
47+
temperature: 0

examples/tutorial/parser_regex.pdl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
description: Hello world with parser using regex
22
text:
33
- model: ollama/granite-code:8b
4+
parameters:
5+
temperature: 0
46
input: "Hello,"
57
parameters:
68
# Tell the LLM to stop after generating an exclamation point.

pdl-live-react/demos/demo2.pdl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
description: Model chaining
22
text:
33
- "write a hello world example, and explain to me how to run it"
4-
- model: ollama/granite3.2:8b
4+
- model: ollama/granite3.2
5+
parameters:
6+
temperature: 0
57
- "how about in Rust?"
6-
- model: ollama/granite3.2:8b
8+
- model: ollama/granite3.2
9+
parameters:
10+
temperature: 0
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11

22
What is APR?
3-
APR stands for Annual Percentage Rate. It is the annual interest rate charged for borrowing or earned through an investment, and it represents the actual yearly cost of funds over the term of a loan. It includes any fees or additional costs associated with the transaction.
3+
APR stands for Annual Percentage Rate. It's a measure of the cost of a loan, expressed as a yearly rate that includes not only interest but also other charges or fees that may be associated with the loan. This allows consumers to compare different loans and understand their true cost more easily. APR is calculated by taking into account the interest rate, points, mortgage insurance, and other costs over the life of the loan. It's important to note that APR doesn't necessarily reflect the actual interest rate you'll be charged; it's a standardized way to compare loans from different lenders.
44
Can you write a poem about APR?
5-
In the world of finance, APR is the key,
6-
A number that tells us what we'll pay, or earn, you see.
7-
It's the annual rate, both simple and clear,
8-
Including all fees, for loans and investments, near and far.
9-
10-
It's the cost of borrowing, or the return we gain,
11-
A figure that helps us make informed financial gain.
12-
So, when you're comparing loans, or investments to choose,
13-
Remember APR, and make the right move.
5+
In finance, there's a term so neat,
6+
APR, it helps us to compete.
7+
Not just interest, but all the fees,
8+
A yearly rate that sets loans free.
9+
10+
From mortgages to credit cards,
11+
It guides our choices, as per the charts.
12+
Points, insurance, and more,
13+
In this calculation, they're no chore.
14+
15+
A standardized tool for comparison,
16+
Helping us avoid financial frustration.
17+
Though it may not reflect the true rate,
18+
APR is a helpful trait.
19+
20+
So when you borrow, take a peek,
21+
At APR, and don't be meek.
22+
Understand its power, use it wisely,
23+
And watch your finances flourish with ease.
1424
Now explain APR to me like I'm 5 years old
15-
Sure! Imagine you have a piggy bank, and you want to borrow some money from your parents to buy a toy. Your parents will ask you to pay them back with some extra money, which is like interest. APR is the special number that tells you how much extra money you'll have to pay back, all in one year. It's like a special rule that helps you understand how much you'll owe your parents.
25+
Sure! Imagine you want to buy a toy that costs $100. You can either pay the full $100 right away or borrow it and pay back more over time.
26+
27+
APR is like a special number that tells you how much more you'll have to pay in total when you borrow money. It includes not just the extra money you pay for using someone else's cash (that's like interest), but also any other costs, like fees for taking the loan or insurance to protect the lender if you can't pay back.
28+
29+
So, if your APR is 10%, that means you'll have to pay an extra $10 on top of the $100 you're borrowing. That's a total of $110. It's like a little extra for using their money, and it helps everyone understand how much more things cost when we borrow instead of saving up.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Hello
2-
Hello! How can I assist you today?
2+
Greetings! How can I assist you today?
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hello
2+
Hi there! How can I help you today?
3+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123

0 commit comments

Comments
 (0)