Merge branch 'master' into frontier
This commit is contained in:
		
						commit
						2b96a60b76
					
				
							
								
								
									
										15
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								README.md
									
									
									
									
									
								
							@ -18,15 +18,15 @@
 | 
				
			|||||||
[![Wiki][Wiki-image]][Wiki-url]
 | 
					[![Wiki][Wiki-image]][Wiki-url]
 | 
				
			||||||
[![PR][PRs-image]][PRs-url]
 | 
					[![PR][PRs-image]][PRs-url]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[License-image]: https://img.shields.io/badge/LICENSE-GPL3.0-orange?&style=flat-square
 | 
					[Github-image]: https://img.shields.io/badge/github-12100E.svg?style=flat-square
 | 
				
			||||||
[Github-image]: https://img.shields.io/badge/github-12100E.svg?&style=flat-square
 | 
					[License-image]: https://img.shields.io/github/license/binary-husky/gpt_academic?label=License&style=flat-square&color=orange
 | 
				
			||||||
[Releases-image]: https://img.shields.io/badge/Releases-v3.6.0-blue?style=flat-square
 | 
					[Releases-image]: https://img.shields.io/github/release/binary-husky/gpt_academic?label=Release&style=flat-square&color=blue
 | 
				
			||||||
[Installation-image]: https://img.shields.io/badge/Installation-v3.6.1-blue?style=flat-square
 | 
					[Installation-image]: https://img.shields.io/badge/dynamic/json?color=blue&url=https://raw.githubusercontent.com/binary-husky/gpt_academic/master/version&query=$.version&label=Installation&style=flat-square
 | 
				
			||||||
[Wiki-image]: https://img.shields.io/badge/wiki-项目文档-black?style=flat-square
 | 
					[Wiki-image]: https://img.shields.io/badge/wiki-项目文档-black?style=flat-square
 | 
				
			||||||
[PRs-image]: https://img.shields.io/badge/PRs-welcome-pink?style=flat-square
 | 
					[PRs-image]: https://img.shields.io/badge/PRs-welcome-pink?style=flat-square
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[License-url]: https://github.com/binary-husky/gpt_academic/blob/master/LICENSE
 | 
					 | 
				
			||||||
[Github-url]: https://github.com/binary-husky/gpt_academic
 | 
					[Github-url]: https://github.com/binary-husky/gpt_academic
 | 
				
			||||||
 | 
					[License-url]: https://github.com/binary-husky/gpt_academic/blob/master/LICENSE
 | 
				
			||||||
[Releases-url]: https://github.com/binary-husky/gpt_academic/releases
 | 
					[Releases-url]: https://github.com/binary-husky/gpt_academic/releases
 | 
				
			||||||
[Installation-url]: https://github.com/binary-husky/gpt_academic#installation
 | 
					[Installation-url]: https://github.com/binary-husky/gpt_academic#installation
 | 
				
			||||||
[Wiki-url]: https://github.com/binary-husky/gpt_academic/wiki
 | 
					[Wiki-url]: https://github.com/binary-husky/gpt_academic/wiki
 | 
				
			||||||
@ -38,7 +38,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
**如果喜欢这个项目,请给它一个Star;如果您发明了好用的快捷键或插件,欢迎发pull requests!**
 | 
					**如果喜欢这个项目,请给它一个Star;如果您发明了好用的快捷键或插件,欢迎发pull requests!**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you like this project, please give it a Star. Read this in [English](docs/README.English.md) | [日本語](docs/README.Japanese.md) | [한국어](docs/README.Korean.md) | [Русский](docs/README.Russian.md) | [Français](docs/README.French.md). All translations have been provided by the project itself. To translate this project to arbitrary language with GPT, read and run [`multi_language.py`](multi_language.py) (experimental).
 | 
					If you like this project, please give it a Star.
 | 
				
			||||||
 | 
					Read this in [English](docs/README.English.md) | [日本語](docs/README.Japanese.md) | [한국어](docs/README.Korean.md) | [Русский](docs/README.Russian.md) | [Français](docs/README.French.md). All translations have been provided by the project itself. To translate this project to arbitrary language with GPT, read and run [`multi_language.py`](multi_language.py) (experimental).
 | 
				
			||||||
