Skip to content

Commit 7a051ab

Browse files
Clean up llm_interface
* Use generic llm class for all requests * Add model temperature and system prompt settings * Make save button more prominent on summarizer UI * Tidy up some files
1 parent 39b1b53 commit 7a051ab

11 files changed

Lines changed: 105 additions & 276 deletions

File tree

ai_summary/indico_ai_summary/client/components/ActionButtons.jsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import '../styles/ind_summarize_button.module.scss';
1414
export default function ActionButtons({loading, error, summaryHtml, saving, onSave, onRetry}) {
1515

1616
const [isCopied, setIsCopied] = useState(false);
17+
const [showSavedIcon, setShowSavedIcon] = useState(false);
18+
const [prevSaving, setPrevSaving] = useState(false);
1719

1820
useEffect(() => {
1921
if (isCopied) {
@@ -22,19 +24,19 @@ export default function ActionButtons({loading, error, summaryHtml, saving, onSa
2224
}
2325
}, [isCopied]);
2426

27+
useEffect(() => {
28+
if (prevSaving && !saving) {
29+
setShowSavedIcon(true);
30+
const timer = setTimeout(() => setShowSavedIcon(false), 2000);
31+
return () => clearTimeout(timer);
32+
}
33+
setPrevSaving(saving);
34+
}, [saving, prevSaving]);
35+
2536
if (!loading) {
2637
return (
38+
<div styleName="action-buttons-container">
2739
<ButtonGroup basic>
28-
{summaryHtml && !error && (
29-
<Popup trigger={
30-
<Button icon onClick={onSave} disabled={saving}>
31-
{saving ? <Icon name="spinner" loading /> : <Icon name="save" />}
32-
</Button>
33-
}
34-
content={saving ? Translate.string('Saving summary...') : Translate.string('Save the generated summary to the meeting minutes')}
35-
position="top center"
36-
/>
37-
)}
3840
{summaryHtml && !error && (
3941
<Popup trigger={
4042
<Button
@@ -63,6 +65,30 @@ export default function ActionButtons({loading, error, summaryHtml, saving, onSa
6365
position="top center"
6466
/>
6567
</ButtonGroup>
68+
69+
{summaryHtml && !error && (
70+
<Popup trigger={
71+
<Button primary={!showSavedIcon} basic={showSavedIcon} icon onClick={onSave} disabled={saving} styleName="save-button">
72+
{saving ? (
73+
<Icon name="spinner" loading />
74+
) : showSavedIcon ? (
75+
<Icon name="check" color="green" />
76+
) : (
77+
<Icon name="save" />
78+
)}
79+
</Button>
80+
}
81+
content={
82+
saving
83+
? Translate.string('Saving summary...')
84+
: showSavedIcon
85+
? Translate.string('Saved!')
86+
: Translate.string('Save the generated summary to the meeting minutes')
87+
}
88+
position="top center"
89+
/>
90+
)}
91+
</div>
6692
);
6793
}
6894

ai_summary/indico_ai_summary/client/components/SummaryPreview.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function SummaryPreview({loading, error, summaryHtml, saving, onS
2727
}, [streamResponse, summaryHtml, error]);
2828

2929
const scrollBarStyle = loading && !error ? "preview-card-wrapper scrollbar-hidden" : "preview-card-wrapper";
30-
const displayedHtml = summaryHtml ? (error ? summaryHtml.substring(0, 1200) : summaryHtml) : null;
30+
const displayedHtml = summaryHtml ? (error ? summaryHtml.substring(0, 1000) : summaryHtml) : null;
3131

3232
if (!loading && !error && !summaryHtml) {
3333
return (

ai_summary/indico_ai_summary/client/components/ind_summarize_button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function SummarizeButton({categoryId, eventId, storedPrompts, streamResponse, ll
119119
// save combined notes(or previous summary) + summary back to Indico
120120
await saveSummaryToEvent(eventId, updatedHtml, noteData.id);
121121
} catch (e) {
122-
setError(`Error during saving summary: ${handleAxiosError(e)}`);
122+
setError(`Error during saving summary: ${handleAxiosError(e)}.`);
123123
} finally {
124124
setSaving(false);
125125
}

ai_summary/indico_ai_summary/client/services/summarize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function streamSummary(eventId, prompt, {onChunk, onDone, onError} = {})
7474
}
7575
// Otherwise, we were in the middle of streaming and lost connection
7676
if (onError) {
77-
onError('Connection lost while streaming summary.');
77+
onError('Connection lost whilst streaming summary.');
7878
}
7979
};
8080

ai_summary/indico_ai_summary/client/styles/ind_summarize_button.module.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,13 @@
161161
color: $dark-gray;
162162
}
163163
}
164+
165+
.action-buttons-container {
166+
display: flex;
167+
align-items: baseline;
168+
gap: 0;
169+
170+
.save-button {
171+
margin-left: 10px !important;
172+
}
173+
}

ai_summary/indico_ai_summary/client/utils/prompts.js

Lines changed: 0 additions & 84 deletions
This file was deleted.

ai_summary/indico_ai_summary/controllers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# them and/or modify them under the terms of the MIT License;
66
# see the LICENSE file for more details.
77

8-
from flask import jsonify, Response, stream_with_context
8+
from flask import Response, jsonify, stream_with_context
99
from flask_pluginengine import current_plugin
1010
from webargs import fields
1111
from webargs.flaskparser import use_kwargs
@@ -16,11 +16,11 @@
1616
from indico.modules.events.management.controllers.base import RHManageEventBase
1717
from indico.modules.events.notes.util import get_scheduled_notes
1818

19+
from indico_ai_summary.llm_interface import LLMInterface
1920
from indico_ai_summary.models.prompt import Prompt
2021
from indico_ai_summary.schemas import PromptSchema
21-
from indico_ai_summary.utils import chunk_text, convert_markup, MarkupMode, generate_chunk_stream
22+
from indico_ai_summary.utils import MarkupMode, chunk_text, convert_markup, generate_chunk_stream
2223
from indico_ai_summary.views import WPCategoryManagePrompts
23-
from indico_ai_summary.llm_interface import LLMInterface
2424

2525

2626
CATEGORY_SIDEMENU_ITEM = 'plugin_ai_summary_prompts'
@@ -78,7 +78,9 @@ def _process(self, prompt):
7878
host=current_plugin.settings.get('llm_host_name'),
7979
url=current_plugin.settings.get('llm_provider_url'),
8080
auth_token=current_plugin.settings.get('llm_auth_token'),
81-
max_tokens=current_plugin.settings.get('llm_max_tokens')
81+
max_tokens=current_plugin.settings.get('llm_max_tokens'),
82+
temperature=current_plugin.settings.get('llm_temperature'),
83+
system_prompt=current_plugin.settings.get('llm_system_prompt')
8284
)
8385

8486
if current_plugin.settings.get('llm_stream_response'):
@@ -87,7 +89,7 @@ def _process(self, prompt):
8789
content_type='text/event-stream',
8890
headers={
8991
'Cache-Control': 'no-cache',
90-
'X-Accel-Buffering': 'no'
92+
'X-Accel-Buffering': 'no' # Disable buffering for nginx
9193
}
9294
)
9395

0 commit comments

Comments
 (0)