Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| import os | |
| import sys | |
| from google import generativeai as genai | |
| from dotenv import load_dotenv | |
| def clear_screen(): | |
| """Terminal ekranını temizler.""" | |
| os.system('cls' if os.name == 'nt' else 'clear') | |
| # Load environment variables | |
| load_dotenv() | |
| # Configure Google API | |
| api_key = os.getenv("GOOGLE_API_KEY") | |
| if not api_key: | |
| print("HATA: GOOGLE_API_KEY bulunamadı!") | |
| print("Lütfen .env dosyasına API anahtarınızı ekleyin.") | |
| sys.exit(1) | |
| try: | |
| genai.configure(api_key=api_key) | |
| model = genai.GenerativeModel('gemini-3-flash-preview') | |
| chat = model.start_chat(history=[]) | |
| except Exception as e: | |
| print(f"HATA: Gemini API bağlantısı kurulamadı: {str(e)}") | |
| sys.exit(1) | |
| def main(): | |
| """Ana uygulama döngüsü.""" | |
| clear_screen() | |
| print("=" * 60) | |
| print(" CHATBOT PRO - Terminal Sürümü") | |
| print("=" * 60) | |
| print("Gemini AI ile sohbet etmeye başlayın.") | |
| print("Çıkmak için 'q' veya 'quit' yazın.") | |
| print("=" * 60) | |
| while True: | |
| user_input = input("\n\033[1mSiz:\033[0m ") | |
| if user_input.lower() in ['q', 'quit', 'exit', 'çıkış']: | |
| print("\nGörüşmek üzere!") | |
| break | |
| if not user_input.strip(): | |
| continue | |
| try: | |
| print("\n\033[1;34mChatBot Pro:\033[0m ", end="") | |
| response = chat.send_message(user_input) | |
| print(response.text) | |
| except Exception as e: | |
| print(f"\n\033[1;31mHATA: {str(e)}\033[0m") | |
| if __name__ == "__main__": | |
| main() |