1515from indico .modules .categories .controllers .base import RHManageCategoryBase
1616from indico .modules .events .management .controllers .base import RHManageEventBase
1717from indico .modules .events .notes .util import get_scheduled_notes
18+ from indico .util .string import sanitize_html
1819
1920from indico_ai_summary .llm_interface import LLMInterface
2021from indico_ai_summary .models .prompt import Prompt
2122from indico_ai_summary .schemas import PromptSchema
22- from indico_ai_summary .utils import MarkupMode , chunk_text , convert_markup , generate_chunk_stream
23+ from indico_ai_summary .utils import chunk_text , markdown_to_html , html_to_markdown , generate_chunk_stream
2324from indico_ai_summary .views import WPCategoryManagePrompts
2425
2526
2627CATEGORY_SIDEMENU_ITEM = 'plugin_ai_summary_prompts'
2728
2829
2930class RHManageCategoryPrompts (RHManageCategoryBase ):
30-
3131 def _process_args (self ):
3232 RHManageCategoryBase ._process_args (self )
3333
@@ -47,25 +47,18 @@ def _process_POST(self, prompts):
4747 return '' , 204
4848
4949
50- class SummarizeEvent (RHManageEventBase ):
51-
52- CSRF_ENABLED = False
53-
54- def _process_args (self ):
55- RHManageEventBase ._process_args (self )
56-
57- @use_kwargs ({'prompt' : fields .Str (load_default = '' )}, location = 'json' )
50+ class RHSummarizeEvent (RHManageEventBase ):
51+ @use_kwargs ({'prompt' : fields .Str (required = True )})
5852 def _process (self , prompt ):
59- event = self .event
60- prompt_template = prompt .strip ()
61- notes = get_scheduled_notes (event )
53+ prompt_template = prompt
54+ notes = get_scheduled_notes (self .event )
6255 meeting_notes = '\n \n ' .join (note .html for note in notes if hasattr (note , 'html' ))
6356
6457 if not meeting_notes .strip ():
6558 current_plugin .logger .error ("No meeting notes found from this event's contributions." )
6659 return jsonify ({'error' : "No meeting notes found from this event's contributions." }), 400
6760
68- cleaned_text = convert_markup (meeting_notes , MarkupMode . HTML_TO_MARKDOWN )
61+ cleaned_text = html_to_markdown (meeting_notes )
6962 chunks = chunk_text (cleaned_text )
7063 summaries = []
7164
@@ -74,14 +67,14 @@ def _process(self, prompt):
7467 return jsonify ({'error' : 'LLM Auth Token is not set in plugin settings.' }), 400
7568
7669 llm_model = LLMInterface (
77- model_name = current_plugin .settings .get ('llm_model_name' ),
78- host = current_plugin .settings .get ('llm_host_name ' ),
79- url = current_plugin .settings .get ('llm_provider_url' ),
80- auth_token = current_plugin .settings .get ('llm_auth_token' ),
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' )
84- )
70+ model_name = current_plugin .settings .get ('llm_model_name' ),
71+ host = current_plugin .settings .get ('llm_host_header ' ),
72+ url = current_plugin .settings .get ('llm_provider_url' ),
73+ auth_token = current_plugin .settings .get ('llm_auth_token' ),
74+ max_tokens = current_plugin .settings .get ('llm_max_tokens' ),
75+ temperature = current_plugin .settings .get ('llm_temperature' ),
76+ system_prompt = current_plugin .settings .get ('llm_system_prompt' ),
77+ )
8578
8679 if current_plugin .settings .get ('llm_stream_response' ):
8780 return Response (
@@ -103,8 +96,8 @@ def _process(self, prompt):
10396 summaries .append (response )
10497
10598 combined_summary = '\n ' .join (summaries )
106- html_output = convert_markup (combined_summary , MarkupMode . MARKDOWN_TO_HTML )
99+ html_output = markdown_to_html (combined_summary )
107100
108101 return {
109- 'summary_html' : html_output
102+ 'summary_html' : sanitize_html ( html_output )
110103 }
0 commit comments