fix: fallback to default DB for LLM config lookup
- _get_llm_config now tries module DB and 'default' DB - Adds logging to show which DB is accessed - Prevents empty config when table is in default DB
This commit is contained in:
parent
d22dfdf383
commit
a7f99fc710
@ -77,20 +77,29 @@ LLM_PROVIDERS = {
|
|||||||
|
|
||||||
async def _get_llm_config() -> Dict[str, Any]:
|
async def _get_llm_config() -> Dict[str, Any]:
|
||||||
"""Get LLM client configuration from harnessed_agent_config table."""
|
"""Get LLM client configuration from harnessed_agent_config table."""
|
||||||
|
dbnames_to_try = ['default']
|
||||||
try:
|
try:
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
dbname = env.get_module_dbname('harnessed_agent')
|
module_db = env.get_module_dbname('harnessed_agent')
|
||||||
|
if module_db not in dbnames_to_try:
|
||||||
|
dbnames_to_try.insert(0, module_db)
|
||||||
except Exception:
|
except Exception:
|
||||||
dbname = 'default'
|
pass
|
||||||
|
|
||||||
try:
|
for dbname in dbnames_to_try:
|
||||||
async with DBPools().sqlorContext(dbname) as sor:
|
try:
|
||||||
rows = await sor.R('harnessed_agent_config', {},
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
orderby='updated_at DESC', limit=1)
|
rows = await sor.R('harnessed_agent_config', {},
|
||||||
if rows:
|
orderby='updated_at DESC', limit=1)
|
||||||
return rows[0]
|
if rows:
|
||||||
except Exception as e:
|
info(f"Loaded LLM config from DB '{dbname}'")
|
||||||
error(f"Failed to fetch LLM config: {e}")
|
return rows[0]
|
||||||
|
else:
|
||||||
|
warning(f"No rows in harnessed_agent_config in DB '{dbname}'")
|
||||||
|
except Exception as e:
|
||||||
|
error(f"Failed to fetch LLM config from DB '{dbname}': {e}")
|
||||||
|
|
||||||
|
error("LLM config not found in any database")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user