46 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from appPublic.log import debug, error, info
from ahserver.serverenv import ServerEnv
import aiohttp
from aiohttp import ClientSession, ClientTimeout
import json
from .folderinfo import RagFileMgr
from .ragprogram import set_program, get_rag_programs
from .ragllm_utils import get_ragllms_by_catelog
from appPublic.registerfunction import RegisterFunction
from sqlor.dbpools import DBPools
from appPublic.registerfunction import RegisterFunction
from rag.ragapi import docs, get_kdbs, fusedsearch, textinsert
async def get_user_kdbs(request):
env = request._run_ns
db = env.DBPools()
dbname = env.get_module_dbname('rag')
userorgid = await env.get_userorgid()
async with db.sqlorContext(dbname) as sor:
sql = "select * from kdb where ownerid = ${orgid}$"
sql = "select * from kdb where orgid = ${orgid}$"
recs = await sor.sqlExe(sql, {'orgid': userorgid})
return recs
return recs
return []
def load_rag():
"""
初始化 ServerEnv绑定 MilvusConnection 的所有功能。
"""
env = ServerEnv()
env.docs = docs
env.RagFileMgr = RagFileMgr
env.set_program = set_program
env.get_rag_programs = get_rag_programs
env.get_ragllms_by_catelog = get_ragllms_by_catelog
env.get_user_kdbs = get_user_kdbs
rf = RegisterFunction()
rf.register('docs', docs)
rf.register('get_kdbs', get_kdbs)
rf.register('fusedsearch', fusedsearch)
rf.register('textinsert', textinsert)