Skip to content

Commit 82c7de4

Browse files
committed
add input_cached_tokens tag key
1 parent cde5db2 commit 82c7de4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

cozeloop/spec/tracespec/span_key.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
MODEL_PROVIDER = "model_provider"
3333
MODEL_NAME = "model_name"
3434
INPUT_TOKENS = "input_tokens"
35+
INPUT_CACHED_TOKENS = "input_cached_tokens"
3536
OUTPUT_TOKENS = "output_tokens"
3637
TOKENS = "tokens"
3738
MODEL_PLATFORM = "model_platform"

examples/trace/wrapper_openai/sync_openai_chat.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import os
2+
13
from openai import OpenAI
24

35
from cozeloop import new_client
46
from cozeloop.decorator import observe
57
from cozeloop.integration.wrapper import openai_wrapper
68

9+
10+
base_url = os.environ.get('OPENAI_BASE_URL')
11+
api_key = os.environ.get('OPENAI_API_KEY')
12+
model_name = os.environ.get('OPENAI_MODEL_NAME')
13+
14+
715
openai_client = openai_wrapper(OpenAI(
8-
base_url="https://ark.cn-beijing.volces.com/api/v3", # use ark model, refer: https://www.volcengine.com/docs/82379/1361424
9-
api_key="***",
16+
base_url=base_url, # use ark model, refer: https://www.volcengine.com/docs/82379/1361424
17+
api_key=api_key,
1018
))
1119

1220
def retriever():
@@ -26,7 +34,7 @@ def rag(question):
2634
# {"role": "system", "content": system_message},
2735
# {"role": "user", "content": question},
2836
# ],
29-
# model="doubao-1-5-vision-pro-32k-250115",
37+
# model=model_name,
3038
# )
3139
# print(res)
3240

@@ -36,7 +44,7 @@ def rag(question):
3644
{"role": "system", "content": system_message},
3745
{"role": "user", "content": question},
3846
],
39-
model="doubao-1-5-vision-pro-32k-250115",
47+
model=model_name,
4048
stream=True,
4149
extra_body={
4250
"stream_options": {

0 commit comments

Comments
 (0)