Skip to content

Commit

Permalink
[Obs AI Assistant] Add tokenCount event to complete event stream in s…
Browse files Browse the repository at this point in the history
…erverless tests (elastic#205397)

Closes elastic#203407
elastic#203408
elastic#203478

## Summary

### Problem
Some tests in serverless are failing after the migration to the
Inference endpoints. This is due to not emitting the tokenCount event,
which enables successfully closing the stream.

### Solution
Emit the tokenCount event in the serverless tests when the title or
conversation is simulated.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
viduni94 authored Jan 3, 2025
1 parent 1ff181c commit a5909f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
];

// Failing: See https://github.com/elastic/kibana/issues/203407
describe.skip('/internal/observability_ai_assistant/chat/complete', function () {
describe('/internal/observability_ai_assistant/chat/complete', function () {
// TODO: https://github.com/elastic/kibana/issues/192751
this.tags(['skipMKI']);
let proxy: LlmProxy;
Expand Down Expand Up @@ -107,6 +106,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {

await titleSimulator.status(200);
await titleSimulator.next('My generated title');
await titleSimulator.tokenCount({ completion: 1, prompt: 1, total: 2 });
await titleSimulator.complete();

await conversationSimulator.status(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
];

// Failing: See https://github.com/elastic/kibana/issues/203408
describe.skip('/api/observability_ai_assistant/chat/complete', function () {
describe('/api/observability_ai_assistant/chat/complete', function () {
// TODO: https://github.com/elastic/kibana/issues/192751
this.tags(['skipMKI']);

Expand Down Expand Up @@ -107,6 +106,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {

await titleSimulator.status(200);
await titleSimulator.next('My generated title');
await titleSimulator.tokenCount({ completion: 1, prompt: 1, total: 2 });
await titleSimulator.complete();

await conversationSimulator.status(200);
Expand Down Expand Up @@ -202,6 +202,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
],
});
await conversationSimulator.tokenCount({ completion: 0, prompt: 0, total: 0 });
await conversationSimulator.complete();
}
);
Expand Down Expand Up @@ -259,6 +260,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
},
],
});
await conversationSimulator.tokenCount({ completion: 0, prompt: 0, total: 0 });
await conversationSimulator.complete();
}
);
Expand All @@ -275,6 +277,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
before(async () => {
responseBody = await getOpenAIResponse(async (conversationSimulator) => {
await conversationSimulator.next('Hello');
await conversationSimulator.tokenCount({ completion: 1, prompt: 1, total: 2 });
await conversationSimulator.complete();
});
});
Expand Down

0 comments on commit a5909f3

Please sign in to comment.