Skip to content

Commit

Permalink
Merge branch 'ai-react-for-me' into 'master'
Browse files Browse the repository at this point in the history
ai react for me button for posts

See merge request kchat/webapp!888
  • Loading branch information
antonbuks committed Aug 20, 2024
2 parents 75fb38b + 3d42f6e commit de40e8c
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 2 deletions.
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2694,6 +2694,7 @@
"air_gapped_modal.title": "Testschlüssel anfordern",
"ai.summarizeThread" : "Thread zusammenfassen",
"ai.actions" : "KI-Aktionen",
"ai.react_for_me": "Reagiere für mich",
"alert_banner.tooltipCloseBtn": "Schliessen",
"analytics.chart.loading": "Lade...",
"analytics.chart.meaningful": "Nicht genügend Daten für eine aussagekräftige Darstellung.",
Expand Down
5 changes: 3 additions & 2 deletions webapp/channels/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2778,8 +2778,9 @@
"air_gapped_modal.close": "Close",
"air_gapped_modal.description": "To start your trial, please visit {link} and request a trial key.",
"air_gapped_modal.title": "Request a trial key",
"ai.summarizeThread" : "Summarize thread",
"ai.actions" : "AI Actions",
"ai.summarizeThread": "Summarize thread",
"ai.actions": "AI Actions",
"ai.react_for_me": "React for me",
"admin.webserverModeUncompressedDescription": "The kChat server will serve static files uncompressed.",
"alert_banner.tooltipCloseBtn": "Close",
"analytics.chart.loading": "Loading...",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,7 @@
"admin_settings.save_unsaved_changes": "Por favor, guarde los cambios primero",
"ai.summarizeThread" : "Resumir hilo",
"ai.actions" : "Acciones IA",
"ai.react_for_me": "Reacciona por mí",
"analytics.chart.loading": "Cargando...",
"analytics.chart.meaningful": "No hay suficiente data para tener una representación significativa.",
"analytics.system.activeUsers": "Usuarios Activos con Mensajes",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,7 @@
"air_gapped_modal.title": "Demander une clé d’essai",
"ai.summarizeThread" : "Résumer le fil de discussion",
"ai.actions" : "Actions IA",
"ai.react_for_me": "Réagir pour moi",
"alert_banner.tooltipCloseBtn": "Fermer",
"analytics.chart.loading": "Chargement…",
"analytics.chart.meaningful": "Pas assez de données pour afficher une représentation pertinente.",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@
"analytics.chart.meaningful": "Dati insufficienti per una rappresentazione significativa.",
"ai.summarizeThread" : "Riassumi il thread",
"ai.actions" : "Azioni IA",
"ai.react_for_me": "Reagisci per me",
"analytics.system.activeUsers": "Utenti attivi con post",
"analytics.system.channelTypes": "Tipi di canale",
"analytics.system.dailyActiveUsers": "Utenti attivi quotidianamente",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';

import Svg from '../svg';

