Rooni commited on
Commit
0f41a05
·
verified ·
1 Parent(s): 131b6fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -18,7 +18,7 @@ MODEL_NAME = "openai"
18
  TEMPERATURE = 0.7
19
  MAX_TOKENS = 1500
20
 
21
- def call_pollinations_api(messages, temperature=TEMPERATURE, max_tokens=MAX_TOKENS, stream=True):
22
  headers = {
23
  "Content-Type": "application/json"
24
  }
@@ -40,7 +40,7 @@ def generate_story(prompt, style):
40
  ]
41
  try:
42
  # Получаем ответ целиком (stream=False)
43
- response = call_pollinations_api(messages, max_tokens=MAX_TOKENS, stream=True)
44
  full_response = response.json()
45
 
46
  # Если API вернул ошибку
@@ -69,7 +69,7 @@ def edit_story(original_story="", edited_prompt=""):
69
  {"role": "user", "content": f"История: ```\n{original_story}\n```"}
70
  ]
71
  try:
72
- response = call_pollinations_api(messages, max_tokens=32000, stream=True)
73
  full_response = response.json()
74
 
75
  if "error" in full_response:
@@ -103,7 +103,7 @@ def next_story_func(original_story="", next_prompt="", continuation_type="Про
103
  {"role": "user", "content": f"История: ```\n{original_story}\n```"}
104
  ]
105
  try:
106
- response = call_pollinations_api(messages, max_tokens=MAX_TOKENS, stream=True)
107
  full_response = response.json()
108
 
109
  if "error" in full_response:
 
18
  TEMPERATURE = 0.7
19
  MAX_TOKENS = 1500
20
 
21
+ def call_pollinations_api(messages, temperature=TEMPERATURE, max_tokens=MAX_TOKENS, stream=False):
22
  headers = {
23
  "Content-Type": "application/json"
24
  }
 
40
  ]
41
  try:
42
  # Получаем ответ целиком (stream=False)
43
+ response = call_pollinations_api(messages, max_tokens=MAX_TOKENS, stream=False)
44
  full_response = response.json()
45
 
46
  # Если API вернул ошибку
 
69
  {"role": "user", "content": f"История: ```\n{original_story}\n```"}
70
  ]
71
  try:
72
+ response = call_pollinations_api(messages, max_tokens=32000, stream=False)
73
  full_response = response.json()
74
 
75
  if "error" in full_response:
 
103
  {"role": "user", "content": f"История: ```\n{original_story}\n```"}
104
  ]
105
  try:
106
+ response = call_pollinations_api(messages, max_tokens=MAX_TOKENS, stream=False)
107
  full_response = response.json()
108
 
109
  if "error" in full_response: