anewryzm commited on
Commit
02ab833
Β·
verified Β·
1 Parent(s): 75b1177

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -38,3 +38,5 @@ temp_files/313511c1-b8bb-4c2a-8ace-777b3bbd01a8.m4a filter=lfs diff=lfs merge=lf
38
  temp_files/d612cbb0-1910-44f6-b4a8-9ccee4af0a52.m4a filter=lfs diff=lfs merge=lfs -text
39
  test_files/hi.wav filter=lfs diff=lfs merge=lfs -text
40
  test_files/hello-mcp.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
38
  temp_files/d612cbb0-1910-44f6-b4a8-9ccee4af0a52.m4a filter=lfs diff=lfs merge=lfs -text
39
  test_files/hi.wav filter=lfs diff=lfs merge=lfs -text
40
  test_files/hello-mcp.wav filter=lfs diff=lfs merge=lfs -text
41
+ test_files/sell[[:space:]]authentically.mp4 filter=lfs diff=lfs merge=lfs -text
42
+ test_files/this[[:space:]]people[[:space:]]3.m4a filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -155,28 +155,44 @@ def chat_with_tools(user_message, history, user_groq_api_key, user_anthropic_api
155
  content=transcription_result,
156
  metadata={"title": "❌ Error", "status": "done"}
157
  ))
 
 
158
  else:
159
- # Add tool result to history
160
  history.append(ChatMessage(
161
  role="assistant",
162
  content=f"**Transcription Result:**\n\n{transcription_result}",
163
  metadata={"title": "πŸŽ™οΈ Transcription", "status": "done"}
164
  ))
165
  transcription_performed = True
 
166
 
167
- # Add the transcription result to messages for Claude to be aware of it
168
- messages.append({
169
- "role": "assistant",
170
- "content": f"I've transcribed the audio from the URL. Here's the result:\n\n{transcription_result}"
171
- })
172
-
173
- # Add a user message to prompt Claude to respond to the transcription
174
- messages.append({
175
- "role": "user",
176
- "content": "Please analyze this transcription and provide your thoughts or follow-up on my original request."
177
- })
178
-
179
- yield history
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  except Exception as e:
181
  import traceback
182
  error_details = traceback.format_exc()
@@ -188,6 +204,7 @@ def chat_with_tools(user_message, history, user_groq_api_key, user_anthropic_api
188
  metadata={"title": "❌ Error", "status": "done"}
189
  ))
190
  yield history
 
191
  # Manual transcript request without URL
192
  elif transcript_request and not audio_url:
193
  history.append(ChatMessage(
@@ -198,9 +215,8 @@ def chat_with_tools(user_message, history, user_groq_api_key, user_anthropic_api
198
  yield history
199
  return
200
 
201
- # 3. Claude response phase - only if we haven't returned early
202
  try:
203
- # If transcription was performed, Claude will now respond to the transcription
204
  response = client.messages.create(
205
  model="claude-3-7-sonnet-latest",
206
  max_tokens=4096,
@@ -208,14 +224,7 @@ def chat_with_tools(user_message, history, user_groq_api_key, user_anthropic_api
208
  )
209
 
210
  response_content = response.content[0].text
211
-
212
- # For clarity in the UI, if transcription was performed,
213
- # we can add a prefix to indicate Claude is responding to the transcription
214
- if transcription_performed:
215
- prefix = "**Analysis of the transcription:**\n\n"
216
- history.append(ChatMessage(role="assistant", content=prefix + response_content))
217
- else:
218
- history.append(ChatMessage(role="assistant", content=response_content))
219
  except Exception as e:
220
  history.append(ChatMessage(
221
  role="assistant",
 
155
  content=transcription_result,
156
  metadata={"title": "❌ Error", "status": "done"}
157
  ))
158
+ yield history
159
+ return
160
  else:
161
+ # Add transcript result to history
162
  history.append(ChatMessage(
163
  role="assistant",
164
  content=f"**Transcription Result:**\n\n{transcription_result}",
165
  metadata={"title": "πŸŽ™οΈ Transcription", "status": "done"}
166
  ))
167
  transcription_performed = True
168
+ yield history
169
 
170
+ # Now let Claude respond to the transcript
171
+ try:
172
+ # Create a new prompt for Claude to respond to the transcript
173
+ claude_prompt = f"You've just transcribed this audio for the user:\n\n{transcription_result}\n\nPlease respond to the user about this transcript."
174
+
175
+ # Send request to Claude
176
+ response = client.messages.create(
177
+ model="claude-3-7-sonnet-latest",
178
+ max_tokens=4096,
179
+ system="You are a helpful assistant that can transcribe audio using MCP tools and respond to user queries. The way you can generate transcripts is using receiving audio URLs and processing them with GROQ API. When you respond to the user, always provide a clear and concise answer. You don't add unnecesary analysis or comments, unless the user asks you for it. Then you add follow up questions to the user about if they need to do something with the transcript.",
180
+ messages=[{"role": "user", "content": claude_prompt}]
181
+ )
182
+
183
+ # Add Claude's response to history
184
+ response_content = response.content[0].text
185
+ history.append(ChatMessage(role="assistant", content=response_content))
186
+ yield history
187
+ return
188
+ except Exception as e:
189
+ history.append(ChatMessage(
190
+ role="assistant",
191
+ content=f"Error generating response to transcript: {str(e)}",
192
+ metadata={"title": "❌ Error", "status": "done"}
193
+ ))
194
+ yield history
195
+ return
196
  except Exception as e:
197
  import traceback
198
  error_details = traceback.format_exc()
 
204
  metadata={"title": "❌ Error", "status": "done"}
205
  ))
206
  yield history
207
+ return
208
  # Manual transcript request without URL
209
  elif transcript_request and not audio_url:
210
  history.append(ChatMessage(
 
215
  yield history
216
  return
217
 
218
+ # 3. Claude response phase - only for non-transcription requests
219
  try:
 
220
  response = client.messages.create(
221
  model="claude-3-7-sonnet-latest",
222
  max_tokens=4096,
 
224
  )
225
 
226
  response_content = response.content[0].text
227
+ history.append(ChatMessage(role="assistant", content=response_content))
 
 
 
 
 
 
 
228
  except Exception as e:
229
  history.append(ChatMessage(
230
  role="assistant",
test_files/sell authentically.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e959ee72a753493c862315807a07d858e7e01245199576040efb01b3fb05debf
3
+ size 3024521
test_files/this people 3.m4a ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00b8c5937838debb7df2bb7da7da3295bdb76c55bfb701c45460df72f8d39c6d
3
+ size 430861