Skip to content

Commit db1d71b

Browse files
committed
Introduce ollama after using OpenAI
1 parent a81637a commit db1d71b

File tree

1 file changed

+27
-6
lines changed
  • instrumentation/elastic-opentelemetry-instrumentation-openai

1 file changed

+27
-6
lines changed

instrumentation/elastic-opentelemetry-instrumentation-openai/README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,42 @@ pip install -r test-requirements.txt
3131
pip install python-dotenv[cli]
3232
```
3333

34-
Run the script with telemetry setup to use the instrumentation. [ollama.env](ollama.env)
35-
includes variables to point to Ollama instead of OpenAI, which allows you to
36-
run examples without a cloud account:
34+
Create a `.env` file containing the OpenAI API key:
3735

3836
```
39-
dotenv -f ollama.env run -- \
40-
opentelemetry-instrument python examples/chat.py
37+
echo "OPENAI_API_KEY=sk-..." > .env
38+
```
39+
40+
Run the script with telemetry setup to use the instrumentation.
41+
42+
```
43+
dotenv run -- opentelemetry-instrument python examples/chat.py
4144
```
4245

4346
You can record more information about prompts as log events by enabling content capture.
4447
```
45-
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true dotenv -f ollama.env run -- \
48+
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true dotenv run -- \
4649
opentelemetry-instrument python examples/chat.py
4750
```
4851

52+
### Using a local model
53+
54+
[Ollama](https://ollama.com/) may be used to run examples without a cloud account. After you have set it up
55+
need to install the models in order to run the examples:
56+
57+
```
58+
# for chat
59+
ollama pull qwen2.5:0.5b
60+
# for embeddings
61+
ollama pull all-minilm:33m
62+
```
63+
64+
Finally run the examples using [ollama.env](ollama.env) variables to point to Ollama instead of OpenAI:
65+
66+
```
67+
dotenv run -f ollama.env -- opentelemetry-instrument python examples/chat.py
68+
```
69+
4970
### Instrumentation specific environment variable configuration
5071

5172
None

0 commit comments

Comments
 (0)