@@ -12,6 +12,7 @@ import (
1212 "github.com/prometheus/client_golang/prometheus"
1313 promtest "github.com/prometheus/client_golang/prometheus/testutil"
1414 "github.com/stretchr/testify/require"
15+ "github.com/tidwall/gjson"
1516
1617 "github.com/coder/aibridge"
1718 "github.com/coder/coder/v2/coderd/coderdtest"
@@ -107,7 +108,7 @@ func TestIntegration(t *testing.T) {
107108 "completion_tokens": 15,
108109 "total_tokens": 75,
109110 "prompt_tokens_details": {
110- "cached_tokens": 0 ,
111+ "cached_tokens": 15 ,
111112 "audio_tokens": 0
112113 },
113114 "completion_tokens_details": {
@@ -244,8 +245,9 @@ func TestIntegration(t *testing.T) {
244245 tokens , err := db .GetAIBridgeTokenUsagesByInterceptionID (ctx , interceptions [0 ].ID )
245246 require .NoError (t , err )
246247 require .Len (t , tokens , 1 )
247- require .EqualValues (t , tokens [0 ].InputTokens , 60 )
248+ require .EqualValues (t , tokens [0 ].InputTokens , 45 )
248249 require .EqualValues (t , tokens [0 ].OutputTokens , 15 )
250+ require .EqualValues (t , gjson .Get (string (tokens [0 ].Metadata .RawMessage ), "prompt_cached" ).Int (), 15 )
249251
250252 tools , err := db .GetAIBridgeToolUsagesByInterceptionID (ctx , interceptions [0 ].ID )
251253 require .NoError (t , err )
0 commit comments