Skip to content

Commit 31a7390

Browse files
authored
Merge pull request #13 from F33RNI/next
Add base url to settings
2 parents 9dc6d12 + 86d01af commit 31a7390

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

Diff for: Authenticator.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import copy
1818
import logging
1919
import multiprocessing
20+
import os
2021
import random
2122
import threading
2223
import time
@@ -45,7 +46,7 @@ def kill_all_processes(processes_and_times):
4546
logging.warning('Error killing process with PID: ' + str(process_.pid))
4647

4748

48-
def initialize_chatbot(proxy, config, chatbots_and_proxies_queue):
49+
def initialize_chatbot(base_url, proxy, config, chatbots_and_proxies_queue):
4950
"""
5051
Pops first proxy and tries to initialize chatbot
5152
:return:
@@ -56,6 +57,8 @@ def initialize_chatbot(proxy, config, chatbots_and_proxies_queue):
5657
config_['proxy'] = proxy
5758

5859
# Initialize chatbot
60+
if base_url is not None and len(str(base_url)) > 0:
61+
os.environ['CHATGPT_BASE_URL'] = str(base_url)
5962
from revChatGPT.V1 import Chatbot
6063
chatbot = Chatbot(config=config_)
6164

@@ -116,6 +119,9 @@ def start_check_loop(self):
116119
logging.info('Proxy checks disabled. Initializing chatbot...')
117120
if self.chatbot is None:
118121
try:
122+
if len(str(self.settings['chatgpt_api_1']['chatgpt_auth']['base_url'])) > 0:
123+
os.environ['CHATGPT_BASE_URL'] \
124+
= str(self.settings['chatgpt_api_1']['chatgpt_auth']['base_url'])
119125
from revChatGPT.V1 import Chatbot
120126
self.chatbot = Chatbot(config=self.get_chatbot_config())
121127
self.chatbot_working = True
@@ -288,7 +294,9 @@ def proxy_checker_loop(self):
288294
< int(self.settings['chatgpt_api_1']['proxy']['max_number_of_processes']):
289295
proxy = self.proxy_list.pop(0)
290296
process = multiprocessing.Process(target=initialize_chatbot,
291-
args=(proxy,
297+
args=(str(self.settings['chatgpt_api_1']
298+
['chatgpt_auth']['base_url']),
299+
proxy,
292300
default_config,
293301
self.chatbots_and_proxies_queue,))
294302
process.start()

Diff for: main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import Authenticator
2828
import BotHandler
2929

30-
TELEGRAMUS_VERSION = 'beta_1.7.0'
30+
TELEGRAMUS_VERSION = 'beta_1.7.1'
3131

3232
# Logging level (INFO for debug, WARN for release)
3333
LOGGING_LEVEL = logging.INFO

Diff for: settings.json

+15-13
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@
2222
"__comment07__": "YOU CAN USE EMAIL/PASSWORD",
2323
"__comment08__": "OR SESSION_TOKEN (FROM COOKIES ON chat.openai.com AS __Secure-next-auth.session-token)",
2424
"__comment09__": "OR ACCESS_TOKEN (https://chat.openai.com/api/auth/session)",
25+
"__comment10__": "PROVIDE PROXY BASE URL (LEAVE EMPTY FOR DEFAULT VALUE OR TRY https://apps.openai.com/)",
2526
"chatgpt_auth": {
2627
"email": "",
2728
"password": "",
2829
"session_token": "",
29-
"access_token": ""
30+
"access_token": "",
31+
"base_url": "https://apps.openai.com/"
3032
},
3133

32-
"__comment10__": "PROXIES TO BYPASS COUNTRY RESTRICTIONS",
33-
"__comment11__": "IN AUTO MODE, PROXIES WILL BE REQUESTED FROM http://free-proxy-list.net/",
34-
"__comment12__": "IF AUTO IS FALSE, SPECIFY PROXY IN THE http://IP:PORT FORMAT",
35-
"__comment13__": "SPECIFY THE INTERVAL HOW LONG TO CHECK THE PROXY BY ASKING A QUESTION. OR SET 0 TO DISABLE CHECK",
36-
"__comment14__": "SPECIFY THE QUESTION WHICH THE APP WILL ASK AND THE TEXT WHICH SHOULD BE IN THE ANSWER",
34+
"__comment11__": "PROXIES TO BYPASS COUNTRY RESTRICTIONS",
35+
"__comment12__": "IN AUTO MODE, PROXIES WILL BE REQUESTED FROM http://free-proxy-list.net/",
36+
"__comment13__": "IF AUTO IS FALSE, SPECIFY PROXY IN THE http://IP:PORT FORMAT",
37+
"__comment14__": "SPECIFY THE INTERVAL HOW LONG TO CHECK THE PROXY BY ASKING A QUESTION. OR SET 0 TO DISABLE CHECK",
38+
"__comment15__": "SPECIFY THE QUESTION WHICH THE APP WILL ASK AND THE TEXT WHICH SHOULD BE IN THE ANSWER",
3739
"proxy": {
3840
"enabled": false,
3941
"auto": true,
@@ -47,26 +49,26 @@
4749
"initialization_timeout": 60
4850
},
4951

50-
"__comment15__": "SPECIFY YOUR INITIAL CONVERSATION_ID and PARENT_ID TO CONTINUE THE DIALOGUE",
51-
"__comment16__": "WHEN YOU START FOR THE FIRST TIME, LEAVE THEM BLANK, ASK A QUESTION AND LOOK IN THE CONSOLE",
52+
"__comment16__": "SPECIFY YOUR INITIAL CONVERSATION_ID and PARENT_ID TO CONTINUE THE DIALOGUE",
53+
"__comment17__": "WHEN YOU START FOR THE FIRST TIME, LEAVE THEM BLANK, ASK A QUESTION AND LOOK IN THE CONSOLE",
5254
"chatgpt_dialog": {
5355
"conversation_id": "",
5456
"parent_id": "",
5557
"too_many_requests_wait_time_seconds": 600
5658
}
5759
},
5860

59-
"__comment17__": "PROVIDE YOUR API_KEY FROM https://platform.openai.com/account/api-keys FOR REQUESTS TO DALL-E",
60-
"__comment18__": "SPECIFY FORMAT OF GENERATED IMAGES (256x256 or 512x512 or 1024x1024)",
61-
"__comment19__": "SPECIFY IS PROXY NEEDED FOR DALLE (SAME PROXY AS FOR CHATGPT)",
61+
"__comment18__": "PROVIDE YOUR API_KEY FROM https://platform.openai.com/account/api-keys FOR REQUESTS TO DALL-E",
62+
"__comment19__": "SPECIFY FORMAT OF GENERATED IMAGES (256x256 or 512x512 or 1024x1024)",
63+
"__comment20__": "SPECIFY IS PROXY NEEDED FOR DALLE (SAME PROXY AS FOR CHATGPT)",
6264
"dalle": {
6365
"open_ai_api_key": "",
6466
"image_size": "512x512",
6567
"use_proxy": true
6668
},
6769

68-
"__comment20__": "PROVIDE YOUR BOT API KEY FROM https://t.me/BotFather",
69-
"__comment21__": "SPECIFY THE SIZE OF THE REQUEST QUEUE AND WHETHER TO SHOW A MESSAGE ABOUT ADDING TO THE QUEUE",
70+
"__comment21__": "PROVIDE YOUR BOT API KEY FROM https://t.me/BotFather",
71+
"__comment22__": "SPECIFY THE SIZE OF THE REQUEST QUEUE AND WHETHER TO SHOW A MESSAGE ABOUT ADDING TO THE QUEUE",
7072
"telegram": {
7173
"api_key": "",
7274
"queue_max": 5,

0 commit comments

Comments
 (0)