通用智能体子账号使用主账号
This commit is contained in:
parent
462ba14074
commit
0b1f3d411f
@ -615,13 +615,19 @@ async def fetch_bot_config_from_db(bot_user_id: str, user_identifier: Optional[s
|
||||
if not config.get("api_key") and user_identifier:
|
||||
async with pool.connection() as conn:
|
||||
async with conn.cursor() as cursor:
|
||||
# Sub-accounts should fall back to the parent account's API token
|
||||
await cursor.execute(
|
||||
"SELECT new_api_token FROM agent_user WHERE username = %s",
|
||||
"""
|
||||
SELECT u.new_api_token, parent.new_api_token
|
||||
FROM agent_user u
|
||||
LEFT JOIN agent_user parent ON u.parent_id = parent.id
|
||||
WHERE u.username = %s
|
||||
""",
|
||||
(user_identifier,)
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
if row and row[0]:
|
||||
config["api_key"] = row[0]
|
||||
if row:
|
||||
config["api_key"] = row[1] or row[0] or ""
|
||||
logger.info(
|
||||
f"Fetched general agent config: model={config['model']}, "
|
||||
f"api_key={'*' + config['api_key'][-4:] if config.get('api_key') else 'N/A'}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user