Skip to content

Commit 0d6e9e4

Browse files
committed
add llm tests
1 parent 50356a4 commit 0d6e9e4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
uses: actions/setup-python@v4
2727
with:
2828
python-version: ${{ matrix.python-version }}
29+
- name: Pull Ollama model
30+
run: |
31+
curl http://localhost:11434/api/pull -d '{
32+
"model": "gemma2:2b"
33+
}'
2934
- name: Install dependencies
3035
run: |
3136
python3 -m pip install --upgrade pip
@@ -43,6 +48,8 @@ jobs:
4348
NEO4J_PASSWORD: your_password
4449
NEO4J_HOST: localhost
4550
NEO4J_PORT: 7687
51+
OLLAMA_HOST: "http://localhost:11434/v1"
52+
OLLAMA_MODEL: "gemma2:2b"
4653
run: |
4754
python3 -m poetry run pytest
4855
@@ -54,3 +61,7 @@ jobs:
5461
- 7687:7687
5562
env:
5663
NEO4J_AUTH: neo4j/your_password
64+
ollama:
65+
image: ollama/ollama:latest
66+
ports:
67+
- 11434:11434

tests/integration/test_llm.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from mdmodels import DataModel, llm
3+
4+
5+
class TestLLM:
6+
def test_llm(self):
7+
# Arrange
8+
OLLAMA_HOST = os.getenv("OLLAMA_HOST")
9+
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL")
10+
11+
assert OLLAMA_HOST, "OLLAMA_HOST is not set"
12+
assert OLLAMA_MODEL, "OLLAMA_MODEL is not set"
13+
14+
dm = DataModel.from_markdown("./tests/fixtures/model_graph.md")
15+
input_text = "My name is John Doe (33 yrs old) and I like to code."
16+
17+
# Act
18+
response = llm.query_openai(
19+
query=input_text,
20+
response_model=dm.Person,
21+
base_url=OLLAMA_HOST,
22+
llm_model=OLLAMA_MODEL,
23+
api_key="ollama",
24+
)
25+
26+
# Assert
27+
assert response

0 commit comments

Comments
 (0)