Skip to content

Commit 86ba9a5

Browse files
authored
Merge pull request #31 from codefuse-ai/modelcache_dev_mm
use markdown format for file paths; add flask4multicache service
2 parents 0a474f6 + d522560 commit 86ba9a5

18 files changed

+534
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ python flask4modelcache_demo.py
5555

5656
#### Normal Service Startup
5757
Before starting the service, the following environment configurations should be performed:
58-
1. Install the relational database MySQL and import the SQL file to create the data tables. The SQL file can be found at: reference_doc/create_table.sql
58+
1. Install the relational database MySQL and import the SQL file to create the data tables. The SQL file can be found at: ```reference_doc/create_table.sql```
5959
2. Install the vector database Milvus.
6060
3. Add the database access information to the configuration files:
61-
1. modelcache/config/milvus_config.ini
62-
2. modelcache/config/mysql_config.ini
61+
1. ```modelcache/config/milvus_config.ini ```
62+
2. ```modelcache/config/mysql_config.ini```
6363
4. Download the embedding model bin file from the following address: [https://huggingface.co/shibing624/text2vec-base-chinese/tree/main](https://huggingface.co/shibing624/text2vec-base-chinese/tree/main). Place the downloaded bin file in the model/text2vec-base-chinese folder.
6464
5. Start the backend service using the flask4modelcache.py script.
6565
## Service-Access

README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ python flask4modelcache_demo.py
5555

5656
#### 正常服务启动
5757
在启动服务前,应该进行如下环境配置:
58-
1. 安装关系数据库 mysql, 导入sql创建数据表,sql文件: reference_doc/create_table.sql
58+
1. 安装关系数据库 mysql, 导入sql创建数据表,sql文件:```reference_doc/create_table.sql```
5959
2. 安装向量数据库milvus
6060
3. 在配置文件中添加数据库访问信息,配置文件为:
61-
1. modelcache/config/milvus_config.ini
62-
2. modelcache/config/mysql_config.ini
61+
1. ```modelcache/config/milvus_config.ini```
62+
2. ```modelcache/config/mysql_config.ini```
6363
4. 离线模型bin文件下载, 参考地址:[https://huggingface.co/shibing624/text2vec-base-chinese/tree/main](https://huggingface.co/shibing624/text2vec-base-chinese/tree/main),并将下载的bin文件,放到 model/text2vec-base-chinese 文件夹中
6464
5. 通过flask4modelcache.py脚本启动后端服务。
6565
## 服务访问

examples/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
Alipay.com Inc.
4+
Copyright (c) 2004-2023 All Rights Reserved.
5+
------------------------------------------------------
6+
File Name : __init__.py.py
7+
Author : fuhui.phe
8+
Create Time : 2024/5/22 11:03
9+
Description : description what the main function of this file
10+
Change Activity:
11+
version0 : 2024/5/22 11:03 by fuhui.phe init
12+
"""

examples/flask/llms_cache/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Alipay.com Inc.
4+
Copyright (c) 2004-2023 All Rights Reserved.
5+
------------------------------------------------------
6+
File Name : __init__.py.py
7+
Author : fuhui.phe
8+
Create Time : 2024/5/22 10:28
9+
Description : description what the main function of this file
10+
Change Activity:
11+
version0 : 2024/5/22 10:28 by fuhui.phe init
12+
"""
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Alipay.com Inc.
4+
Copyright (c) 2004-2023 All Rights Reserved.
5+
------------------------------------------------------
6+
File Name : __init__.py.py
7+
Author : fuhui.phe
8+
Create Time : 2024/5/22 10:29
9+
Description : description what the main function of this file
10+
Change Activity:
11+
version0 : 2024/5/22 10:29 by fuhui.phe init
12+
"""
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
import time
3+
import json
4+
import uuid
5+
import requests
6+
7+
8+
def run():
9+
url = 'http://127.0.0.1:5000/multicache'
10+
11+
request_type = 'insert'
12+
scope = {"model": "multimodal_test"}
13+
# UUID = "820b0052-d9d8-11ee-95f1-52775e3e6fd1" + "==>" + str(time.time())
14+
UUID = str(uuid.uuid1()) + "==>" + str(time.time())
15+
img_data = "https://img0.baidu.com/it/u=1436460262,4166266890&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=282"
16+
query = {'text': ['父母带着孩子来这个地方可能会有什么顾虑'],
17+
'imageRaw': '',
18+
'imageUrl': img_data,
19+
'imageId': 'ccc'}
20+
answer = "应该注意小孩不要跑到铁轨上"
21+
chat_info = [{"query": query, "answer": answer}]
22+
data_dict = {'request_type': request_type, 'scope': scope, 'chat_info': chat_info, 'UUID': UUID}
23+
24+
headers = {"Content-Type": "application/json"}
25+
res = requests.post(url, headers=headers, json=json.dumps(data_dict))
26+
res_text = res.text
27+
print('res_text: {}'.format(res_text))
28+
29+
30+
if __name__ == '__main__':
31+
run()

0 commit comments

Comments
 (0)