Skip to content

Commit

Permalink
test(instr-openai): refactor some test envvars and the Q used for tes…
Browse files Browse the repository at this point in the history
…ting chat completion (#497)
  • Loading branch information
trentm authored Dec 26, 2024
1 parent 8fddaf7 commit 731abfe
Show file tree
Hide file tree
Showing 28 changed files with 224 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-instrumentation-openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:
- name: Pull Ollama models
run: |
source packages/instrumentation-openai/ollama.env
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_MODEL_TOOLS\"}"
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_MODEL_EMBEDDINGS\"}"
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_CHAT_MODEL\"}"
curl -s http://localhost:11434/api/pull -d "{\"model\": \"$TEST_EMBEDDINGS_MODEL\"}"
curl -s http://localhost:11434/api/tags | jq
# Dump Ollama container logs if it doesn't appear to be working.
curl -fsS http://localhost:11434/ || docker logs $(docker ps -q)
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-openai/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dev/debugging. For example:
npx @elastic/mockotlpserver # or whatever OTLP endpoint you like to use
cd test/fixtures
TEST_MODEL_TOOLS=gpt-4o-mini \
TEST_CHAT_MODEL=gpt-4o-mini \
node --env-file ../../openai.env -r ./telemetry.js chat-completion.js
```

4 changes: 2 additions & 2 deletions packages/instrumentation-openai/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ or a running Ollama. Which is used is determined by the environment variables.
docker run -it --rm -p 11434:11434 -v ~/.ollama:/root/.ollama ghcr.io/elastic/ollama/ollama:testing serve
set -a; source ./ollama.env
ollama pull $TEST_MODEL_TOOLS
ollama pull $TEST_MODEL_EMBEDDINGS
ollama pull $TEST_CHAT_MODEL
ollama pull $TEST_EMBEDDINGS_MODEL
npm run test:integration
```
Expand Down
4 changes: 2 additions & 2 deletions packages/instrumentation-openai/azure.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ OPENAI_API_VERSION=2024-10-01-preview

# Set this to the *deployment name* in your Azure OpenAI endpoint that deployed
# a model that supports OpenAI tool calling, such as "gpt-4o-mini".
TEST_MODEL_TOOLS=YOUR_TOOL_COMPATIBLE_DEPLOYMENT_NAME
TEST_CHAT_MODEL=YOUR_TOOL_COMPATIBLE_DEPLOYMENT_NAME

# Set this to the *deployment name* in your Azure OpenAI endpoint that deployed
# a model that supports OpenAI embeddings, such as "text-embedding-3-small".
TEST_MODEL_EMBEDDINGS=YOUR_EMBEDDING_DEPLOYMENT_NAME
TEST_EMBEDDINGS_MODEL=YOUR_EMBEDDING_DEPLOYMENT_NAME


2 changes: 1 addition & 1 deletion packages/instrumentation-openai/examples/use-chat-esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function main() {
{
role: 'user',
content:
'Answer in up to 3 words: Which ocean contains the falkland islands?',
'Answer in up to 3 words: Which ocean contains Bouvet Island?',
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation-openai/examples/use-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function main() {
{
role: 'user',
content:
'Answer in up to 3 words: Which ocean contains the falkland islands?',
'Answer in up to 3 words: Which ocean contains Bouvet Island?',
},
],
});
Expand Down
4 changes: 2 additions & 2 deletions packages/instrumentation-openai/ollama.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ OPENAI_API_KEY=notused

# These models may be substituted in the future with inexpensive to run, newer
# variants.
TEST_MODEL_TOOLS=qwen2.5:0.5b
TEST_MODEL_EMBEDDINGS=all-minilm:33m
TEST_CHAT_MODEL=qwen2.5:0.5b
TEST_EMBEDDINGS_MODEL=all-minilm:33m
4 changes: 2 additions & 2 deletions packages/instrumentation-openai/openai.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ OPENAI_API_KEY=sk-...
# OPENAI_ORG_ID=org-...
# OPENAI_PROJECT_ID=...

TEST_MODEL_TOOLS=gpt-4o-mini
TEST_MODEL_EMBEDDINGS=text-embedding-3-small
TEST_CHAT_MODEL=gpt-4o-mini
TEST_EMBEDDINGS_MODEL=text-embedding-3-small
Loading

0 comments on commit 731abfe

Please sign in to comment.