From fa1309f2b868f05b61af80315b3a2098a4484ff9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 27 Jul 2026 12:23:11 +0800 Subject: [PATCH] fix: add uapiio entries + headers + ioid linkage for GPU services --- scripts/update_uapi_data.py | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 scripts/update_uapi_data.py diff --git a/scripts/update_uapi_data.py b/scripts/update_uapi_data.py new file mode 100644 index 0000000..761afe4 --- /dev/null +++ b/scripts/update_uapi_data.py @@ -0,0 +1,79 @@ +"""Update uapi entries with proper headers + create uapiio definitions""" +import asyncio +from sqlor.dbpools import DBPools +from appPublic.jsonConfig import getConfig + +async def main(): + config = getConfig('.') + DBPools(config.databases) + db = DBPools() + async with db.sqlorContext('rag') as sor: + + # --- uapiio entries --- + uapiiios = [ + ('io-vdb-vector', 'VDB向量操作', '向量数据库CRUD输入输出', + '[{"name":"collection","label":"集合名","uitype":"str","required":true},' + '{"name":"data","label":"向量数据","uitype":"json"},' + '{"name":"ids","label":"向量ID列表","uitype":"json"},' + '{"name":"topK","label":"返回数量","uitype":"int"}]'), + ('io-reranker', 'Reranker重排序', 'BGE重排序输入输出', + '[{"name":"query","label":"查询文本","uitype":"text","required":true},' + '{"name":"documents","label":"候选文档列表","uitype":"json","required":true}]'), + ('io-face', '人脸服务', '人脸检测/识别/比对', + '[{"name":"image_url","label":"图片URL","uitype":"str","required":true},' + '{"name":"image_url1","label":"图片1 URL","uitype":"str"},' + '{"name":"image_url2","label":"图片2 URL","uitype":"str"},' + '{"name":"face_id","label":"人脸ID","uitype":"str"}]'), + ('io-graph', '图数据库', '图CRUD输入输出', + '[{"name":"graph","label":"图名","uitype":"str","required":true},' + '{"name":"query","label":"图查询语句","uitype":"text"},' + '{"name":"data","label":"图数据","uitype":"json"}]'), + ('io-ner', 'NER实体识别', '命名实体识别', + '[{"name":"text","label":"待识别文本","uitype":"text","required":true}]'), + ('io-embedding', 'CLIP向量化', '文本/图片向量化', + '[{"name":"texts","label":"文本列表","uitype":"json","required":true},' + '{"name":"model","label":"模型名","uitype":"str"}]'), + ] + for ioid, name, desc, fields in uapiiios: + await sor.sqlExe( + "INSERT INTO uapiio (id, name, description, input_fields) " + "VALUES (${id}$, ${name}$, ${desc}$, ${fields}$) " + "ON DUPLICATE KEY UPDATE description=${desc}$, input_fields=${fields}$", + {"id": ioid, "name": name, "desc": desc, "fields": fields}) + print(f'uapiio: {len(uapiiios)} inserted') + + # --- Update uapi entries: add headers + link ioid --- + updates = [ + # VDB + ('vdb-upsert', 'rag-vdb', 'io-vdb-vector'), + ('vdb-search', 'rag-vdb', 'io-vdb-vector'), + ('vdb-delete', 'rag-vdb', 'io-vdb-vector'), + # Reranker + ('reranker-rerank', 'rag-reranker', 'io-reranker'), + # Face + ('face-detect', 'rag-face', 'io-face'), + ('face-recognize', 'rag-face', 'io-face'), + ('face-compare', 'rag-face', 'io-face'), + # Graph + ('graph-save', 'rag-graph', 'io-graph'), + ('graph-query', 'rag-graph', 'io-graph'), + ('graph-delete', 'rag-graph', 'io-graph'), + # NER + ('ner-entities', 'rag-ner', 'io-ner'), + # Embedding + ('emb-embed', 'rag-embedding', 'io-embedding'), + ] + headers_tmpl = '{\n "Content-Type": "application/json"\n}' + for aid, upappid, ioid in updates: + await sor.sqlExe( + "UPDATE uapi SET headers=${h}$, ioid=${ioid}$ WHERE id=${id}$", + {"h": headers_tmpl, "ioid": ioid, "id": aid}) + print(f'uapi: {len(updates)} updated (headers + ioid)') + + # --- Fix vdb-search data template --- + await sor.sqlExe( + "UPDATE uapi SET data=${d}$ WHERE id='vdb-search'", + {"d": '{"collectionName": "{{collection}}", "vector": {{json.dumps(vector)}}, "topK": {{top_k}}}'}) + print('vdb-search data template fixed') + +asyncio.run(main())