switched to in memory file

This commit is contained in:
gilcu3
2023-11-09 18:07:31 +01:00
parent d637e35498
commit bc1a3f38a1

View File

@@ -10,7 +10,7 @@ import openai
import requests
import json
import httpx
import tempfile
import io
from datetime import date
from calendar import monthrange
@@ -350,8 +350,9 @@ class OpenAIHelper:
response_format='opus'
)
temp_file = tempfile.NamedTemporaryFile()
response.stream_to_file(temp_file.name)
temp_file = io.BytesIO()
temp_file.write(response.read())
temp_file.seek(0)
return temp_file, len(text)
except Exception as e:
raise Exception(f"⚠️ _{localized_text('error', bot_language)}._ ⚠️\n{str(e)}") from e