yadongxie commited on
Commit
0b682de
1 Parent(s): 28391f7

fix: add conversation

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -80,6 +80,14 @@ def generate_response_and_audio(audio_bytes: bytes, state: AppState):
80
  format_ = state.output_format
81
  bitrate = 128 if format_ == "mp3" else 32 # Higher bitrate for MP3, lower for OPUS
82
  audio_data = base64.b64encode(audio_bytes).decode()
 
 
 
 
 
 
 
 
83
 
84
  try:
85
  stream = state.client.chat.completions.create(
@@ -90,9 +98,7 @@ def generate_response_and_audio(audio_bytes: bytes, state: AppState):
90
  "tts_audio_bitrate": bitrate,
91
  },
92
  model="llama3.1-8b",
93
- messages=[
94
- {"role": "user", "content": [{"type": "audio", "data": audio_data}]}
95
- ],
96
  temperature=0.7,
97
  max_tokens=256,
98
  stream=True,
 
80
  format_ = state.output_format
81
  bitrate = 128 if format_ == "mp3" else 32 # Higher bitrate for MP3, lower for OPUS
82
  audio_data = base64.b64encode(audio_bytes).decode()
83
+ old_messages = []
84
+
85
+ for item in state.conversation:
86
+ old_messages.append({"role": item["role"], "content": item["content"]})
87
+
88
+ old_messages.append(
89
+ {"role": "user", "content": [{"type": "audio", "data": audio_data}]}
90
+ )
91
 
92
  try:
93
  stream = state.client.chat.completions.create(
 
98
  "tts_audio_bitrate": bitrate,
99
  },
100
  model="llama3.1-8b",
101
+ messages=old_messages,
 
 
102
  temperature=0.7,
103
  max_tokens=256,
104
  stream=True,