Adieva-15 commited on
Commit
9f9229d
·
1 Parent(s): aef3d4b

config.py fixed

Browse files
Files changed (2) hide show
  1. app.py +1 -38
  2. functions/chat.py +1 -0
app.py CHANGED
@@ -53,43 +53,6 @@ def index():
53
  elif action=="chat":
54
  pass
55
 
56
- # # ---------- Функции с фото ----------
57
- # elif action in ['colorize']:
58
- # if 'image' not in request.files:
59
- # error = "Файл не загружен"
60
- # else:
61
- # file = request.files['image']
62
- #
63
- # if file.filename=='':
64
- # error= "Файл не выбран"
65
- # else:
66
- # img_bytes=file.read()
67
- # try:
68
- # if action=='colorize':
69
- # # 1 Вызываем функцию раскрашивания
70
- # result_bytes = colorize_photo(img_bytes)
71
- #
72
- # # 2. Генерируем уникальное имя файла
73
- # filename = f"{uuid.uuid4().hex}.jpg"
74
- # filepath = os.path.join(RESULTS_FOLDER, filename)
75
- #
76
- # # 3. Сохраняем результат
77
- # with open(filepath, 'wb') as f:
78
- # f.write(result_bytes)
79
- #
80
- # if os.path.exists(filepath):
81
- # print(f"✅ Файл сохранён: {filepath}, размер: {os.path.getsize(filepath)}")
82
- # else:
83
- # print("❌ Файл не создан!")
84
- #
85
- # # 4. Передаём URL для отображения
86
- # result_image = f"/static/results/{filename}"
87
- # print("Результат сохранен")
88
- # # encoded = base64.b64encode(result_image=result_image,error=None)
89
- # # return send_file(io.BytesIO(result_bytes), mimetype='image/jpeg')
90
- # except Exception as e:
91
- # error = f"Ошибка обработки: {str(e)}"
92
-
93
  return render_template('index.html', result_text=result_text, error=error)
94
 
95
  @app.route('/chat', methods=['POST'])
@@ -98,7 +61,7 @@ def chat_endpoint():
98
  data = request.data.get_json()
99
  user_message=data.get('message', '').strip()
100
  if not user_message:
101
- return jsonify({'error':'сообщение не молжет пустым'})
102
 
103
  history = session.get('chat_history',[])
104
  reply, new_history=chat_with_agent(history, user_message)
 
53
  elif action=="chat":
54
  pass
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  return render_template('index.html', result_text=result_text, error=error)
57
 
58
  @app.route('/chat', methods=['POST'])
 
61
  data = request.data.get_json()
62
  user_message=data.get('message', '').strip()
63
  if not user_message:
64
+ return jsonify({'error':'сообщение не может быть пустым'})
65
 
66
  history = session.get('chat_history',[])
67
  reply, new_history=chat_with_agent(history, user_message)
functions/chat.py CHANGED
@@ -3,6 +3,7 @@ from openai import OpenAI
3
  from dotenv import load_dotenv
4
  load_dotenv()
5
  HF_TOKEN=os.getenv("HF_TOKEN","")
 
6
  if not HF_TOKEN:
7
  raise ValueError("Переменная окружения HF_TOKEN не установлена")
8
  model_chat="zai-org/GLM-5.2:novita"
 
3
  from dotenv import load_dotenv
4
  load_dotenv()
5
  HF_TOKEN=os.getenv("HF_TOKEN","")
6
+ print(f"HF_TOKEN exists: {bool(HF_TOKEN)}")
7
  if not HF_TOKEN:
8
  raise ValueError("Переменная окружения HF_TOKEN не установлена")
9
  model_chat="zai-org/GLM-5.2:novita"