diff --git a/apikey.ini b/apikey.ini index 7cda4ef..ac28026 100644 --- a/apikey.ini +++ b/apikey.ini @@ -6,3 +6,6 @@ api = your_gitee_api owner = your_gitee_name repo = your_repo_name path = files_name_in_your_repo +[Proxy] +http = http://127.0.0.1:1234 +https = http://127.0.0.1:1234 \ No newline at end of file diff --git a/chat_arxiv.py b/chat_arxiv.py index 01b147e..7cb30a1 100644 --- a/chat_arxiv.py +++ b/chat_arxiv.py @@ -303,6 +303,7 @@ def __init__(self, key_word, query, self.chat_api_list = self.config.get('OpenAI', 'OPENAI_API_KEYS')[1:-1].replace('\'', '').split(',') self.chat_api_list = [api.strip() for api in self.chat_api_list if len(api) > 5] self.cur_api = 0 + self.proxy = dict(self.config['Proxy']) self.file_format = args.file_format if args.save_image: self.gitee_key = self.config.get('Gitee', 'api') @@ -514,6 +515,7 @@ def summary_with_chat(self, paper_list): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_conclusion(self, text, conclusion_prompt_token = 800): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api @@ -556,6 +558,7 @@ def chat_conclusion(self, text, conclusion_prompt_token = 800): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_method(self, text, method_prompt_token = 800): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api @@ -599,6 +602,7 @@ def chat_method(self, text, method_prompt_token = 800): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_summary(self, text, summary_prompt_token = 1100): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api diff --git a/chat_paper.py b/chat_paper.py index 8cc7cdd..e23e6a5 100644 --- a/chat_paper.py +++ b/chat_paper.py @@ -38,6 +38,7 @@ def __init__(self, key_word, query, filter_keys, self.chat_api_list = self.config.get('OpenAI', 'OPENAI_API_KEYS')[1:-1].replace('\'', '').split(',') self.chat_api_list = [api.strip() for api in self.chat_api_list if len(api) > 5] self.cur_api = 0 + self.proxy = dict(self.config['Proxy']) self.file_format = args.file_format if args.save_image: self.gitee_key = self.config.get('Gitee', 'api') @@ -267,6 +268,7 @@ def summary_with_chat(self, paper_list): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_conclusion(self, text, conclusion_prompt_token = 800): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api @@ -309,6 +311,7 @@ def chat_conclusion(self, text, conclusion_prompt_token = 800): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_method(self, text, method_prompt_token = 800): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api @@ -352,6 +355,7 @@ def chat_method(self, text, method_prompt_token = 800): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_summary(self, text, summary_prompt_token = 1100): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api diff --git a/chat_response.py b/chat_response.py index 5c4f41f..d54b46c 100644 --- a/chat_response.py +++ b/chat_response.py @@ -28,6 +28,7 @@ def __init__(self, args=None): self.chat_api_list = self.config.get('OpenAI', 'OPENAI_API_KEYS')[1:-1].replace('\'', '').split(',') self.chat_api_list = [api.strip() for api in self.chat_api_list if len(api) > 5] self.cur_api = 0 + self.proxy = dict(self.config['Proxy']) self.file_format = args.file_format self.max_token_num = 4096 self.encoding = tiktoken.get_encoding("gpt2") @@ -58,6 +59,7 @@ def response_by_chatgpt(self, comment_path): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_response(self, text): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api diff --git a/chat_reviewer.py b/chat_reviewer.py index cb82758..9e6e4b7 100644 --- a/chat_reviewer.py +++ b/chat_reviewer.py @@ -28,6 +28,7 @@ def __init__(self, args=None): self.chat_api_list = self.config.get('OpenAI', 'OPENAI_API_KEYS')[1:-1].replace('\'', '').split(',') self.chat_api_list = [api.strip() for api in self.chat_api_list if len(api) > 5] self.cur_api = 0 + self.proxy = dict(self.config['Proxy']) self.file_format = args.file_format self.max_token_num = 4096 self.encoding = tiktoken.get_encoding("gpt2") @@ -80,6 +81,7 @@ def stage_1(self, paper): text = '' text += 'Title: ' + paper.title + '. ' text += 'Abstract: ' + paper.section_texts['Abstract'] + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api @@ -111,6 +113,7 @@ def stage_1(self, paper): stop=tenacity.stop_after_attempt(5), reraise=True) def chat_review(self, text): + openai.proxy = self.proxy openai.api_key = self.chat_api_list[self.cur_api] self.cur_api += 1 self.cur_api = 0 if self.cur_api >= len(self.chat_api_list)-1 else self.cur_api