Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use local proxy instead of system proxy #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apikey.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions chat_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions chat_paper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions chat_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions chat_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down