Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,7 +82,17 @@ def create_ppt_from_modules(modules, output_file, aspect_ratio="16:9"):
|
|
| 82 |
# Funkcja do generowania treści prezentacji za pomocą OpenAI
|
| 83 |
def generate_presentation_content_openai(prompt, api_key, progress_bar, progress_text):
|
| 84 |
try:
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# Ustaw streamowanie dla postępu
|
| 88 |
response = client.chat.completions.create(
|
|
@@ -92,7 +102,7 @@ def generate_presentation_content_openai(prompt, api_key, progress_bar, progress
|
|
| 92 |
{"role": "user", "content": prompt}
|
| 93 |
],
|
| 94 |
stream=True,
|
| 95 |
-
max_tokens=
|
| 96 |
)
|
| 97 |
|
| 98 |
# Aktualizacja paska postępu i wyświetlanie generowanej treści
|
|
|
|
| 82 |
# Funkcja do generowania treści prezentacji za pomocą OpenAI
|
| 83 |
def generate_presentation_content_openai(prompt, api_key, progress_bar, progress_text):
|
| 84 |
try:
|
| 85 |
+
# Konfiguracja sesji z proxy (tylko jeśli wymagane)
|
| 86 |
+
session = requests.Session()
|
| 87 |
+
session.proxies = {
|
| 88 |
+
"http": os.getenv("HTTP_PROXY", ""),
|
| 89 |
+
"https": os.getenv("HTTPS_PROXY", "")
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
client = openai.OpenAI(
|
| 93 |
+
api_key=api_key,
|
| 94 |
+
http_client=session # Przekazanie sesji
|
| 95 |
+
)
|
| 96 |
|
| 97 |
# Ustaw streamowanie dla postępu
|
| 98 |
response = client.chat.completions.create(
|
|
|
|
| 102 |
{"role": "user", "content": prompt}
|
| 103 |
],
|
| 104 |
stream=True,
|
| 105 |
+
max_tokens=80000
|
| 106 |
)
|
| 107 |
|
| 108 |
# Aktualizacja paska postępu i wyświetlanie generowanej treści
|