Skip to content

Commit 96264db

Browse files
authored
fix: update reflection API E2E Test (#3529)
1 parent f745bec commit 96264db

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

‎tests/specs/reflection_api.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@ tests:
3434
role: model
3535
content:
3636
- text: '{"messages":[{"content":[{"text":"hello"}],"role":"user"}]}'
37+
usage:
38+
inputCharacters: 5
39+
outputCharacters: 59
40+
inputImages: 0
41+
inputVideos: 0
42+
inputAudioFiles: 0
43+
outputImages: 0
44+
outputVideos: 0
45+
outputAudioFiles: 0

‎tests/test_js_app/src/index.ts‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { genkit, z } from 'genkit';
17+
import { MessageData, genkit, z } from 'genkit';
18+
import { getBasicUsageStats } from 'genkit/model';
1819

1920
const ai = genkit({
2021
plugins: [],
@@ -30,16 +31,18 @@ ai.defineModel(
3031
// So swap the order here to match Go.
3132
const m = input.messages[0];
3233
input.messages[0] = { content: m.content, role: m.role };
34+
const message: MessageData = {
35+
role: 'model',
36+
content: [
37+
{
38+
text: JSON.stringify(input),
39+
},
40+
],
41+
};
3342
return {
3443
finishReason: 'stop',
35-
message: {
36-
role: 'model',
37-
content: [
38-
{
39-
text: JSON.stringify(input),
40-
},
41-
],
42-
},
44+
message,
45+
usage: getBasicUsageStats(input.messages, message),
4346
};
4447
}
4548
);

0 commit comments

Comments
 (0)