Skip to content

Commit 3dfb7e0

Browse files
committed
Conducting functional testing of the service.
1 parent 2966fc9 commit 3dfb7e0

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

examples/flask/data_insert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def run():
77
url = 'http://127.0.0.1:5000/modelcache'
88
type = 'insert'
9-
scope = {"model": "CODEGPT-1109"}
9+
scope = {"model": "CODEGPT-1117"}
1010
chat_info = [{"query": [{"role": "system", "content": "你是一个python助手"}, {"role": "user", "content": "hello"}],
1111
"answer": "你好,我是智能助手,请问有什么能帮您!"}]
1212
data = {'type': type, 'scope': scope, 'chat_info': chat_info}

examples/flask/data_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def run():
77
url = 'http://127.0.0.1:5000/modelcache'
88
type = 'query'
9-
scope = {"model": "CODEGPT-1109"}
9+
scope = {"model": "CODEGPT-1117"}
1010
query = [{"role": "system", "content": "你是一个python助手"}, {"role": "user", "content": "hello"}]
1111
data = {'type': type, 'scope': scope, 'query': query}
1212

flask4modelcache.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from concurrent.futures import ThreadPoolExecutor
1515
from modelcache.utils.model_filter import model_blacklist_filter
1616
from modelcache.embedding import Data2VecAudio
17-
# from modelcache.maya_embedding_service.maya_embedding_service import get_cache_embedding_text2vec
1817

1918

2019
# 创建一个Flask实例
@@ -113,7 +112,8 @@ def user_backend():
113112
if response is None:
114113
result = {"errorCode": 0, "errorDesc": '', "cacheHit": False, "delta_time": delta_time, "hit_query": '',
115114
"answer": ''}
116-
elif response in ['adapt_query_exception']:
115+
# elif response in ['adapt_query_exception']:
116+
elif isinstance(response, str):
117117
result = {"errorCode": 201, "errorDesc": response, "cacheHit": False, "delta_time": delta_time,
118118
"hit_query": '', "answer": ''}
119119
else:
@@ -124,7 +124,7 @@ def user_backend():
124124
delta_time_log = round(time.time() - start_time, 2)
125125
future = executor.submit(save_query_info, result, model, query, delta_time_log)
126126
except Exception as e:
127-
result = {"errorCode": 202, "errorDesc": e, "cacheHit": False, "delta_time": 0,
127+
result = {"errorCode": 202, "errorDesc": str(e), "cacheHit": False, "delta_time": 0,
128128
"hit_query": '', "answer": ''}
129129
logging.info('result: {}'.format(result))
130130

@@ -138,19 +138,16 @@ def user_backend():
138138
chat_info=chat_info
139139
)
140140
except Exception as e:
141-
result = {"errorCode": 303, "errorDesc": e, "writeStatus": "exception"}
141+
result = {"errorCode": 302, "errorDesc": str(e), "writeStatus": "exception"}
142142
return json.dumps(result, ensure_ascii=False)
143143

144-
if response in ['adapt_insert_exception']:
145-
result = {"errorCode": 301, "errorDesc": response, "writeStatus": "exception"}
146-
elif response == 'success':
144+
if response == 'success':
147145
result = {"errorCode": 0, "errorDesc": "", "writeStatus": "success"}
148146
else:
149-
result = {"errorCode": 302, "errorDesc": response,
150-
"writeStatus": "exception"}
147+
result = {"errorCode": 301, "errorDesc": response, "writeStatus": "exception"}
151148
return json.dumps(result, ensure_ascii=False)
152149
except Exception as e:
153-
result = {"errorCode": 304, "errorDesc": e, "writeStatus": "exception"}
150+
result = {"errorCode": 303, "errorDesc": str(e), "writeStatus": "exception"}
154151
return json.dumps(result, ensure_ascii=False)
155152

156153
if request_type == 'remove':
@@ -162,13 +159,11 @@ def user_backend():
162159
remove_type=remove_type,
163160
id_list=id_list
164161
)
165-
166162
if not isinstance(response, dict):
167163
result = {"errorCode": 401, "errorDesc": "", "response": response, "removeStatus": "exception"}
168164
return json.dumps(result)
169165

170166
state = response.get('status')
171-
172167
if state == 'success':
173168
result = {"errorCode": 0, "errorDesc": "", "response": response, "writeStatus": "success"}
174169
else:

0 commit comments

Comments
 (0)