diff --git a/dsLightRag/Test/QWenImage/T1_QwenImageSync.py b/dsLightRag/Test/QWenImage/T1_QwenImageSync.py new file mode 100644 index 00000000..7900cc12 --- /dev/null +++ b/dsLightRag/Test/QWenImage/T1_QwenImageSync.py @@ -0,0 +1,30 @@ +from http import HTTPStatus +from urllib.parse import urlparse, unquote +from pathlib import PurePosixPath +import requests +# pip install -U dashscope +from dashscope import ImageSynthesis +import os + +prompt = "一副典雅庄重的对联悬挂于厅堂之中,房间是个安静古典的中式布置,桌子上放着一些青花瓷,对联上左书“义本生知人机同道善思新”,右书“通云赋智乾坤启数高志远”, 横批“智启通义”,字体飘逸,中间挂在一着一副中国风的画作,内容是岳阳楼。" + +# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx" +api_key = os.getenv("DASHSCOPE_API_KEY") + +print('----同步调用,请等待任务执行----') +rsp = ImageSynthesis.call(api_key=api_key, + model="qwen-image", + prompt=prompt, + n=1, + size='1328*1328') +print('response: %s' % rsp) +if rsp.status_code == HTTPStatus.OK: + # 在当前目录下保存图片 + for result in rsp.output.results: + file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1] + with open('./%s' % file_name, 'wb+') as f: + f.write(requests.get(result.url).content) +else: + print('同步调用失败, status_code: %s, code: %s, message: %s' % + (rsp.status_code, rsp.code, rsp.message)) + diff --git a/dsLightRag/Test/QWenImage/T2_QWenImageAsync.py b/dsLightRag/Test/QWenImage/T2_QWenImageAsync.py new file mode 100644 index 00000000..530ebec1 --- /dev/null +++ b/dsLightRag/Test/QWenImage/T2_QWenImageAsync.py @@ -0,0 +1,74 @@ +from http import HTTPStatus +from urllib.parse import urlparse, unquote +from pathlib import PurePosixPath +import requests +from dashscope import ImageSynthesis +import os + +prompt = "一副典雅庄重的对联悬挂于厅堂之中,房间是个安静古典的中式布置,桌子上放着一些青花瓷,对联上左书“义本生知人机同道善思新”,右书“通云赋智乾坤启数高志远”, 横批“智启通义”,字体飘逸,中间挂在一着一副中国风的画作,内容是岳阳楼。" + +# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx" +api_key = os.getenv("DASHSCOPE_API_KEY") + +def async_call(): + print('----创建任务----') + task_info = create_async_task() + print('----等待任务结束返回图像url----') + wait_async_task(task_info) + + +# 创建异步任务 +def create_async_task(): + rsp = ImageSynthesis.async_call(api_key=api_key, + model="qwen-image", + prompt=prompt, + n=1, + size='1328*1328') + print(rsp) + if rsp.status_code == HTTPStatus.OK: + print(rsp.output) + else: + print('创建任务失败, status_code: %s, code: %s, message: %s' % + (rsp.status_code, rsp.code, rsp.message)) + return rsp + + +# 等待异步任务结束 +def wait_async_task(task): + rsp = ImageSynthesis.wait(task) + print(rsp) + if rsp.status_code == HTTPStatus.OK: + print(rsp.output) + for result in rsp.output.results: + file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1] + with open('./%s' % file_name, 'wb+') as f: + f.write(requests.get(result.url).content) + else: + print('任务执行失败, status_code: %s, code: %s, message: %s' % + (rsp.status_code, rsp.code, rsp.message)) + + +# 获取异步任务信息 +def fetch_task_status(task): + status = ImageSynthesis.fetch(task) + print(status) + if status.status_code == HTTPStatus.OK: + print(status.output.task_status) + else: + print('获取任务失败, status_code: %s, code: %s, message: %s' % + (status.status_code, status.code, status.message)) + + +# 取消异步任务,只有处于PENDING状态的任务才可以取消 +def cancel_task(task): + rsp = ImageSynthesis.cancel(task) + print(rsp) + if rsp.status_code == HTTPStatus.OK: + print(rsp.output.task_status) + else: + print('取消任务失败, status_code: %s, code: %s, message: %s' % + (rsp.status_code, rsp.code, rsp.message)) + + +if __name__ == '__main__': + async_call() \ No newline at end of file diff --git a/dsLightRag/Test/QWenImage/__init__.py b/dsLightRag/Test/QWenImage/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/dsLightRag/Test/__init__.py b/dsLightRag/Test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc b/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc index 55a2d426..01da2785 100644 Binary files a/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc and b/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc differ diff --git a/dsRagAnything/T2_Query.py b/dsRagAnything/T2_Query.py index c99efc57..54ad3145 100644 --- a/dsRagAnything/T2_Query.py +++ b/dsRagAnything/T2_Query.py @@ -22,7 +22,7 @@ async def query(user_prompt,rag_path): if __name__ == "__main__": - rag_path='./Topic/HuangWanQiao' + rag_path='./Topic/Geogebra' user_prompt = "简洁回复。" configure_logging() asyncio.run(query(user_prompt,rag_path)) diff --git a/dsRagAnything/Topic/Geogebra/kv_store_doc_status.json b/dsRagAnything/Topic/Geogebra/kv_store_doc_status.json index be662948..f4195e29 100644 --- a/dsRagAnything/Topic/Geogebra/kv_store_doc_status.json +++ b/dsRagAnything/Topic/Geogebra/kv_store_doc_status.json @@ -198,12 +198,13 @@ "content_summary": "GeoGebra指令汇编简体中文5.0.527.0\n\n唐家军 编著2019 年 3 月 6 日\n\n前 言\n\nGeoGebra的开源性使得它的指令和功能更新很快,本文的指令名(包括英文和中文名称)指令,基于 GeoGebra5.0.527.0版本,按照功能分块并以中文拼音顺序排列。\n\nGeoGebra指令包括函数和命令两部分,在中文界面使用过程中,输入英文指令或者中文指令名称,只要符合格式规范,都可以得到需要的结果。\n\n函数都是使用英文名称简写后边携带圆括弧的形式,对圆括弧内的数值、表达式或者变量...", "content_length": 424241, "created_at": "2025-08-26T10:26:25.469523+00:00", - "updated_at": "2025-08-26T11:21:10.919820+00:00", + "updated_at": "2025-08-27T08:03:12+00:00", "file_path": "GeoGebra.pdf", "track_id": "insert_20250826_182625_a361d91d", "metadata": { "processing_start_time": 1756203985, "processing_end_time": 1756207270 - } + }, + "multimodal_processed": true } } \ No newline at end of file diff --git a/dsRagAnything/Topic/Geogebra/kv_store_llm_response_cache.json b/dsRagAnything/Topic/Geogebra/kv_store_llm_response_cache.json index f63b3581..b2444e84 100644 --- a/dsRagAnything/Topic/Geogebra/kv_store_llm_response_cache.json +++ b/dsRagAnything/Topic/Geogebra/kv_store_llm_response_cache.json @@ -7473,5 +7473,18 @@ "create_time": 1756206515, "update_time": 1756206515, "_id": "default:extract:e523428e0514a203111710ce9ac5c5d3" + }, + "hybrid:keywords:071f224e4117a8c20e9db67c6065c076": { + "return": "{\"high_level_keywords\": [\"\\u7b80\\u6d01\\u56de\\u590d\"], \"low_level_keywords\": []}", + "cache_type": "keywords", + "chunk_id": null, + "embedding": null, + "embedding_shape": null, + "embedding_min": null, + "embedding_max": null, + "original_prompt": "简洁回复。", + "create_time": 1756253021, + "update_time": 1756253021, + "_id": "hybrid:keywords:071f224e4117a8c20e9db67c6065c076" } } \ No newline at end of file