Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -134,18 +134,22 @@ def predict(audio_file_pth, agree):
|
|
134 |
language = 'English'
|
135 |
speaker_style = 'default'
|
136 |
|
|
|
137 |
# Generate response using OpenAI GPT-4
|
138 |
try:
|
139 |
-
response =
|
140 |
model="gpt-4o-mini",
|
141 |
messages=[
|
142 |
{"role": "system", "content": "You are Mickey Mouse, a friendly and cheerful character who responds to children's queries in a simple and engaging manner. Please keep your response up to 200 characters."},
|
143 |
{"role": "user", "content": input_text}
|
144 |
],
|
145 |
max_tokens=200,
|
|
|
|
|
146 |
temperature=0.7,
|
147 |
)
|
148 |
-
|
|
|
149 |
print(f"GPT-4 Reply: {reply_text}")
|
150 |
except Exception as e:
|
151 |
text_hint += f"[ERROR] Failed to get response from OpenAI GPT-4: {str(e)}\n"
|
|
|
134 |
language = 'English'
|
135 |
speaker_style = 'default'
|
136 |
|
137 |
+
# Generate response using OpenAI GPT-4
|
138 |
# Generate response using OpenAI GPT-4
|
139 |
try:
|
140 |
+
response = client.chat.completions.create(
|
141 |
model="gpt-4o-mini",
|
142 |
messages=[
|
143 |
{"role": "system", "content": "You are Mickey Mouse, a friendly and cheerful character who responds to children's queries in a simple and engaging manner. Please keep your response up to 200 characters."},
|
144 |
{"role": "user", "content": input_text}
|
145 |
],
|
146 |
max_tokens=200,
|
147 |
+
n=1,
|
148 |
+
stop=None,
|
149 |
temperature=0.7,
|
150 |
)
|
151 |
+
# Correctly access the response content
|
152 |
+
reply_text = response.choices[0].message.content.strip()
|
153 |
print(f"GPT-4 Reply: {reply_text}")
|
154 |
except Exception as e:
|
155 |
text_hint += f"[ERROR] Failed to get response from OpenAI GPT-4: {str(e)}\n"
|