Skip to content

Commit

Permalink
Merge pull request #13 from F33RNI/next
Browse files Browse the repository at this point in the history
Add base url to settings
  • Loading branch information
F33RNI authored Feb 27, 2023
2 parents 9dc6d12 + 86d01af commit 31a7390
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
12 changes: 10 additions & 2 deletions Authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import copy
import logging
import multiprocessing
import os
import random
import threading
import time
Expand Down Expand Up @@ -45,7 +46,7 @@ def kill_all_processes(processes_and_times):
logging.warning('Error killing process with PID: ' + str(process_.pid))


def initialize_chatbot(proxy, config, chatbots_and_proxies_queue):
def initialize_chatbot(base_url, proxy, config, chatbots_and_proxies_queue):
"""
Pops first proxy and tries to initialize chatbot
:return:
Expand All @@ -56,6 +57,8 @@ def initialize_chatbot(proxy, config, chatbots_and_proxies_queue):
config_['proxy'] = proxy

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

Expand Down Expand Up @@ -116,6 +119,9 @@ def start_check_loop(self):
logging.info('Proxy checks disabled. Initializing chatbot...')
if self.chatbot is None:
try:
if len(str(self.settings['chatgpt_api_1']['chatgpt_auth']['base_url'])) > 0:
os.environ['CHATGPT_BASE_URL'] \
= str(self.settings['chatgpt_api_1']['chatgpt_auth']['base_url'])
from revChatGPT.V1 import Chatbot
self.chatbot = Chatbot(config=self.get_chatbot_config())
self.chatbot_working = True
Expand Down Expand Up @@ -288,7 +294,9 @@ def proxy_checker_loop(self):
< int(self.settings['chatgpt_api_1']['proxy']['max_number_of_processes']):
proxy = self.proxy_list.pop(0)
process = multiprocessing.Process(target=initialize_chatbot,
args=(proxy,
args=(str(self.settings['chatgpt_api_1']
['chatgpt_auth']['base_url']),
proxy,
default_config,
self.chatbots_and_proxies_queue,))
process.start()
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import Authenticator
import BotHandler

TELEGRAMUS_VERSION = 'beta_1.7.0'
TELEGRAMUS_VERSION = 'beta_1.7.1'

# Logging level (INFO for debug, WARN for release)
LOGGING_LEVEL = logging.INFO
Expand Down
28 changes: 15 additions & 13 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@
"__comment07__": "YOU CAN USE EMAIL/PASSWORD",
"__comment08__": "OR SESSION_TOKEN (FROM COOKIES ON chat.openai.com AS __Secure-next-auth.session-token)",
"__comment09__": "OR ACCESS_TOKEN (https://chat.openai.com/api/auth/session)",
"__comment10__": "PROVIDE PROXY BASE URL (LEAVE EMPTY FOR DEFAULT VALUE OR TRY https://apps.openai.com/)",
"chatgpt_auth": {
"email": "",
"password": "",
"session_token": "",
"access_token": ""
"access_token": "",
"base_url": "https://apps.openai.com/"
},

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

"__comment15__": "SPECIFY YOUR INITIAL CONVERSATION_ID and PARENT_ID TO CONTINUE THE DIALOGUE",
"__comment16__": "WHEN YOU START FOR THE FIRST TIME, LEAVE THEM BLANK, ASK A QUESTION AND LOOK IN THE CONSOLE",
"__comment16__": "SPECIFY YOUR INITIAL CONVERSATION_ID and PARENT_ID TO CONTINUE THE DIALOGUE",
"__comment17__": "WHEN YOU START FOR THE FIRST TIME, LEAVE THEM BLANK, ASK A QUESTION AND LOOK IN THE CONSOLE",
"chatgpt_dialog": {
"conversation_id": "",
"parent_id": "",
"too_many_requests_wait_time_seconds": 600
}
},

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

"__comment20__": "PROVIDE YOUR BOT API KEY FROM https://t.me/BotFather",
"__comment21__": "SPECIFY THE SIZE OF THE REQUEST QUEUE AND WHETHER TO SHOW A MESSAGE ABOUT ADDING TO THE QUEUE",
"__comment21__": "PROVIDE YOUR BOT API KEY FROM https://t.me/BotFather",
"__comment22__": "SPECIFY THE SIZE OF THE REQUEST QUEUE AND WHETHER TO SHOW A MESSAGE ABOUT ADDING TO THE QUEUE",
"telegram": {
"api_key": "",
"queue_max": 5,
Expand Down

0 comments on commit 31a7390

Please sign in to comment.