Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(answerAPI): insight generate endpoint #4602

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/headless/src/api/knowledge/stream-answer-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {SearchAppState} from '../../state/search-app-state.js';
import {
ConfigurationSection,
GeneratedAnswerSection,
InsightConfigurationSection,
} from '../../state/state-sections.js';
import {getFacets} from '../../utils/facet-utils.js';
import {GeneratedAnswerCitation} from '../generated-answer/generated-answer-event-payload.js';
Expand All @@ -30,6 +31,7 @@ export type StateNeededByAnswerAPI = {
answer: ReturnType<typeof answerApi.reducer>;
} & ConfigurationSection &
Partial<SearchAppState> &
InsightConfigurationSection &
dmgauthier marked this conversation as resolved.
Show resolved Hide resolved
GeneratedAnswerSection;

export interface GeneratedAnswerStream {
Expand Down Expand Up @@ -176,15 +178,17 @@ export const answerApi = answerSlice.injectEndpoints({
* It cannot use the inferred state used by Redux, thus the casting.
* https://redux-toolkit.js.org/rtk-query/usage-with-typescript#typing-dispatch-and-getstate
*/
const {configuration, generatedAnswer} =
const {configuration, generatedAnswer, insightConfiguration} =
getState() as unknown as StateNeededByAnswerAPI;
const {organizationId, environment, accessToken} = configuration;
const platformEndpoint = getOrganizationEndpoint(
organizationId,
environment
);
const insightGenerateEndpoint = `${platformEndpoint}/rest/organizations/${organizationId}/insight/v1/configs/${insightConfiguration.insightId}/answer/${generatedAnswer.answerConfigurationId}/generate`;
dmgauthier marked this conversation as resolved.
Show resolved Hide resolved
const generateEndpoint = `${platformEndpoint}/rest/organizations/${organizationId}/answer/v1/configs/${generatedAnswer.answerConfigurationId}/generate`;
await fetchEventSource(
`${platformEndpoint}/rest/organizations/${organizationId}/answer/v1/configs/${generatedAnswer.answerConfigurationId}/generate`,
insightConfiguration ? insightGenerateEndpoint : generateEndpoint,
{
method: 'POST',
body: JSON.stringify(args),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export const streamAnswerAPIStateMock: StateNeededByAnswerAPI = {
answerConfigurationId: '',
},
},
insightConfiguration: {
insightId: 'allo',
},
dmgauthier marked this conversation as resolved.
Show resolved Hide resolved
version: '2.77.0',
debug: false,
pipeline: '',
Expand Down
Loading