# 数据库智能体-llmdbAgent **Repository Path**: biehaocheng/llmh2-db ## Basic Information - **Project Name**: 数据库智能体-llmdbAgent - **Description**: 机器人或手机、汽车等物联网设备 的嵌入式数据库Agent,通过JDBC,ODBC,API接口访问 - **Primary Language**: Java - **License**: MPL-2.0 - **Default Branch**: master - **Homepage**: http://8.130.66.117:9090/ - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2024-09-09 - **Last Updated**: 2025-08-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 大模型数据库AGENT 大模型数据库智能体,实现 【机器人或手机、汽车等物联网设备】 的嵌入式数据库大脑 = 大模型+RAG+Agent Mesh+百度web搜索+机器学习+fabric+nlp+neo4j的功能,提供了大模型对话,知识库RAG编排,多智能体langgraph编排等功能; 开源版支持本百万级的大模型向量添加和查询,企业版本支持百亿级的大模型向量添加和查询; 可以通过GraalVM把java代码编译成2进制,减少内存消耗,提升执行速度; WEB平台体验地址:http://8.130.66.117:9090 ## 创新点 1. 降低大模型的agent,rag,ai工作流等开发难度,懂sql语句就能使用大模型,还能兼容和利旧以前的老系统。 2. 统一接口,屏蔽大模型的调用复杂性以及新技术快速迭代,不需要 python安装一套大模型的库,java又安装一套大模型的库,每种开发语言调用还不完全一致。 3. 通过数据库增强大模型的安全性。使用数据库的log,权限,以及对prompt的自动脱密加密,调用者不直接使用大模型api和api-key等技术,确保模型安全。 4. 数据库和 rag 有机融合。数据库扩展向量函数,实现多种rag查询功能。 5. agent和数据编排工具有机融合。一条sql就能实现多种agent,可以调用外部python等工具,也可以调用可视化数据编排的hpl工具。 6. 数据库和ai工作流有机融合。把ai工作流保存在表中,一条sql语句就能注册复杂muti-agent服务,供另外的sql调用agent服务,构建agent mesh的微服务集群更简单。 7. 在智能设备的边缘端,方便数据存储和大模型统一使用。 ## 安装和编译 ![img_4.png](img_4.png) 1. 建议使用graalVM 23(java版本23以上)编译为2进制,python的版本10以上,langgraph等相关组件,在服务器端配置大模型的.env环境变量; 2. 参考linux-bin目录下面的 h2-*,启动文件runllmdb.sh,.env文件等; 3. 默认是调用deepseek模型,每天免费调用6次,可以选择本地模型或其它收费模型包括gpt,qwen等; ``` [python] # 8.130.66.117为大模型数据库云服务器IP,sql语法可以兼容postgresql或mysql,oracle等 #import psycopg2 #con = psycopg2.connect("dbname=./llm.data;DATABASE_TO_LOWER=TRUE; user=usr_test password=usr_test host=8.130.66.117 port=5435 schema=usr_test_db; ") #python连接池 import psycopg2 from psycopg2 import pool # 使用连接池来管理数据库连接 conn_pool = psycopg2.pool.SimpleConnectionPool(1, 3, user='usr_test', password='usr_test', host='8.130.66.117', port='5435', database='./llm.data;DATABASE_TO_LOWER=TRUE;schema=usr_test_db;') try: conn = conn_pool.getconn() # 进行数据库操作 with conn.cursor() as cur: sql="select chatgpt('info','') " cur.execute(sql) rows = cur.fetchall() print(rows) finally: conn_pool.putconn(conn) [java] 通过jdbc调用 url=jdbc:h2:tcp://8.130.66.117:9092/./llm.data;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;schema=usr_test_db 用户名和密码:usr_test/usr_test ``` DBeaver等数据库工具访问例子(如果下载不了h2database的驱动,请在源码的linux-bin文件夹下载h2*.jar.zip解压后作为jdbc的驱动) ![img_3.png](img_3.png) # 为什么要使用大模型数据库 ## 安全性高 1. API_KEY管理: chatgpt的API_KEY配置在数据库服务器端,使用者通过API,JDBC,ODBC等方式访问chatgpt,不用接触到API_KEY; 2. prompt脱敏: 访问外网chatgpt服务,会对prompt提示词先做脱敏处理再提交到chatgpt,防止隐私泄露,如电话号码变成139***; 3. 信息混淆: 把prompt里面敏感信息自动替换变量,如"张三的电话号码是139***,",数据替换为"A的电话号码是B" .大模型返回后再把A替换为张三,B替换为139***; 4. prompt存储加密: 参考LangChain Hub功能,提供标准的prompt接口,把prompt加密后保存到数据库里面,对用户的prompt资产进行分类保护; 5. 大模型api调用日志和审计,以及熔断和限流等管理; 6. 结合NeMo-Guardrails系统,给大模型安装了安全围墙,对大模型的输入和输出内容做有害信息的控制和过滤,评估等; ## 性能快,更省钱 1. 数据库缓存:数据库默认启动缓存,如果是相同的大模型查询,会从缓存里面读取;缓存里面没有,才会从chatgpt里面读取,减少重复token消费; 2. prompt混淆压缩: 对prompt里面长的字符串 替换为短字符,在不影响prompt的情况下, 对空格,换行等进行压缩,减少prompt的token数; 3. 分布式:采用hadoop的mapreduce的技术,把超过大模型窗口的文字内容,分隔成多个块给不同的大模型数据库计算,计算完成后再合并输出; 4. 除了具有向量库的功能 如对向量增删改查等,还提供了生成向量的服务和功能,使用更加方便; 5. 简单agent和rag一条sql语句就能创建一个,复杂langgraph工作流图只是需要在表里面配置好工作流,实现muti-agent多智能体协同; ## 大模型组件生态圈 1. 通过大模型组件市场,下载其他人开源的组件代码和例子; 2. 通过大模型组件市场,把自定义组件发布到组件市场; 3. 通过download命令,从市场下载自定义函数; 4. 通过upload命令,可以把自定义函数上传到市场; 5. 通过list命令,查询市场里面自定义函数; ## 开发效率高,学习成本低 1. prompt管理:大模型数据库自带prompt管理,可以通过api访问,或者在sql里面关联使用; 2. chatgpt调用:一条sql就能实现一个智能体和实现多智能体协同; 2.1. 自动生成并且修复,调用修复函数实现查询rag->内容生成->内容验证->错误修改->正确的经验再进入到向量库; 2.2. 强化学习功能,调用lats函数基于langgraph实现Tree search + ReAct + Plan&Execute+ Reflection; 2.3. 物联网的桥梁下沉检测,调用检修函数实现输入规则和经验库,采集的数据字段,采集的图片字段, 就可以判断是否下沉,是否存在风险; 2.4. 经典的啤酒喝尿布关联分析,调用机器学习函数mlfpgrowth(编号字段,实体列表字段)就能分析出实体间关系,还可以写入neo4j中; 3. 标准化:采用不同的编程语言(python,java,c#,rust,go等)需要安装不同的SDK和编写不同的代码,采用大模型数据库后统一采用SQL语句,交流和沟通更方便; 4. 学习成本低:不需要学习springAI,langchain,langgraph,llamaindex,机器学习算法,大数据等不同的框架和技术,会使用sql就可以使用大模型服务器; 5. 扩展自定义函数: 通过数据库的自定义函数,方便添加java和python等不同语言的大模型函数,沉淀出公司自己的资产,不需要重复开发相同的功能; ## 兼容不同系统 1. 兼容主流的大模型: 功能基于langgraph和langchain开发,langchain支持的模型,大模型数据库都能兼容; 2. grafana的兼容: 连接大模型数据库,通过自然语言查询进行数据挖掘和探索,grafana对返回的结果进行可视化显示 3. ERP等信息系统的兼容: 可以通jdbc或postgresql的连接访问大模型数据库,连接成功后,就可以使用大模型的CRUD,NLP,机器学习和大模型的服务,没有额外的组件和系统安装; 4. 数据库和文件兼容: 通过etl等功能,可以对接主流的50+数据库类型;兼容pdf,office文件(word,excel,ppt) ,csv,图片,视频,声音,md等文件,对文件和文件目录索引和查询; 5. flink和spark的兼容: 通过etl对接flink和sprk,把计算后的结果交给大模型数据库再分析; ## Agent-mesh 微服务专用大模型 1. 每个服务拆分为不同小型Agent微模型和数据库,本地模型和外部大模型无缝配合; 2. 简单易用,不需要复杂的安装和配置‌; 3. 快速的启动时间和低内存消耗; 4. 支持分布式存储和计算,处理大规模的数据和并发请求; # 主要功能教程 ## 基本函数 -llm开头的函数教程 ```sql 注意:如果参数里面包含特殊字符,调用BASE64ENCODE函数转成base64格式再传入函数 --查询大模型信息 --默认是调用deepseek模型,每天免费调用6次。可以选择本地模型或其它收费模型包括gpt,qwen等; select chatgpt('info','') --大模型对话和 AGI生成内容 --参数1:系统提示词 --参数2:用户的问题 select llmchat('你是聊天助手','1+1=?' ) -- 通过表和excel文件批量的生成对话和AGI生成内容 --参数1:系统提示词 --参数2:用户的问题 select llmchat(al.sysprompt ,al.userprompt ) from usr_test_db.aigc_llm al --调用api的 react 的agent例子 --参数1:带少量例子或场景的json对象 --参数2:用户的问题 select llminvoke('[{"role": "system", "content": "你是聊天助手"},{"role": "user","content":"{input}"} ]' ,'{"input":"1+1=?"}') --调用api的 react 的agent例子 --参数1:工具参数, { "type": "rest", agent调用的工具类型:code:python字符串代码; rest:api的url; hpl:hpl文件路径;python:python文件路径;print:用于debug打印参数 "name": "echoA", 工具的名称 "desc": "echoA" 工具的描述 } --参数2: 提示词,'调用echoA函数,参数是hi,' --参数3: 工具的代码内容;'http://127.0.0.1:8082/88api/webssh/echoA.hpl' select llmagent('{"type": "rest","name": "echoA","desc": "echoA"}','调用echoA函数,参数是hi','http://127.0.0.1:8082/88api/webssh/echoA.hpl') --调用hpl的 react 的agent例子 。hpl是可视化工具编排平台,url是 http://8.130.66.117:8080/ui --参数1:工具参数, { "type": "hpl", agent调用的工具类型:code:python字符串代码; rest:api的url; hpl:hpl文件路径;python:python文件路径;print:用于debug打印参数 "name": "echoA", 工具的名称 "desc": "echoA" 工具的描述 } --参数2: 提示词,'调用echoA函数,参数是hi,' --参数3: 工具的代码内容;'$PROJECT_HOME/88api/webssh/echoA.hpl' select llmagent('{"type": "hpl","name": "echoA","desc": "echoA"}', '调用echoA函数,参数是hi','$PROJECT_HOME/88api/webssh/echoA.hpl') -- 调用api的 react 的agent例子 --参数1:工具参数, { "type": "print", agent调用的工具类型:code:python字符串代码; rest:api的url; hpl:hpl文件路径;python:python文件路径;print:用于debug打印参数 "name": "print", 工具的名称 "desc": "print" 工具的描述 } --参数2: 提示词,'调用print函数,参数是hi,' --参数3: 工具的代码内容;print类型不需要代码 select llmagent('{"type": "print","name": "print","desc": "print"}','调用print函数,参数是hi,','') -- 调用python代码的 react 的agent例子 --参数1:工具参数, { "type": "code", agent调用的工具类型:code:python字符串代码; rest:api的url; hpl:hpl文件路径;python:python文件路径;print:用于debug打印参数 "name": "echoA", 工具的名称 "desc": "echoA" 工具的描述 } --参数2: 提示词,'调用echoA函数,参数是hi,' --参数3: 工具的代码内容; select llmagent('{"type": "rest","name": "echoA","desc": "echoA"}', '调用echoA函数,参数是hi','def echoA(param): return "echoA"+param') ``` ## 多智能体协同 Agent mesh -grp开头的函数教程 体验地址:http://8.130.66.117:9090 多智能体langgraph教程 ```sql --查看专家库的表结构 -- deleted INTEGER DEFAULT 0, 删除标志 -- vct_name CHARACTER VARYING(500), 向量表名称 -- name CHARACTER VARYING(200), langgraph的节点agent的名称 -- tools CHARACTER VARYING(200) DEFAULT 'database-sql-tools', 节点agent使用的工具 -- prompt CHARACTER VARYING, 节点agent使用的prompt -- test CHARACTER VARYING(200),对生成答案测试工具 -- verify CHARACTER VARYING(200),答案和问题相似度对比工具 -- cond CHARACTER VARYING, langgraph的条件节点 -- parent_id INTEGER DEFAULT 0,langgraph的父节点 -- flag INTEGER DEFAULT 0, 0、表示推荐状态;1、发布状态;2、禁用状态 select * from ept_sql_convert -- 把专家表的内容 注册为langgraph的muti-agent 微服务 --参数1:专家表名称 --参数2: 向量库名称 select grp_regrec('ept_sql_convert','sql-convert/tools') -- 查找是否注册了微服务 --参数1:专家表名称 select grp_find('ept_sql_convert') -- 调用注册的微服务,如果不存在微服务,提示:Agent is None --参数1:表名称 ept_sql_convert --参数2:问题 select grp_chat('ept_sql_convert','select * from "Project" where "ProjectID" >0') ``` ## 智能体记忆和图数据库-rag开头函数教程 体验地址:http://8.130.66.117:9090 智能体rag教程 ```sql -- 加载问题和答案到向量表 -- 参数1:向量表名称proc/extract/tablename,如果向量表不存在,会自动创建 -- 参数2:问题是 hostname(111) -- 参数3:回答是 host_name(111) -- 参数4:关键词: 问题里面关键词:host_name,如果查询里面包含关键词,必定会查询到 -- 把问题和答案加入向量表 select rag_loadqa('proc/extract/tablename', 'hostname(222)','host_name(222)','host_name') -- 加载doc文档内容到向量表,rag的类型是doc -- 参数1:向量表名称proc/extract/tablename,如果向量表不存在,会自动创建 -- 参数2:问题是hostname(111) -- 参数3:rag的类型,目前支持问答qa,文档doc等,默认是'doc' select rag_loadtxt('proc/extract/tablename', 'hostname(111)','doc') -- llm根据向量表答案回答问题 -- 参数1:向量表名称:proc/extract/tablename,如果查询多个向量表,使用分号隔开t1;t2;t3; 系统自动会查询多个向量表 -- 参数2:系统提示词 -- 参数3:问题内容 hostname(222) -- 参数4:rag的类型,目前支持问答qa,文档doc等 -- 参数5:ent_vectinfo向量配置算法(BM25Okapi等)表主键id,可以不传。配置bm25d里面表名称会覆盖 sql语句里面的向量表名称 select rag_chat('proc/extract/tablename;', 'You are a Postgresql database expert','hostname(222)','qa') -- 加载文件夹和文件到向量表,rag的类型是doc -- 参数1:文件夹或文件名;如果是文件夹,自动批量加载文件夹下面的全部的文件(包括pdf,csv,word,ppt,md,图片,视频等) -- 参数2:文档的字符串分隔符:如 '[\n。?!?!]' select rag_loadfile('/home/softrobot/llm/qwne05/txt/测试.txt', '\n') -- 获取物理表名。有了物理表名后,可以执行常规sql如drop table,select,delete 和update等; -- 参数1:向量表名:proc/extract/tablename,如果查询多个向量表,使用分号隔开t1;t2;t3; 返回表名称数组 select rag_name('proc/extract/tablename;') -- 返回查询原始的字符串 -- 参数1:向量表名称proc/extract/tablename -- 参数2:问题是hostname(111) -- 参数3:rag的类型,目前支持问答qa,文档doc等 -- 参数4:查询类型,1:按关键词查询;2:按向量查询;0、混合查询 select rag_query('proc/extract/tablename', 'hostname','qa','1') -- 把字符串保存到图数据库库里面 -- 参数1:向量库的前缀neo4j,向量库默认生成 neo4j/chunks,neo4j/relationships,neo4j/entities -- 参数2:要保存的字符串 --qwen05解析比较慢 select rag_loadgb('neo4j','欧元区正逐渐从疫情和乌克兰战争引发的能源危机的双重冲击中恢复过来') -- 从图数据库里面查询 -- 参数1: 图数据库查询类型:local,global,hybrid,默认是hybrid,混合模式 -- 参数2:向量库的前缀neo4j -- 参数3:用户问题 select rag_chatgb('hybrid', 'neo4j','What are the top themes in this story') -- cosine向量比较 -- 参数1: 向量1 -- 参数2:向量2 select vct_cosine('vct1', 'vct2') -- 优化向量比较 -- 参数1: 向量1 -- 参数2:向量2 select vct_adjust('vct1', 'vct2') ``` ## 可选择的工具(包含api,文件,数据库,消息队列等)-tol开头的函数 体验地址:http://8.130.66.117:9090 智能体tol教程 ```sql -- 加载工具代码到表 -- 参数1:工具名称:read-table-ddl -- 参数2:工具的代码 select tol_loadcode('read-table-ddl', base64encode('def getpsql_table_ddl(param): from sqlalchemy import create_engine, MetaData, Table list=param.split(",") print(list) engine = create_engine(list[0]) # 反射数据库中的表 metadata = MetaData() metadata.reflect(bind=engine) # 获取反射的表 example_table = metadata.tables[list[1]] # 获取DDL语句 with engine.connect() as conn: ddl_script = str(example_table.create(conn)) return ddl_script')) -- 加载文件夹下面的python,hpl工具到表 -- 参数1:函数名称前缀,防止有相同的函数名称 -- 参数2:文件夹或文件,用分号分割多个文件或文件夹 select tol_loadfile('prefix-','/home/softrobot/llm/qwne05/tools;') -- 加载和训练工具使用的场景, -- 参数1:向量表名称:database/tools -- 参数2:工具使用的场景描述:Read the table ddl. uri is abc1, The name of the table is tab1 -- 参数3:工具的名称:read-table-ddl -- 参数4:参数描述:tab1 select tol_loadfunc('database/tools','Read the table ddl. uri is abc1, The name of the table is tab1','read-table-ddl','tab1') -- 根据问题描述,自动执行工具 -- 参数1:向量表名称database/tools -- 参数2:问题是 Read the table ddl. uri is 1234, The name of the table is 234 select tol_chat('database/tools;','Read the table ddl. uri is 1234, The name of the table is 234') -- 返回查询原始的字符串 -- 参数1:向量表名称:database/tools -- 参数2:问题是Read the table ddl select tol_query('database/tools','Read the table ddl') -- 从 【百度】 搜索 数据,代替国外搜索组件 -- 参数1:要搜索的内 -- 参数2:返回的条数 -- 参数3:高级配置参数,默认值是'{"url":"https://www.baidu.com/","input":"kw","btn":"su"}' select tol_baidu('小红薯',3) ``` ## 大模型安全-sft开头函数教程 体验地址:http://8.130.66.117:9090 大模型安全教程目录 ```sql -- 对字符串内容 脱敏 -- 参数1:需要 脱敏 的字符串 -- 参数2:敏感内容,多个内容用;分割 select sft_mask('我是一个来自星星的超人,具有超人本领', '超人;星星') ``` ## 规划和任务分解(任务计划,任务分解,探索等)-act开头的函数教程 体验地址:http://8.130.66.117:9090 智能体act教程 ```sql -- 加载 把问题分解为多个子任务 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题分解为子任务 subtask1: Find out the number of hours Thomas worked. #E2 = 1\nsubtask2: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_loadmap('act/plan/tablename', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week', 'subtask1: Find out the number of hours Thomas worked. #E2 = 1\nsubtask2: Find out the number of hours Toby worked. #E2 = 1','worked') -- 加载 把问题分解成多个机会 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题分解为子计划 plan1: Find out the number of hours Thomas worked. #E2 = 1\nplan2s: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_loadplan('act/plan/tablename', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week', 'plan1: Find out the number of hours Thomas worked. #E2 = 1\nplan2: Find out the number of hours Toby worked. #E2 = 1','worked') -- 加载 问题重写(换一个相近的问题) -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题换成新的问题 Thomas, Toby, and Rebecca worked a total of 157 hours -- 参数4:关键词: worked select act_loadwt('act/plan/tablename', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week', 'Thomas, Toby, and Rebecca worked a total of 157 hours','worked') -- 加载 生成与问题相关的列表 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:与问题相关的列表 relevance1: Find out the number of hours Thomas worked. #E2 = 1\nrelevance2: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_loadrelate('act/plan/tablename', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week', 'relevance1: Find out the number of hours Thomas worked. #E2 = 1\nrelevance2: Find out the number of hours Toby worked. #E2 = 1','worked') -- 加载 把问题分解为多个子任务 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题分解为子任务 subtask1: Find out the number of hours Thomas worked. #E2 = 1\nsubtask2: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_chatmap('act/plan/tablename;', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week') -- 加载 把问题分解成多个机会 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题分解为子计划 plan1: Find out the number of hours Thomas worked. #E2 = 1\nplan2s: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_chatplan('act/plan/tablename;', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week') -- 加载 问题重新(换一个相近的问题) -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:把当前问题换成新的问题 Thomas, Toby, and Rebecca worked a total of 157 hours -- 参数4:关键词: worked select act_chatwt('act/plan/tablename;', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week') -- 加载 生成与问题相关的列表 -- 参数1:向量表名称act/test,如果向量表不存在,会自动创建 -- 参数2:问题是 Thomas, Toby, and Rebecca worked a total of 157 hours in one week -- 参数3:与问题相关的列表 relevance1: Find out the number of hours Thomas worked. #E2 = 1\nrelevance2: Find out the number of hours Toby worked. #E2 = 1 -- 参数4:关键词: worked select act_chatrelate('act/plan/tablename;', 'Thomas, Toby, and Rebecca worked a total of 157 hours in one week') ``` ## 对执行结果反思,评估,优化-rft开头的函数 体验地址:http://8.130.66.117:9090 智能体rft教程 ```sql -- 加载doc文档内容到向量表,rag的类型是doc -- 参数1:向量表名称rft/relevancy,如果向量表不存在,会自动创建 -- 参数2:保存的txt内容:The FIFA World Cup in 2018 was won by the French national football team -- 参数3:关键字:FIFA World Cup select rft_loadtxt('rft/relevancy', 'The FIFA World Cup in 2018 was won by the French national football team','%FIFA World Cup%') -- 返回查询原始的字符串 -- 参数1:向量表名称rft/relevancy; -- 参数2:问题是The FIFA World Cup in 2018 -- 参数3:查询类型,1:按关键词查询;2:按向量查询;0、混合查询 select rft_query('rft/relevancy;','The FIFA World Cup in 2018','0') -- 关联分析 -- 参数1:向量表名称rft/relevancy; -- 参数2:输入值 input -- 参数3:期望的输出值 expected -- 参数4:实际输出值 output select rft_relevancy('rft/relevancy;','input','expected','output') -- 关联分析 -- 参数1:向量表名称rft/relevancy; -- 参数2:自定义判断的条件: criteria -- 参数3:输入值 input -- 参数4:期望的输出值 expected -- 参数5:实际输出值 output select rft_relevancy('rft/relevancy;','criteria','input','expected','output') ``` ## 机器学习ML-ml开头的函数教程 体验地址:http://8.130.66.117:9090 机器学习ml教程 ```sql select * from aigc_ml select JSON_ARRAYAGG(id) from aigc_ml select JSON_OBJECTAGG(id:GROWTH) from aigc_ml select CAST(JSON_OBJECTAGG(KEY id VALUE GROWTH) AS text) from aigc_ml -- FP-Growth算法 select ml_fpgrowth(id:growth) from aigc_ml -- apriori算法 select ml_apriori(id:growth) from aigc_ml -- forest分类算法 select ml_forestcls(x:y) from aigc_ml select CAST(ml_forestreg(x:y) AS text) AS ml from aigc_ml -- kmens算法 select ml_kmens(x:y) from aigc_ml -- knn分类算法 select ml_knncls(x:y) from aigc_ml -- knn回归算法 select ml_knnreg(x:y) from aigc_ml -- linear分类算法 select ml_linearcls(x:y) from aigc_ml -- linear回归算法 select ml_linearreg(x:y) from aigc_ml -- logistic分类算法 select ml_logistic(x:y) from aigc_ml -- svm分类算法 select ml_svmcls(x:y) from aigc_ml -- svm回归算法 select ml_svmreg(x:y) from aigc_ml -- DecisionTreeClassifier分类算法 select ml_treecls(x:y) from aigc_ml -- DecisionTreeRegressor算法 select ml_treereg(x:y) AS ml from aigc_ml ``` ## 自助BI和ELT教程 体验地址:http://8.130.66.117:9090 大模型自助BI教程目录 体验地址:http://8.130.66.117:8080/ui dataops平台实现数据开发,编排,ETL,调度,CI/CD,元数据管理,数据探索,发布api等功能 ```sql -- 通过rest api直接 访问pipe和调度文件 curl --location --request POST 'http://8.130.66.117:8082/api/v1/echoA.hpl' -- 通过etl函数运行数据编排echo.hpl,默认目录是pip的项目路径 SELECT etl('/api/v1/echoA.hpl','') SELECT etl('info.ai','') SELECT etl('/api/v1/echo.hpl','{"cnt":"5L2g5aW9"}') -- 通过etl查询ai接口 SELECT etl('/api/v1/echo.ai','') -- 通过etl函数运行调度day.hwf SELECT etl('/02dispatch/day.hwf','') -- 数据库启动时,自动运行system_dispatch里面的status>0的任务 -- status=0:禁用;1:运行中;2:运行结束;3:运行中发生错误; SELECT * from system_dispatch -- 修改system_dispatch的状态'disable':修改为启动状态, 'start':修改为启动状态,'end':修改结束状态,'error':修改错误状态 SELECT TOL_DISP_STATUS('/02dispatch/day.hwf','start') -- 'start':启动全部任务,'end':结束全部任务 SELECT TOL_DISPATCH('start') -- 运行python文件,默认目录是数据库数据文件目录 SELECT python('info.py','') -- csvread,csvwrite:csv文件的读取和写入 SELECT * FROM CSVREAD('/home/softrobot/webapps/ROOT/BOOT-INF/config/projects/samples/200testdata/towngas.txt') CALL CSVWRITE('/tmp/test.csv', 'SELECT * FROM AIGC_LLM') -- 普通文件的读取和写入 SELECT FILE_WRITE('Hello world', '/tmp/hello.txt') SELECT FILE_READ('/tmp/hello.txt', 'utf-8') as txt -- LINK_SCHEMA:数据库连接,如果targetSchemaString不存在,自动创建targetSchemaString -- LINK_SCHEMA ( targetSchemaString , driverString , urlString ,userString , passwordString , sourceSchemaString ) SELECT * FROM LINK_SCHEMA('testto', 'com.mysql.cj.jdbc.Driver', 'jdbc:mysql://8.130.66.117:3306/testto', 'testto', 'testto', '') -- 外部连接数据库link表 CREATE LINKED TABLE IF NOT EXISTS system_users('com.mysql.cj.jdbc.Driver', 'jdbc:mysql://8.130.66.117:3306/testto', 'testto', 'testto', 'system_users') select * from system_users -- fileread:读取不同的文件数据,以及自然语言查询############################") SELECT * FROM file_read('$PROJECT_HOME/200testdata/towngas.txt','') SELECT * FROM file_read('$PROJECT_HOME/200testdata/towngas.txt','What brand of towngas do people aged between 30 and 40 buy') -- pdf单独处理 select file_pdf('$PROJECT_HOME/200testdata/测试.pdf') from aigc_ml LIMIT 1 ```