const IconReactForMe = () => (
<Svg
width='18'
height='18'
viewBox='0 0 18 18'
fill='none'
>
<path
d='M9.99899 9.99696C9.67912 9.99696 9.39764 9.87541 9.15454 9.63231C8.92424 9.38921 8.80909 9.10773 8.80909 8.78787C8.80909 8.468 8.92424 8.19292 9.15454 7.96261C9.39764 7.71952 9.67912 7.59797 9.99899 7.59797C10.3316 7.59797 10.6131 7.71952 10.8434 7.96261C11.0865 8.19292 11.2081 8.468 11.2081 8.78787C11.2081 9.10773 11.0865 9.38921 10.8434 9.63231C10.6131 9.87541 10.3316 9.99696 9.99899 9.99696ZM5.20101 9.99696C4.88115 9.99696 4.59966 9.87541 4.35657 9.63231C4.12626 9.38921 4.01111 9.10773 4.01111 8.78787C4.01111 8.468 4.12626 8.19292 4.35657 7.96261C4.59966 7.71952 4.88115 7.59797 5.20101 7.59797C5.53367 7.59797 5.81515 7.71952 6.04545 7.96261C6.28855 8.19292 6.4101 8.468 6.4101 8.78787C6.4101 9.10773 6.28855 9.38921 6.04545 9.63231C5.81515 9.87541 5.53367 9.99696 5.20101 9.99696ZM13.5687 9.92019C14.1061 9.84342 14.6242 9.67069 15.1232 9.40201C15.1744 9.83703 15.2 10.1697 15.2 10.4C15.2 11.769 14.8545 13.0485 14.1636 14.2384C13.4855 15.3771 12.5771 16.2855 11.4384 16.9636C10.2485 17.6545 8.96902 18 7.6 18C6.23098 18 4.95152 17.6545 3.76162 16.9636C2.6229 16.2983 1.71448 15.3899 1.03636 14.2384C0.345455 13.0613 0 11.7818 0 10.4C0 9.01817 0.345455 7.73871 1.03636 6.5616C1.71448 5.41009 2.6229 4.50167 3.76162 3.83635C4.95152 3.14544 6.23098 2.79999 7.6 2.79999C7.8303 2.79999 8.16296 2.82558 8.59798 2.87676C8.32929 3.37575 8.15657 3.89393 8.0798 4.4313C7.87508 4.40571 7.71515 4.39292 7.6 4.39292C6.51246 4.39292 5.50808 4.668 4.58687 5.21817C3.67845 5.75554 2.96195 6.47204 2.43737 7.36766C1.88721 8.30167 1.61212 9.31245 1.61212 10.4C1.61212 11.4875 1.88081 12.4919 2.41818 13.4131C2.95556 14.3215 3.67205 15.038 4.56768 15.5626C5.50168 16.1128 6.51246 16.3879 7.6 16.3879C8.68754 16.3879 9.69832 16.1128 10.6323 15.5626C11.5407 15.038 12.2572 14.3215 12.7818 13.4131C13.332 12.4919 13.6071 11.4875 13.6071 10.4C13.6071 10.2848 13.5943 10.1249 13.5687 9.92019ZM3.51212 11.9929H11.7071C11.3744 12.8246 10.837 13.5027 10.0949 14.0273C9.35286 14.539 8.52121 14.7949 7.6 14.7949C6.67879 14.7949 5.84714 14.539 5.10505 14.0273C4.36296 13.5027 3.83199 12.8246 3.51212 11.9929Z'
fill='var(--center-channel-color)'
fillOpacity='0.56'
/>
<path
d='M13.6 0.400024L12.72 3.52002L9.59998 4.40002L12.72 5.28003L13.6 8.40002L14.48 5.28003L17.6 4.40002L14.48 3.52002L13.6 0.400024Z'
fill='var(--center-channel-color)'
fillOpacity='0.56'
/>
</Svg>

);

export default IconReactForMe;
16 changes: 16 additions & 0 deletions webapp/channels/src/plugins/ai/components/post_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {handleEvent} from 'actions/websocket_actions';
import type {GlobalState} from 'types/store';

import IconAI from './assets/icon_ai';
import IconReactForMe from './assets/icon_react_for_me';
import IconThreadSummarization from './assets/icon_thread_summarization';
import {DropdownBotSelector} from './bot_slector';
import DotMenu, {DropdownMenu, DropdownMenuItem} from './dot_menu';
Expand Down Expand Up @@ -60,6 +61,14 @@ const PostMenu = (props: Props) => {
}
};

const reactForMe = async (postId: string) => {
try {
await Client4.doReaction(postId);
} catch (error) {
console.error('Error react post:', error);
}
};

// if (!isBasicsLicensed) {
// return null;
// }
Expand Down Expand Up @@ -95,6 +104,13 @@ const PostMenu = (props: Props) => {
</div>

</DropdownMenuItem>
<DropdownMenuItem onClick={() => reactForMe(post.id)}>
<span className='icon'><IconReactForMe/></span>
<FormattedMessage
id='ai.react_for_me'
defaultMessage='React for me'
/>
</DropdownMenuItem>
{/* <Divider/>
<DropdownInfoOnlyVisibleToYou/> */}
</DotMenu>
Expand Down
6 changes: 6 additions & 0 deletions webapp/platform/client/src/client4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4875,6 +4875,12 @@ export default class Client4 {
return this.doFetch(url, {method: 'post'});
}

async doReaction(postId: string) {
const url = `${this.getPostRoute(postId)}/react`;

return this.doFetch(url, {method: 'post'});
}

async doStopGenerating(postId: string) {
const url = `${this.getPostRoute(postId)}/stop`;

Expand Down

0 comments on commit de40e8c

Please sign in to comment.