<br>
 | 
					<br>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,7 +48,7 @@ If you like this project, please give it a Star. Read this in [English](docs/REA
 | 
				
			|||||||
> 2.本项目中每个文件的功能都在[自译解报告](https://github.com/binary-husky/gpt_academic/wiki/GPT‐Academic项目自译解报告)`self_analysis.md`详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题请查阅wiki。
 | 
					> 2.本项目中每个文件的功能都在[自译解报告](https://github.com/binary-husky/gpt_academic/wiki/GPT‐Academic项目自译解报告)`self_analysis.md`详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题请查阅wiki。
 | 
				
			||||||
>    [](#installation)  [](https://github.com/binary-husky/gpt_academic/releases)  [](https://github.com/binary-husky/gpt_academic/wiki/项目配置说明) []([https://github.com/binary-husky/gpt_academic/wiki/项目配置说明](https://github.com/binary-husky/gpt_academic/wiki))
 | 
					>    [](#installation)  [](https://github.com/binary-husky/gpt_academic/releases)  [](https://github.com/binary-husky/gpt_academic/wiki/项目配置说明) []([https://github.com/binary-husky/gpt_academic/wiki/项目配置说明](https://github.com/binary-husky/gpt_academic/wiki))
 | 
				
			||||||
> 
 | 
					> 
 | 
				
			||||||
> 3.本项目兼容并鼓励尝试国产大语言模型ChatGLM等。支持多个api-key共存,可在配置文件中填写如`API_KEY="openai-key1,openai-key2,azure-key3,api2d-key4"`。需要临时更换`API_KEY`时,在输入区输入临时的`API_KEY`然后回车键提交后即可生效。
 | 
					> 3.本项目兼容并鼓励尝试国产大语言模型ChatGLM等。支持多个api-key共存,可在配置文件中填写如`API_KEY="openai-key1,openai-key2,azure-key3,api2d-key4"`。需要临时更换`API_KEY`时,在输入区输入临时的`API_KEY`然后回车键提交即可生效。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<br><br>
 | 
					<br><br>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								config.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								config.py
									
									
									
									
									
								
							@ -15,13 +15,13 @@ API_KEY = "此处填API密钥"    # 可同时填写多个API-KEY,用英文逗
 | 
				
			|||||||
USE_PROXY = False
 | 
					USE_PROXY = False
 | 
				
			||||||
if USE_PROXY:
 | 
					if USE_PROXY:
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					    代理网络的地址,打开你的代理软件查看代理协议(socks5h / http)、地址(localhost)和端口(11284)
 | 
				
			||||||
    填写格式是 [协议]://  [地址] :[端口],填写之前不要忘记把USE_PROXY改成True,如果直接在海外服务器部署,此处不修改
 | 
					    填写格式是 [协议]://  [地址] :[端口],填写之前不要忘记把USE_PROXY改成True,如果直接在海外服务器部署,此处不修改
 | 
				
			||||||
            <配置教程&视频教程> https://github.com/binary-husky/gpt_academic/issues/1>
 | 
					            <配置教程&视频教程> https://github.com/binary-husky/gpt_academic/issues/1>
 | 
				
			||||||
    [协议] 常见协议无非socks5h/http; 例如 v2**y 和 ss* 的默认本地协议是socks5h; 而cl**h 的默认本地协议是http
 | 
					    [协议] 常见协议无非socks5h/http; 例如 v2**y 和 ss* 的默认本地协议是socks5h; 而cl**h 的默认本地协议是http
 | 
				
			||||||
    [地址] 懂的都懂,不懂就填localhost或者127.0.0.1肯定错不了(localhost意思是代理软件安装在本机上)
 | 
					    [地址] 填localhost或者127.0.0.1(localhost意思是代理软件安装在本机上)
 | 
				
			||||||
    [端口] 在代理软件的设置里找。虽然不同的代理软件界面不一样,但端口号都应该在最显眼的位置上
 | 
					    [端口] 在代理软件的设置里找。虽然不同的代理软件界面不一样,但端口号都应该在最显眼的位置上
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    # 代理网络的地址,打开你的*学*网软件查看代理的协议(socks5h / http)、地址(localhost)和端口(11284)
 | 
					 | 
				
			||||||
    proxies = {
 | 
					    proxies = {
 | 
				
			||||||
        #          [协议]://  [地址]  :[端口]
 | 
					        #          [协议]://  [地址]  :[端口]
 | 
				
			||||||
        "http":  "socks5h://localhost:11284",  # 再例如  "http":  "http://127.0.0.1:7890",
 | 
					        "http":  "socks5h://localhost:11284",  # 再例如  "http":  "http://127.0.0.1:7890",
 | 
				
			||||||
@ -100,6 +100,12 @@ AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview","gpt-4-vision-prev
 | 
				
			|||||||
MULTI_QUERY_LLM_MODELS = "gpt-3.5-turbo&chatglm3"
 | 
					MULTI_QUERY_LLM_MODELS = "gpt-3.5-turbo&chatglm3"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 选择本地模型变体(只有当AVAIL_LLM_MODELS包含了对应本地模型时,才会起作用)
 | 
				
			||||||
 | 
					# 如果你选择Qwen系列的模型,那么请在下面的QWEN_MODEL_SELECTION中指定具体的模型
 | 
				
			||||||
 | 
					# 也可以是具体的模型路径
 | 
				
			||||||
 | 
					QWEN_MODEL_SELECTION = "Qwen/Qwen-1_8B-Chat-Int8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 百度千帆(LLM_MODEL="qianfan")
 | 
					# 百度千帆(LLM_MODEL="qianfan")
 | 
				
			||||||
BAIDU_CLOUD_API_KEY = ''
 | 
					BAIDU_CLOUD_API_KEY = ''
 | 
				
			||||||
BAIDU_CLOUD_SECRET_KEY = ''
 | 
					BAIDU_CLOUD_SECRET_KEY = ''
 | 
				
			||||||
 | 
				
			|||||||
@ -1,13 +1,7 @@
 | 
				
			|||||||
model_name = "Qwen"
 | 
					model_name = "Qwen"
 | 
				
			||||||
cmd_to_install = "`pip install -r request_llms/requirements_qwen.txt`"
 | 
					cmd_to_install = "`pip install -r request_llms/requirements_qwen.txt`"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from toolbox import ProxyNetworkActivate, get_conf
 | 
				
			||||||
from transformers import AutoModel, AutoTokenizer
 | 
					 | 
				
			||||||
import time
 | 
					 | 
				
			||||||
import threading
 | 
					 | 
				
			||||||
import importlib
 | 
					 | 
				
			||||||
from toolbox import update_ui, get_conf, ProxyNetworkActivate
 | 
					 | 
				
			||||||
from multiprocessing import Process, Pipe
 | 
					 | 
				
			||||||
from .local_llm_class import LocalLLMHandle, get_local_llm_predict_fns
 | 
					from .local_llm_class import LocalLLMHandle, get_local_llm_predict_fns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -24,16 +18,14 @@ class GetQwenLMHandle(LocalLLMHandle):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def load_model_and_tokenizer(self):
 | 
					    def load_model_and_tokenizer(self):
 | 
				
			||||||
        # 🏃♂️🏃♂️🏃♂️ 子进程执行
 | 
					        # 🏃♂️🏃♂️🏃♂️ 子进程执行
 | 
				
			||||||
        import os, glob
 | 
					        # from modelscope import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
 | 
				
			||||||
        import os
 | 
					        from transformers import AutoModelForCausalLM, AutoTokenizer
 | 
				
			||||||
        import platform
 | 
					        from transformers.generation import GenerationConfig
 | 
				
			||||||
        from modelscope import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        with ProxyNetworkActivate('Download_LLM'):
 | 
					        with ProxyNetworkActivate('Download_LLM'):
 | 
				
			||||||
            model_id = 'qwen/Qwen-7B-Chat'
 | 
					            model_id = get_conf('QWEN_MODEL_SELECTION')
 | 
				
			||||||
            self._tokenizer = AutoTokenizer.from_pretrained('Qwen/Qwen-7B-Chat', trust_remote_code=True, resume_download=True)
 | 
					            self._tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True, resume_download=True)
 | 
				
			||||||
            # use fp16
 | 
					            # use fp16
 | 
				
			||||||
            model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True, fp16=True).eval()
 | 
					            model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True).eval()
 | 
				
			||||||
            model.generation_config = GenerationConfig.from_pretrained(model_id, trust_remote_code=True)  # 可指定不同的生成长度、top_p等相关超参
 | 
					            model.generation_config = GenerationConfig.from_pretrained(model_id, trust_remote_code=True)  # 可指定不同的生成长度、top_p等相关超参
 | 
				
			||||||
            self._model = model
 | 
					            self._model = model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -51,7 +43,7 @@ class GetQwenLMHandle(LocalLLMHandle):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        query, max_length, top_p, temperature, history = adaptor(kwargs)
 | 
					        query, max_length, top_p, temperature, history = adaptor(kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for response in self._model.chat(self._tokenizer, query, history=history, stream=True):
 | 
					        for response in self._model.chat_stream(self._tokenizer, query, history=history):
 | 
				
			||||||
            yield response
 | 
					            yield response
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def try_to_import_special_deps(self, **kwargs):
 | 
					    def try_to_import_special_deps(self, **kwargs):
 | 
				
			||||||
 | 
				
			|||||||
@ -1,2 +1,4 @@
 | 
				
			|||||||
modelscope
 | 
					modelscope
 | 
				
			||||||
transformers_stream_generator
 | 
					transformers_stream_generator
 | 
				
			||||||
 | 
					auto-gptq
 | 
				
			||||||
 | 
					optimum
 | 
				
			||||||
@ -16,8 +16,9 @@ if __name__ == "__main__":
 | 
				
			|||||||
    # from request_llms.bridge_jittorllms_llama import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_jittorllms_llama import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_claude import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_claude import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_internlm import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_internlm import predict_no_ui_long_connection
 | 
				
			||||||
    from request_llms.bridge_deepseekcoder import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_deepseekcoder import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_qwen import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_qwen_7B import predict_no_ui_long_connection
 | 
				
			||||||
 | 
					    from request_llms.bridge_qwen import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_spark import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_spark import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_zhipu import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_zhipu import predict_no_ui_long_connection
 | 
				
			||||||
    # from request_llms.bridge_chatglm3 import predict_no_ui_long_connection
 | 
					    # from request_llms.bridge_chatglm3 import predict_no_ui_long_connection
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user