md编著
This commit is contained in:
parent
667feb0d7e
commit
afed2c31d3
74
README.md
74
README.md
@ -49,13 +49,16 @@ requirements.txt一般无需变动,除非代码中使用了新的库,也要
|
||||
**如何本地启动本项目:**
|
||||
|
||||
1. requirements.txt里的环境要配好
|
||||
2. .env环境配好 (一般不需要在电脑环境变量中额外配置了)
|
||||
|
||||
conda create -n zbparse python=3.8
|
||||
conda activate zbparse
|
||||
pip install -r requirements.txt
|
||||
2. .env环境配好 (一般不需要在电脑环境变量中额外配置了,但是要在Pycharm中安装插件,使得项目能将env中的环境变量配置到系统环境变量中!!!)
|
||||
3. 点击下拉框,Edit configurations
|
||||
|
||||

|
||||
|
||||
设置run_serve.py为启动脚本
|
||||
注意这里的working directory要设置到最外层文件夹,而不是flask_app!!!
|
||||
|
||||
4. postman打post请求测试:
|
||||
|
||||
@ -70,11 +73,78 @@ body:
|
||||
"zb_type":2
|
||||
|
||||
}
|
||||
file_url如何获取:[OSS管理控制台](https://oss.console.aliyun.com/bucket/oss-cn-wuhan-lr/bid-assistance/object?path=test%2F)
|
||||
|
||||
bid-assistance/test 里面找个文件的url,推荐'094定稿-湖北工业大学xxx'
|
||||
注意这里的url地址有时效性,要经常重新获取新的url
|
||||
|
||||
|
||||
|
||||
## flask_app结构介绍
|
||||
|
||||
### 项目中做限制的地方
|
||||
|
||||
**大模型的限制**
|
||||
|
||||
general/llm下的doubao.py 和通义千问long_plus.py
|
||||
**目前是linux和windows各部署一套,因此项目中的qps是对半的,即calls=?**
|
||||
|
||||
1. 这是qianwen-long的限制(针对阿里qpm为1200,投标生成和解析对半分600,每秒就是10,又linux和windows服务器对半,就是5;)
|
||||
|
||||
```
|
||||
@sleep_and_retry
|
||||
@limits(calls=5, period=1) # 每秒最多调用4次
|
||||
def rate_limiter():
|
||||
pass # 这个函数本身不执行任何操作,只用于限流
|
||||
```
|
||||
|
||||
2. 这是qianwen-plus的限制(针对tpm为1000万,每个请求2万tokens,那么linux和windows总的qps为8时,8x60x2=960<1000。)
|
||||
|
||||
```
|
||||
@sleep_and_retry
|
||||
@limits(calls=4, period=1) # 每秒最多调用4次
|
||||
def qianwen_plus(user_query, need_extra=False):
|
||||
logger = logging.getLogger('model_log') # 通过日志名字获取记录器
|
||||
```
|
||||
|
||||
**重点!!**后续阿里扩容之后成倍修改这块**calls=?**
|
||||
|
||||
如果不用linux和windows负载均衡,这里的calls也要乘2!!
|
||||
|
||||
|
||||
|
||||
**接口的限制**
|
||||
|
||||
1. start_up.py的def create_app()函数,限制了对每个接口同时100次请求。这里事实上不再限制了(因为100已经足够大了),默认限制做到大模型限制这块。
|
||||
|
||||
```
|
||||
app.connection_limiters['upload'] = ConnectionLimiter(max_connections=100)
|
||||
app.connection_limiters['get_deviation'] = ConnectionLimiter(max_connections=100)
|
||||
app.connection_limiters['default'] = ConnectionLimiter(max_connections=100)
|
||||
app.connection_limiters['judge_zbfile'] = ConnectionLimiter(max_connections=100)
|
||||
```
|
||||
|
||||
2. ConnectionLimiter.py以及每个接口上的装饰器,如
|
||||
|
||||
```
|
||||
@require_connection_limit(timeout=1800)
|
||||
|
||||
def zbparse():
|
||||
```
|
||||
|
||||
|
||||
这里限制了每个接口内部执行的时间,暂时设置到了30分钟!(不包括排队时间)超时就是解析失败
|
||||
|
||||
|
||||
|
||||
**后端的限制:**
|
||||
|
||||
目前后端发起招标请求,如果发送超过100(max_connections=100)个请求,我这边会排队后面的请求,这时后端的计时器会将这些请求也视作正在解析中,事实上它们还在排队等待中,这样会导致在极端情况下,新进的解析文件速度大于解析的速度,排队越来越长,后面的文件会因为等待时间过长而直接失败,而不是'解析失败'。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### general
|
||||
|
||||
是公共函数存放的文件夹,llm下是各类大模型,读取文件下是docx pdf文件的读取以及文档清理clean_pdf,去页眉页脚页码
|
||||
|
Loading…
x
Reference in New Issue
Block a user