Skip to content

Commit 06c0d17

Browse files
committed
simplify llama-stack-client-list-models.py
1 parent 75c4364 commit 06c0d17

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

llm/llama-stack-client-completions-min.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
#!/usr/bin/python3
22

3-
# export INFERENCE_MODEL=llama3.2:1b-instruct-fp16
4-
## start ollama:
3+
# export INFERENCE_MODEL=ollama/llama3.2:3b
54
# ollama run $INFERENCE_MODEL
6-
## start llama-stack:
7-
# uv run --with llama-stack llama stack build --template ollama --image-type venv --image-name ~/my-ollama-llama-stack --run
5+
# llama stack run starter
86

97
import os
108
from llama_stack_client import LlamaStackClient
119

1210
c = LlamaStackClient(base_url="http://localhost:8321")
1311

1412
r = c.chat.completions.create(
15-
model=os.getenv("INFERENCE_MODEL", "gemini/models/gemini-2.5-pro"),
13+
model=os.getenv("INFERENCE_MODEL", "ollama/llama3.2:3b"),
1614
messages=[
1715
{"role": "system", "content": "You are a helpful assistant."},
1816
{"role": "user", "content": "Write a haiku about coding"},
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#!/usr/bin/python3
22

3+
# Prerequisite:
4+
# export LLAMA_STACK_CLIENT_BASE_URL=http://localhost:8321
5+
36
from llama_stack_client import LlamaStackClient
47

5-
# uses LLAMA_STACK_CLIENT_BASE_URL
68
for m in LlamaStackClient().models.list():
7-
try:
8-
print(m.custom_metadata.get("provider_id"), m.custom_metadata['model_type'], m.id)
9-
except Exception:
10-
try:
11-
print(m.model_type, m.identifier)
12-
except Exception:
13-
print(m)
9+
print(m.custom_metadata.get("provider_id"), m.custom_metadata['model_type'], m.id)

0 commit comments

Comments
 (0)