MCPcopy Create free account
hub / github.com/TheDeepOpc/deepsec / api_settings

Method api_settings

deepsec-l1.py:869–912  ·  view source on GitHub ↗

API sozlamalari

(self)

Source from the content-addressed store, hash-verified

867 time.sleep(2)
868
869 def api_settings(self):
870 """API sozlamalari"""
871 self.print_banner()
872 print("⚙️ API CONFIGURATION")
873 print("="*50)
874
875 current_key = self.settings.get('api_key', '')
876 if current_key:
877 print(f"Current API Key: {current_key[:10]}...")
878 else:
879 print("No API key configured")
880
881 print("\n[1] Enter new API key")
882 print("[2] Load from .env file")
883 print("[3] Back")
884
885 choice = input("\n[1-3]: ").strip()
886
887 if choice == '1':
888 new_key = getpass.getpass("Enter new API key: ").strip()
889 if new_key:
890 self.settings['api_key'] = new_key
891 # .env fayliga saqlash
892 with open(".env", "w") as f:
893 f.write(f'GROQ_API_KEY="{new_key}"\n')
894 self.save_settings()
895 print("✅ API key saved!")
896 else:
897 print("❌ No key entered")
898
899 elif choice == '2':
900 if os.path.exists(".env"):
901 with open(".env", "r") as f:
902 for line in f:
903 if line.startswith("GROQ_API_KEY="):
904 key = line.split("=", 1)[1].strip().strip('"').strip("'")
905 self.settings['api_key'] = key
906 self.save_settings()
907 print("✅ API key loaded from .env")
908 break
909 else:
910 print("❌ .env file not found")
911
912 time.sleep(2)
913
914 def help_menu(self):
915 """Yordam menyusi"""

Callers 1

settings_menuMethod · 0.95

Calls 2

print_bannerMethod · 0.95
save_settingsMethod · 0.95

Tested by

no test coverage detected