'commit'
This commit is contained in:
@@ -20,9 +20,10 @@ GLM_MODEL_NAME = "THUDM/GLM-4.1V-9B-Thinking"
|
|||||||
# 阿里云API信息【绘智科技】
|
# 阿里云API信息【绘智科技】
|
||||||
ALY_LLM_API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc"
|
ALY_LLM_API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc"
|
||||||
ALY_LLM_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
ALY_LLM_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||||
ALY_LLM_MODEL_NAME = "qwen-plus"
|
# 通义千问
|
||||||
|
# ALY_LLM_MODEL_NAME = "qwen-plus"
|
||||||
|
# Kimi K2大模型
|
||||||
|
ALY_LLM_MODEL_NAME = "Moonshot-Kimi-K2-Instruct"
|
||||||
|
|
||||||
# 智谱的API KEY【吴缤申请个人版免费】
|
# 智谱的API KEY【吴缤申请个人版免费】
|
||||||
ZHIPU_API_KEY = "78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9"
|
ZHIPU_API_KEY = "78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9"
|
||||||
@@ -30,4 +31,3 @@ ZHIPU_API_KEY = "78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9"
|
|||||||
# GPTNB的API KEY
|
# GPTNB的API KEY
|
||||||
GPTNB_API_KEY = "sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662"
|
GPTNB_API_KEY = "sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662"
|
||||||
GPTNB_BASE_URL = "https://goapi.gptnb.ai"
|
GPTNB_BASE_URL = "https://goapi.gptnb.ai"
|
||||||
|
|
||||||
|
Binary file not shown.
BIN
dsRagAnything/Doc/GeoGebra5经典版指令汇编201903061.pdf
Normal file
BIN
dsRagAnything/Doc/GeoGebra5经典版指令汇编201903061.pdf
Normal file
Binary file not shown.
@@ -3,10 +3,13 @@ from raganything import RAGAnything, RAGAnythingConfig
|
|||||||
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
from lightrag.llm.openai import openai_complete_if_cache, openai_embed
|
||||||
from lightrag.utils import EmbeddingFunc
|
from lightrag.utils import EmbeddingFunc
|
||||||
|
|
||||||
|
import Config.Config
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# 设置 API 配置
|
# 设置 API 配置
|
||||||
api_key = "your-api-key"
|
api_key = Config.Config.ALY_LLM_API_KEY
|
||||||
base_url = "your-base-url" # 可选
|
base_url = Config.Config.ALY_LLM_BASE_URL
|
||||||
|
|
||||||
# 创建 RAGAnything 配置
|
# 创建 RAGAnything 配置
|
||||||
config = RAGAnythingConfig(
|
config = RAGAnythingConfig(
|
||||||
@@ -21,7 +24,7 @@ async def main():
|
|||||||
# 定义 LLM 模型函数
|
# 定义 LLM 模型函数
|
||||||
def llm_model_func(prompt, system_prompt=None, history_messages=[], **kwargs):
|
def llm_model_func(prompt, system_prompt=None, history_messages=[], **kwargs):
|
||||||
return openai_complete_if_cache(
|
return openai_complete_if_cache(
|
||||||
"gpt-4o-mini",
|
Config.Config.ALY_LLM_MODEL_NAME,
|
||||||
prompt,
|
prompt,
|
||||||
system_prompt=system_prompt,
|
system_prompt=system_prompt,
|
||||||
history_messages=history_messages,
|
history_messages=history_messages,
|
||||||
@@ -37,19 +40,19 @@ async def main():
|
|||||||
# 如果提供了messages格式(用于多模态VLM增强查询),直接使用
|
# 如果提供了messages格式(用于多模态VLM增强查询),直接使用
|
||||||
if messages:
|
if messages:
|
||||||
return openai_complete_if_cache(
|
return openai_complete_if_cache(
|
||||||
"gpt-4o",
|
Config.Config.GLM_MODEL_NAME,
|
||||||
"",
|
"",
|
||||||
system_prompt=None,
|
system_prompt=None,
|
||||||
history_messages=[],
|
history_messages=[],
|
||||||
messages=messages,
|
messages=messages,
|
||||||
api_key=api_key,
|
api_key=Config.Config.GLM_API_KEY,
|
||||||
base_url=base_url,
|
base_url=Config.Config.GLM_BASE_URL,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
# 传统单图片格式
|
# 传统单图片格式
|
||||||
elif image_data:
|
elif image_data:
|
||||||
return openai_complete_if_cache(
|
return openai_complete_if_cache(
|
||||||
"gpt-4o",
|
Config.Config.GLM_MODEL_NAME,
|
||||||
"",
|
"",
|
||||||
system_prompt=None,
|
system_prompt=None,
|
||||||
history_messages=[],
|
history_messages=[],
|
||||||
@@ -72,8 +75,8 @@ async def main():
|
|||||||
if image_data
|
if image_data
|
||||||
else {"role": "user", "content": prompt},
|
else {"role": "user", "content": prompt},
|
||||||
],
|
],
|
||||||
api_key=api_key,
|
api_key=Config.Config.GLM_API_KEY,
|
||||||
base_url=base_url,
|
base_url=Config.Config.GLM_BASE_URL,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
# 纯文本格式
|
# 纯文本格式
|
||||||
@@ -82,13 +85,13 @@ async def main():
|
|||||||
|
|
||||||
# 定义嵌入函数
|
# 定义嵌入函数
|
||||||
embedding_func = EmbeddingFunc(
|
embedding_func = EmbeddingFunc(
|
||||||
embedding_dim=3072,
|
embedding_dim=Config.Config.EMBED_DIM,
|
||||||
max_token_size=8192,
|
max_token_size=Config.Config.EMBED_MAX_TOKEN_SIZE,
|
||||||
func=lambda texts: openai_embed(
|
func=lambda texts: openai_embed(
|
||||||
texts,
|
texts,
|
||||||
model="text-embedding-3-large",
|
model=Config.Config.EMBED_MODEL_NAME,
|
||||||
api_key=api_key,
|
api_key=Config.Config.EMBED_API_KEY,
|
||||||
base_url=base_url,
|
base_url=Config.Config.EMBED_BASE_URL,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -102,7 +105,7 @@ async def main():
|
|||||||
|
|
||||||
# 处理文档
|
# 处理文档
|
||||||
await rag.process_document_complete(
|
await rag.process_document_complete(
|
||||||
file_path="path/to/your/document.pdf",
|
file_path="./Doc/GeoGebra5经典版指令汇编201903061.pdf",
|
||||||
output_dir="./output",
|
output_dir="./output",
|
||||||
parse_method="auto"
|
parse_method="auto"
|
||||||
)
|
)
|
||||||
@@ -115,19 +118,6 @@ async def main():
|
|||||||
)
|
)
|
||||||
print("文本查询结果:", text_result)
|
print("文本查询结果:", text_result)
|
||||||
|
|
||||||
# 多模态查询 - 包含具体多模态内容的查询
|
|
||||||
multimodal_result = await rag.aquery_with_multimodal(
|
|
||||||
"分析这个性能数据并解释与现有文档内容的关系",
|
|
||||||
multimodal_content=[{
|
|
||||||
"type": "table",
|
|
||||||
"table_data": """系统,准确率,F1分数
|
|
||||||
RAGAnything,95.2%,0.94
|
|
||||||
基准方法,87.3%,0.85""",
|
|
||||||
"table_caption": "性能对比结果"
|
|
||||||
}],
|
|
||||||
mode="hybrid"
|
|
||||||
)
|
|
||||||
print("多模态查询结果:", multimodal_result)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
Reference in New Issue
Block a user