mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-21 06:35:02 +01:00
switched to in memory file
This commit is contained in:
@@ -10,7 +10,7 @@ import openai
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import httpx
|
import httpx
|
||||||
import tempfile
|
import io
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from calendar import monthrange
|
from calendar import monthrange
|
||||||
|
|
||||||
@@ -350,8 +350,9 @@ class OpenAIHelper:
|
|||||||
response_format='opus'
|
response_format='opus'
|
||||||
)
|
)
|
||||||
|
|
||||||
temp_file = tempfile.NamedTemporaryFile()
|
temp_file = io.BytesIO()
|
||||||
response.stream_to_file(temp_file.name)
|
temp_file.write(response.read())
|
||||||
|
temp_file.seek(0)
|
||||||
return temp_file, len(text)
|
return temp_file, len(text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"⚠️ _{localized_text('error', bot_language)}._ ⚠️\n{str(e)}") from e
|
raise Exception(f"⚠️ _{localized_text('error', bot_language)}._ ⚠️\n{str(e)}") from e
|
||||||
|
|||||||
Reference in New Issue
Block a user