Skip to content

Commit d522560

Browse files
committed
add flask4multicache service
1 parent bf7584a commit d522560

File tree

16 files changed

+211
-81
lines changed

16 files changed

+211
-81
lines changed

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()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
import json
3+
import requests
4+
import uuid
5+
import time
6+
7+
8+
def run():
9+
url = 'http://127.0.0.1:5000/multicache'
10+
request_type = 'query'
11+
UUID = str(uuid.uuid1()) + "==>" + str(time.time())
12+
scope = {"model": "multimodal_test"}
13+
img_data = "https://img0.baidu.com/it/u=1436460262,4166266890&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=282"
14+
query = {'text': ['父母带着孩子来这个地方可能会有什么顾虑'],
15+
'imageRaw': '',
16+
'imageUrl': img_data,
17+
'multiType': 'IMG_TEXT'}
18+
19+
data = {'request_type': request_type, 'scope': scope, 'query': query, 'UUID': UUID}
20+
21+
headers = {"Content-Type": "application/json"}
22+
res = requests.post(url, headers=headers, json=json.dumps(data))
23+
res_text = res.text
24+
print('res_text: {}'.format(res_text))
25+
26+
27+
if __name__ == '__main__':
28+
run()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
register index for redis
4+
"""
5+
import json
6+
import requests
7+
8+
9+
def run():
10+
url = 'http://127.0.0.1:5000/multicache'
11+
request_type = 'register'
12+
scope = {"model": "multimodal_test"}
13+
type = 'IMG_TEXT'
14+
data = {'request_type': request_type, 'scope': scope, 'type': type}
15+
headers = {"Content-Type": "application/json"}
16+
res = requests.post(url, headers=headers, json=json.dumps(data))
17+
res_text = res.text
18+
print('res_text: {}'.format(res_text))
19+
20+
21+
if __name__ == '__main__':
22+
run()

0 commit comments

Comments
 (0)