littlebird13 commited on
Commit
0d90efe
1 Parent(s): 2d29182

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -8,12 +8,15 @@ YOUR_API_TOKEN = os.getenv('YOUR_API_TOKEN')
8
  dashscope.api_key = YOUR_API_TOKEN
9
 
10
  def add_text(chatbot, task_history, input):
11
- """Add text to the chat history."""
 
12
  if len (input.files) > 0:
13
- audio_content = [{"audio": i.path } for i in input.files]
14
- task_history.append({"role": "user", "content": audio_content + [{"text": input.text}]})
15
- else:
16
- task_history.append({"role": "user", "content": [{"text": input.text}]})
 
 
17
  chatbot.append([{
18
  "text": input.text,
19
  "files": input.files,
 
8
  dashscope.api_key = YOUR_API_TOKEN
9
 
10
  def add_text(chatbot, task_history, input):
11
+ text_content = input.text
12
+ content = []
13
  if len (input.files) > 0:
14
+ for i in input.files:
15
+ content.append({'audio': i.path})
16
+ if text_content:
17
+ content.append({'text': text_content})
18
+ task_history.append({"role": "user", "content": content})
19
+
20
  chatbot.append([{
21
  "text": input.text,
22
  "files": input.files,