Skip to content

Commit

Permalink
Merge pull request #7188 from alkem-io/alkemio-1456/async-guidance
Browse files Browse the repository at this point in the history
Async Chat Guidance engine using Matrix rooms instead of direct querying
  • Loading branch information
ccanos authored Dec 6, 2024
1 parent a342e27 commit 97879b8
Show file tree
Hide file tree
Showing 18 changed files with 587 additions and 224 deletions.
32 changes: 10 additions & 22 deletions src/core/apollo/generated/apollo-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ export type AiPersonaServiceFieldPolicy = {
export type AiServerKeySpecifier = (
| 'aiPersonaService'
| 'aiPersonaServices'
| 'askAiPersonaServiceQuestion'
| 'authorization'
| 'createdDate'
| 'defaultAiPersonaService'
Expand All @@ -567,7 +566,6 @@ export type AiServerKeySpecifier = (
export type AiServerFieldPolicy = {
aiPersonaService?: FieldPolicy<any> | FieldReadFunction<any>;
aiPersonaServices?: FieldPolicy<any> | FieldReadFunction<any>;
askAiPersonaServiceQuestion?: FieldPolicy<any> | FieldReadFunction<any>;
authorization?: FieldPolicy<any> | FieldReadFunction<any>;
createdDate?: FieldPolicy<any> | FieldReadFunction<any>;
defaultAiPersonaService?: FieldPolicy<any> | FieldReadFunction<any>;
Expand Down Expand Up @@ -1922,22 +1920,17 @@ export type MessageFieldPolicy = {
timestamp?: FieldPolicy<any> | FieldReadFunction<any>;
};
export type MessageAnswerQuestionKeySpecifier = (
| 'answer'
| 'error'
| 'id'
| 'question'
| 'sources'
| 'success'
| MessageAnswerQuestionKeySpecifier
)[];
export type MessageAnswerQuestionFieldPolicy = {
answer?: FieldPolicy<any> | FieldReadFunction<any>;
error?: FieldPolicy<any> | FieldReadFunction<any>;
id?: FieldPolicy<any> | FieldReadFunction<any>;
question?: FieldPolicy<any> | FieldReadFunction<any>;
sources?: FieldPolicy<any> | FieldReadFunction<any>;
};
export type MessageAnswerToQuestionSourceKeySpecifier = ('title' | 'uri' | MessageAnswerToQuestionSourceKeySpecifier)[];
export type MessageAnswerToQuestionSourceFieldPolicy = {
title?: FieldPolicy<any> | FieldReadFunction<any>;
uri?: FieldPolicy<any> | FieldReadFunction<any>;
success?: FieldPolicy<any> | FieldReadFunction<any>;
};
export type MetadataKeySpecifier = ('services' | MetadataKeySpecifier)[];
export type MetadataFieldPolicy = {
Expand All @@ -1961,6 +1954,7 @@ export type MutationKeySpecifier = (
| 'aiServerPersonaServiceIngest'
| 'aiServerUpdateAiPersonaService'
| 'applyForEntryRoleOnRoleSet'
| 'askChatGuidanceQuestion'
| 'assignLicensePlanToAccount'
| 'assignLicensePlanToSpace'
| 'assignOrganizationRoleToUser'
Expand All @@ -1984,6 +1978,7 @@ export type MutationKeySpecifier = (
| 'createActor'
| 'createActorGroup'
| 'createCalloutOnCollaboration'
| 'createChatGuidanceRoom'
| 'createContributionOnCallout'
| 'createDiscussion'
| 'createEventOnCalendar'
Expand Down Expand Up @@ -2126,6 +2121,7 @@ export type MutationFieldPolicy = {
aiServerPersonaServiceIngest?: FieldPolicy<any> | FieldReadFunction<any>;
aiServerUpdateAiPersonaService?: FieldPolicy<any> | FieldReadFunction<any>;
applyForEntryRoleOnRoleSet?: FieldPolicy<any> | FieldReadFunction<any>;
askChatGuidanceQuestion?: FieldPolicy<any> | FieldReadFunction<any>;
assignLicensePlanToAccount?: FieldPolicy<any> | FieldReadFunction<any>;
assignLicensePlanToSpace?: FieldPolicy<any> | FieldReadFunction<any>;
assignOrganizationRoleToUser?: FieldPolicy<any> | FieldReadFunction<any>;
Expand All @@ -2149,6 +2145,7 @@ export type MutationFieldPolicy = {
createActor?: FieldPolicy<any> | FieldReadFunction<any>;
createActorGroup?: FieldPolicy<any> | FieldReadFunction<any>;
createCalloutOnCollaboration?: FieldPolicy<any> | FieldReadFunction<any>;
createChatGuidanceRoom?: FieldPolicy<any> | FieldReadFunction<any>;
createContributionOnCallout?: FieldPolicy<any> | FieldReadFunction<any>;
createDiscussion?: FieldPolicy<any> | FieldReadFunction<any>;
createEventOnCalendar?: FieldPolicy<any> | FieldReadFunction<any>;
Expand Down Expand Up @@ -2638,8 +2635,6 @@ export type QueryKeySpecifier = (
| 'adminCommunicationMembership'
| 'adminCommunicationOrphanedUsage'
| 'aiServer'
| 'askChatGuidanceQuestion'
| 'askVirtualContributorQuestion'
| 'exploreSpaces'
| 'getSupportedVerifiedCredentialMetadata'
| 'inputCreator'
Expand Down Expand Up @@ -2677,8 +2672,6 @@ export type QueryFieldPolicy = {
adminCommunicationMembership?: FieldPolicy<any> | FieldReadFunction<any>;
adminCommunicationOrphanedUsage?: FieldPolicy<any> | FieldReadFunction<any>;
aiServer?: FieldPolicy<any> | FieldReadFunction<any>;
askChatGuidanceQuestion?: FieldPolicy<any> | FieldReadFunction<any>;
askVirtualContributorQuestion?: FieldPolicy<any> | FieldReadFunction<any>;
exploreSpaces?: FieldPolicy<any> | FieldReadFunction<any>;
getSupportedVerifiedCredentialMetadata?: FieldPolicy<any> | FieldReadFunction<any>;
inputCreator?: FieldPolicy<any> | FieldReadFunction<any>;
Expand Down Expand Up @@ -3535,6 +3528,7 @@ export type UserKeySpecifier = (
| 'directRooms'
| 'email'
| 'firstName'
| 'guidanceRoom'
| 'id'
| 'isContactable'
| 'lastName'
Expand All @@ -3557,6 +3551,7 @@ export type UserFieldPolicy = {
directRooms?: FieldPolicy<any> | FieldReadFunction<any>;
email?: FieldPolicy<any> | FieldReadFunction<any>;
firstName?: FieldPolicy<any> | FieldReadFunction<any>;
guidanceRoom?: FieldPolicy<any> | FieldReadFunction<any>;
id?: FieldPolicy<any> | FieldReadFunction<any>;
isContactable?: FieldPolicy<any> | FieldReadFunction<any>;
lastName?: FieldPolicy<any> | FieldReadFunction<any>;
Expand Down Expand Up @@ -4289,13 +4284,6 @@ export type StrictTypedTypePolicies = {
keyFields?: false | MessageAnswerQuestionKeySpecifier | (() => undefined | MessageAnswerQuestionKeySpecifier);
fields?: MessageAnswerQuestionFieldPolicy;
};
MessageAnswerToQuestionSource?: Omit<TypePolicy, 'fields' | 'keyFields'> & {
keyFields?:
| false
| MessageAnswerToQuestionSourceKeySpecifier
| (() => undefined | MessageAnswerToQuestionSourceKeySpecifier);
fields?: MessageAnswerToQuestionSourceFieldPolicy;
};
Metadata?: Omit<TypePolicy, 'fields' | 'keyFields'> & {
keyFields?: false | MetadataKeySpecifier | (() => undefined | MetadataKeySpecifier);
fields?: MetadataFieldPolicy;
Expand Down
211 changes: 181 additions & 30 deletions src/core/apollo/generated/apollo-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21883,70 +21883,221 @@ export type ResetChatGuidanceMutationOptions = Apollo.BaseMutationOptions<
SchemaTypes.ResetChatGuidanceMutation,
SchemaTypes.ResetChatGuidanceMutationVariables
>;
export const CreateGuidanceRoomDocument = gql`
mutation createGuidanceRoom {
createChatGuidanceRoom {
id
}
}
`;
export type CreateGuidanceRoomMutationFn = Apollo.MutationFunction<
SchemaTypes.CreateGuidanceRoomMutation,
SchemaTypes.CreateGuidanceRoomMutationVariables
>;

/**
* __useCreateGuidanceRoomMutation__
*
* To run a mutation, you first call `useCreateGuidanceRoomMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateGuidanceRoomMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createGuidanceRoomMutation, { data, loading, error }] = useCreateGuidanceRoomMutation({
* variables: {
* },
* });
*/
export function useCreateGuidanceRoomMutation(
baseOptions?: Apollo.MutationHookOptions<
SchemaTypes.CreateGuidanceRoomMutation,
SchemaTypes.CreateGuidanceRoomMutationVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useMutation<SchemaTypes.CreateGuidanceRoomMutation, SchemaTypes.CreateGuidanceRoomMutationVariables>(
CreateGuidanceRoomDocument,
options
);
}

export type CreateGuidanceRoomMutationHookResult = ReturnType<typeof useCreateGuidanceRoomMutation>;
export type CreateGuidanceRoomMutationResult = Apollo.MutationResult<SchemaTypes.CreateGuidanceRoomMutation>;
export type CreateGuidanceRoomMutationOptions = Apollo.BaseMutationOptions<
SchemaTypes.CreateGuidanceRoomMutation,
SchemaTypes.CreateGuidanceRoomMutationVariables
>;
export const AskChatGuidanceQuestionDocument = gql`
query askChatGuidanceQuestion($chatData: ChatGuidanceInput!) {
mutation askChatGuidanceQuestion($chatData: ChatGuidanceInput!) {
askChatGuidanceQuestion(chatData: $chatData) {
id
answer
question
sources {
uri
title
success
}
}
`;
export type AskChatGuidanceQuestionMutationFn = Apollo.MutationFunction<
SchemaTypes.AskChatGuidanceQuestionMutation,
SchemaTypes.AskChatGuidanceQuestionMutationVariables
>;

/**
* __useAskChatGuidanceQuestionMutation__
*
* To run a mutation, you first call `useAskChatGuidanceQuestionMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useAskChatGuidanceQuestionMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [askChatGuidanceQuestionMutation, { data, loading, error }] = useAskChatGuidanceQuestionMutation({
* variables: {
* chatData: // value for 'chatData'
* },
* });
*/
export function useAskChatGuidanceQuestionMutation(
baseOptions?: Apollo.MutationHookOptions<
SchemaTypes.AskChatGuidanceQuestionMutation,
SchemaTypes.AskChatGuidanceQuestionMutationVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useMutation<
SchemaTypes.AskChatGuidanceQuestionMutation,
SchemaTypes.AskChatGuidanceQuestionMutationVariables
>(AskChatGuidanceQuestionDocument, options);
}

export type AskChatGuidanceQuestionMutationHookResult = ReturnType<typeof useAskChatGuidanceQuestionMutation>;
export type AskChatGuidanceQuestionMutationResult = Apollo.MutationResult<SchemaTypes.AskChatGuidanceQuestionMutation>;
export type AskChatGuidanceQuestionMutationOptions = Apollo.BaseMutationOptions<
SchemaTypes.AskChatGuidanceQuestionMutation,
SchemaTypes.AskChatGuidanceQuestionMutationVariables
>;
export const GuidanceRoomIdDocument = gql`
query GuidanceRoomId {
me {
user {
id
guidanceRoom {
id
}
}
}
}
`;

/**
* __useAskChatGuidanceQuestionQuery__
* __useGuidanceRoomIdQuery__
*
* To run a query within a React component, call `useAskChatGuidanceQuestionQuery` and pass it any options that fit your needs.
* When your component renders, `useAskChatGuidanceQuestionQuery` returns an object from Apollo Client that contains loading, error, and data properties
* To run a query within a React component, call `useGuidanceRoomIdQuery` and pass it any options that fit your needs.
* When your component renders, `useGuidanceRoomIdQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAskChatGuidanceQuestionQuery({
* const { data, loading, error } = useGuidanceRoomIdQuery({
* variables: {
* chatData: // value for 'chatData'
* },
* });
*/
export function useAskChatGuidanceQuestionQuery(
export function useGuidanceRoomIdQuery(
baseOptions?: Apollo.QueryHookOptions<SchemaTypes.GuidanceRoomIdQuery, SchemaTypes.GuidanceRoomIdQueryVariables>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<SchemaTypes.GuidanceRoomIdQuery, SchemaTypes.GuidanceRoomIdQueryVariables>(
GuidanceRoomIdDocument,
options
);
}

export function useGuidanceRoomIdLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<SchemaTypes.GuidanceRoomIdQuery, SchemaTypes.GuidanceRoomIdQueryVariables>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<SchemaTypes.GuidanceRoomIdQuery, SchemaTypes.GuidanceRoomIdQueryVariables>(
GuidanceRoomIdDocument,
options
);
}

export type GuidanceRoomIdQueryHookResult = ReturnType<typeof useGuidanceRoomIdQuery>;
export type GuidanceRoomIdLazyQueryHookResult = ReturnType<typeof useGuidanceRoomIdLazyQuery>;
export type GuidanceRoomIdQueryResult = Apollo.QueryResult<
SchemaTypes.GuidanceRoomIdQuery,
SchemaTypes.GuidanceRoomIdQueryVariables
>;
export function refetchGuidanceRoomIdQuery(variables?: SchemaTypes.GuidanceRoomIdQueryVariables) {
return { query: GuidanceRoomIdDocument, variables: variables };
}

export const GuidanceRoomMessagesDocument = gql`
query GuidanceRoomMessages($roomId: UUID!) {
lookup {
room(ID: $roomId) {
...CommentsWithMessages
}
}
}
${CommentsWithMessagesFragmentDoc}
`;

/**
* __useGuidanceRoomMessagesQuery__
*
* To run a query within a React component, call `useGuidanceRoomMessagesQuery` and pass it any options that fit your needs.
* When your component renders, `useGuidanceRoomMessagesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useGuidanceRoomMessagesQuery({
* variables: {
* roomId: // value for 'roomId'
* },
* });
*/
export function useGuidanceRoomMessagesQuery(
baseOptions: Apollo.QueryHookOptions<
SchemaTypes.AskChatGuidanceQuestionQuery,
SchemaTypes.AskChatGuidanceQuestionQueryVariables
SchemaTypes.GuidanceRoomMessagesQuery,
SchemaTypes.GuidanceRoomMessagesQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<SchemaTypes.AskChatGuidanceQuestionQuery, SchemaTypes.AskChatGuidanceQuestionQueryVariables>(
AskChatGuidanceQuestionDocument,
return Apollo.useQuery<SchemaTypes.GuidanceRoomMessagesQuery, SchemaTypes.GuidanceRoomMessagesQueryVariables>(
GuidanceRoomMessagesDocument,
options
);
}

export function useAskChatGuidanceQuestionLazyQuery(
export function useGuidanceRoomMessagesLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
SchemaTypes.AskChatGuidanceQuestionQuery,
SchemaTypes.AskChatGuidanceQuestionQueryVariables
SchemaTypes.GuidanceRoomMessagesQuery,
SchemaTypes.GuidanceRoomMessagesQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<
SchemaTypes.AskChatGuidanceQuestionQuery,
SchemaTypes.AskChatGuidanceQuestionQueryVariables
>(AskChatGuidanceQuestionDocument, options);
return Apollo.useLazyQuery<SchemaTypes.GuidanceRoomMessagesQuery, SchemaTypes.GuidanceRoomMessagesQueryVariables>(
GuidanceRoomMessagesDocument,
options
);
}

export type AskChatGuidanceQuestionQueryHookResult = ReturnType<typeof useAskChatGuidanceQuestionQuery>;
export type AskChatGuidanceQuestionLazyQueryHookResult = ReturnType<typeof useAskChatGuidanceQuestionLazyQuery>;
export type AskChatGuidanceQuestionQueryResult = Apollo.QueryResult<
SchemaTypes.AskChatGuidanceQuestionQuery,
SchemaTypes.AskChatGuidanceQuestionQueryVariables
export type GuidanceRoomMessagesQueryHookResult = ReturnType<typeof useGuidanceRoomMessagesQuery>;
export type GuidanceRoomMessagesLazyQueryHookResult = ReturnType<typeof useGuidanceRoomMessagesLazyQuery>;
export type GuidanceRoomMessagesQueryResult = Apollo.QueryResult<
SchemaTypes.GuidanceRoomMessagesQuery,
SchemaTypes.GuidanceRoomMessagesQueryVariables
>;
export function refetchAskChatGuidanceQuestionQuery(variables: SchemaTypes.AskChatGuidanceQuestionQueryVariables) {
return { query: AskChatGuidanceQuestionDocument, variables: variables };
export function refetchGuidanceRoomMessagesQuery(variables: SchemaTypes.GuidanceRoomMessagesQueryVariables) {
return { query: GuidanceRoomMessagesDocument, variables: variables };
}

export const JourneyRouteResolverDocument = gql`
Expand Down
Loading

0 comments on commit 97879b8

Please sign in to comment.