Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
chat histopry
Murtaza Nasir9ee2dfa9c5c6
diff --git a/app.py b/app.pyindex c16c88c2..50e90d81 100644--- a/app.py+++ b/app.py@@ -266,6 +266,7 @@ def chat_with_transcription():recording_id = data.get('recording_id')user_message = data.get('message')+ message_history = data.get('message_history', [])if not recording_id:return jsonify({'error': 'No recording ID provided'}), 400@@ -298,12 +299,19 @@ Additional context and notes about the meeting:# Call the LLMtry:+ # Prepare messages array with system prompt and conversation history+ messages = [{"role": "system", "content": system_prompt}]++ # Add message history if provided+ if message_history:+ messages.extend(message_history)++ # Add the current user message+ messages.append({"role": "user", "content": user_message})+completion = client.chat.completions.create(model=openrouter_model_name,- messages=[- {"role": "system", "content": system_prompt},- {"role": "user", "content": user_message}- ],+ messages=messages,temperature=0.7,max_tokens=1000)diff --git a/templates/index.html b/templates/index.htmlindex 201c229b..26bb3521 100644--- a/templates/index.html+++ b/templates/index.html@@ -1159,12 +1159,22 @@}try {+ // Prepare message history for the API call+ // We need to convert our UI messages to the format expected by the API+ const messageHistory = chatMessages.value+ .slice(0, -1) // Exclude the message we just added (it will be sent separately)+ .map(msg => ({+ role: msg.role,+ content: msg.content+ }));+const response = await fetch('/chat', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({recording_id: selectedRecording.value.id,- message: message+ message: message,+ message_history: messageHistory})});