11from PySide6 .QtWidgets import QVBoxLayout , QTableWidget , QHeaderView , QTableWidgetItem , QLabel , QLineEdit , QDialog , \
22 QDialogButtonBox
33
4+ from pyqt_openai import HOW_TO_GET_OPENAI_API_KEY_URL , HOW_TO_GET_CLAUDE_API_KEY_URL , HOW_TO_GET_GEMINI_API_KEY_URL , \
5+ HOW_TO_GET_LLAMA_API_KEY_URL
6+ from pyqt_openai .lang .translations import LangClass
7+ from pyqt_openai .widgets .linkLabel import LinkLabel
8+
49
510# FIXME Are there any ways to get authentification from the claude, gemini?
611# def is_api_key_valid(endpoint, api_key):
@@ -18,8 +23,20 @@ def __init__(self, api_keys: list, parent=None):
1823 def __initVal (self , api_keys ):
1924 self .__api_keys = api_keys
2025
26+ # Set "get api key" here
27+ for i , obj in enumerate (self .__api_keys ):
28+ obj ['get_api_key' ] = {
29+ 'OpenAI' : HOW_TO_GET_OPENAI_API_KEY_URL ,
30+ 'Claude' : HOW_TO_GET_CLAUDE_API_KEY_URL ,
31+ 'Gemini' : HOW_TO_GET_GEMINI_API_KEY_URL ,
32+ 'Llama' : HOW_TO_GET_LLAMA_API_KEY_URL
33+ }[obj ['display_name' ]]
34+
35+
2136 def __initUi (self ):
22- columns = ['Models' , 'API Key' ]
37+ self .setWindowTitle ('API Key' )
38+
39+ columns = ['Platform' , 'API Key' , 'Get API Key' ]
2340 self .__tableWidget = QTableWidget ()
2441 self .__tableWidget .setColumnCount (len (columns ))
2542 self .__tableWidget .setHorizontalHeaderLabels (columns )
@@ -35,6 +52,11 @@ def __initUi(self):
3552 apiKeyLineEdit .setEchoMode (QLineEdit .EchoMode .Password )
3653 self .__tableWidget .setCellWidget (i , 1 , apiKeyLineEdit )
3754
55+ getApiKeyLbl = LinkLabel ()
56+ getApiKeyLbl .setText ('Link' )
57+ getApiKeyLbl .setUrl (obj ['get_api_key' ])
58+ self .__tableWidget .setCellWidget (i , 2 , getApiKeyLbl )
59+
3860 # Dialog buttons
3961 buttonBox = QDialogButtonBox (QDialogButtonBox .Ok | QDialogButtonBox .Cancel )
4062 buttonBox .accepted .connect (self .accept )
0 commit comments