SamiKoen commited on
Commit
7b01f1b
·
verified ·
1 Parent(s): 253e59a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -786,34 +786,34 @@ def chatbot_fn(user_message, history, image=None):
786
 
787
  messages = system_messages + history + [{"role": "user", "content": user_message}]
788
 
789
- payload = {
790
- "model": "gpt-5.1-chat-latest",
791
- "messages": messages,
792
- "temperature": 0.0,
793
- "top_p": 1,
794
- "stream": True,
795
- "presence_penalty": 0,
796
- "frequency_penalty": 0,
797
- "n": 1,
798
- }
 
799
  headers = {
800
  "Content-Type": "application/json",
801
  "Authorization": f"Bearer {OPENAI_API_KEY}"
802
  }
803
-
804
- response = requests.post(API_URL, headers=headers, json=payload, stream=True)
805
 
806
- # HATA VARSA DETAYI GÖSTER
807
- if response.status_code != 200:
808
- try:
809
- print("\n\n🔴 OPENAI API ERROR")
810
- print("Status Code:", response.status_code)
811
- print("Response Body:", response.text, "\n\n")
812
- except Exception as e:
813
- print("Error printing OpenAI error:", e)
814
 
815
- yield f"API hatası: {response.status_code}\n{response.text}"
816
- return
 
 
 
 
 
 
 
 
817
 
818
 
819
  partial_response = ""
 
786
 
787
  messages = system_messages + history + [{"role": "user", "content": user_message}]
788
 
789
+ payload = {
790
+ "model": "gpt-5.1-chat-latest",
791
+ "messages": messages,
792
+ "temperature": 0.0,
793
+ "top_p": 1,
794
+ "stream": True,
795
+ "presence_penalty": 0,
796
+ "frequency_penalty": 0,
797
+ "n": 1,
798
+ }
799
+
800
  headers = {
801
  "Content-Type": "application/json",
802
  "Authorization": f"Bearer {OPENAI_API_KEY}"
803
  }
 
 
804
 
805
+ response = requests.post(API_URL, headers=headers, json=payload, stream=True)
 
 
 
 
 
 
 
806
 
807
+ # 🔥 YENİ EKLEDİĞİMİZ BLOK TAM BURAYA GELECEK
808
+ if response.status_code != 200:
809
+ try:
810
+ print("\n🔴 OPENAI API ERROR")
811
+ print("Status Code:", response.status_code)
812
+ print("Response Body:", response.text, "\n")
813
+ except:
814
+ pass
815
+ yield f"API hatası: {response.status_code}\n{response.text}"
816
+ return
817
 
818
 
819
  partial_response = ""