Skip to content

Commit 310785e

Browse files
committed
Fix Replicate api initializing related issue
1 parent 83e79ac commit 310785e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pyqt_openai/replicate_widget/replicateRightSideBar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __initVal(self):
3636
self.__number_of_images_to_create = CONFIG_MANAGER.get_replicate_property('number_of_images_to_create')
3737
self.__save_prompt_as_text = CONFIG_MANAGER.get_replicate_property('save_prompt_as_text')
3838

39-
self.__wrapper = ReplicateWrapper(self.__api_key)
39+
self.__wrapper = ReplicateWrapper(self.__api_key.strip() if self.__api_key else '')
4040

4141
def __initUi(self):
4242
self.__apiKeyLineEdit = QLineEdit()
@@ -165,8 +165,10 @@ def __initUi(self):
165165
def __replicateChanged(self, v):
166166
sender = self.sender()
167167
if sender == self.__apiKeyLineEdit:
168+
v = v.strip() if v else ''
168169
self.__api_key = v
169170
CONFIG_MANAGER.set_replicate_property('REPLICATE_API_TOKEN', v)
171+
self.__wrapper.set_api(v)
170172
elif sender == self.__widthSpinBox:
171173
self.__width = v
172174
CONFIG_MANAGER.set_replicate_property('width', v)

pyqt_openai/util/replicate_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def set_api(self, api_key):
1818
:param api_key:
1919
:return:
2020
"""
21+
print("API KEY", api_key)
2122
self.__api_key = api_key
2223
os.environ['REPLICATE_API_TOKEN'] = self.__api_key
2324
return True

0 commit comments

Comments
 (0)