Spaces:
Sleeping
Sleeping
Commit Β·
832c6b9
1
Parent(s): 7a49157
first checking commit
Browse files- app.py +75 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# Gemini AI ni sozlash
|
| 5 |
+
genai.configure(api_key=os.environ.get('GEMINI_API_KEY'))
|
| 6 |
+
model = genai.GenerativeModel('gemini-2.5-flash')
|
| 7 |
+
|
| 8 |
+
def get_counter_debuts(opponent_debuts):
|
| 9 |
+
"""Raqib debyutlariga qarshi eng yaxshi debyutlarni olish"""
|
| 10 |
+
|
| 11 |
+
prompt = f"""
|
| 12 |
+
Siz professional shaxmat murabbiyisiz. Raqib quyidagi debyutlarni o'ynaydi:
|
| 13 |
+
|
| 14 |
+
{opponent_debuts}
|
| 15 |
+
|
| 16 |
+
Ushbu debyutlarga qarshi eng samarali qarshi debyutlarni tavsiya qiling.
|
| 17 |
+
Har bir debyt uchun:
|
| 18 |
+
1. Qarshi debyt nomi
|
| 19 |
+
2. Qisqacha tushuntirish (2-3 jumla)
|
| 20 |
+
3. Asosiy g'oya va rejalar
|
| 21 |
+
|
| 22 |
+
Javobni o'zbek tilida bering. Aniq va tushunarli yozing.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
try:
|
| 26 |
+
response = model.generate_content(prompt)
|
| 27 |
+
return response.text
|
| 28 |
+
except Exception as e:
|
| 29 |
+
return f"Xatolik yuz berdi: {str(e)}"
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
print("=" * 60)
|
| 33 |
+
print("π SHAXMAT DEBYUT MASLAHATCHI π")
|
| 34 |
+
print("=" * 60)
|
| 35 |
+
print()
|
| 36 |
+
|
| 37 |
+
while True:
|
| 38 |
+
print("\nπ Raqibingiz qanday debyutlarni o'ynaydi?")
|
| 39 |
+
print("(Bir nechta debyutni vergul bilan ajratib kiriting)")
|
| 40 |
+
print("Misol: Italian oyini, Fransuz mudofaasi, Grunfeld")
|
| 41 |
+
print()
|
| 42 |
+
|
| 43 |
+
opponent_debuts = input("Debyutlar: ").strip()
|
| 44 |
+
|
| 45 |
+
if not opponent_debuts:
|
| 46 |
+
print("\nβ Iltimos, kamida bitta debyt kiriting!")
|
| 47 |
+
continue
|
| 48 |
+
|
| 49 |
+
print("\nβ³ Tahlil qilinmoqda...")
|
| 50 |
+
print()
|
| 51 |
+
|
| 52 |
+
result = get_counter_debuts(opponent_debuts)
|
| 53 |
+
|
| 54 |
+
print("=" * 60)
|
| 55 |
+
print("π TAVSIYA ETILADIGAN QARSHI DEBYUTLAR")
|
| 56 |
+
print("=" * 60)
|
| 57 |
+
print()
|
| 58 |
+
print(result)
|
| 59 |
+
print()
|
| 60 |
+
print("=" * 60)
|
| 61 |
+
|
| 62 |
+
# Yana bir bor so'rash
|
| 63 |
+
choice = input("\nπ Yana tahlil qilishni xohlaysizmi? (ha/yo'q): ").strip().lower()
|
| 64 |
+
|
| 65 |
+
if choice not in ['ha', 'xa', 'h', 'yes', 'y']:
|
| 66 |
+
print("\nβ
Omad tilaymiz! Yaxshi o'ynang! π―")
|
| 67 |
+
break
|
| 68 |
+
|
| 69 |
+
if __name__ == "__main__":
|
| 70 |
+
# API kalitini tekshirish
|
| 71 |
+
if not os.environ.get('GEMINI_API_KEY'):
|
| 72 |
+
print("β οΈ GEMINI_API_KEY muhit o'zgaruvchisini o'rnating!")
|
| 73 |
+
print("Misol: export GEMINI_API_KEY='sizning_kalitingiz'")
|
| 74 |
+
else:
|
| 75 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
google-generativeai>=0.3.0
|