Skip to content

Commit

Permalink
[feature] Add verification to configuration parameters
Browse files Browse the repository at this point in the history
**Phenomenon and reproduction steps**

**Root cause and solution**

**Impactions**

**Test method**

**Affected branch(es)**

* main

**Checklist**

- [ ] Dependencies update required
- [ ] Common bug (similar problem in other repo)
  • Loading branch information
congxi committed Jun 4, 2024
1 parent 8c7ee17 commit 1964a4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
24 changes: 0 additions & 24 deletions df-llm-agent/llm_agent_app/llm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,30 +244,6 @@ async def assistant_base(
f"{const.INVALID_PARAMETERS}, 平台: {platform} 未启用",
)

else:
try:
res_config = await db_models.LlmConfig.filter(**data_info).all()
except Exception as e:
raise BadRequestException("SQL_ERROR", const.SQL_ERROR, f"{e}")

# key = engine_name 时可能会存在多个配置,设置为当前使用值
for v in res_config:
v_dict = dict(v)
_key = v_dict["key"]
_value = v_dict["value"]

if _key == "engine_name":
if _value == engine_name:
engine_config[_key] = _value
else:
engine_config[_key] = _value

if engine_config.get("enable", "") != "1":
raise BadRequestException(
"INVALID_PARAMETERS",
f"{const.INVALID_PARAMETERS}, 平台: {platform} 未启用",
)

# print(engine_config, engine_config.get("engine_name"), engine_name)

if engine_config.get("engine_name", "") != engine_name:
Expand Down
5 changes: 4 additions & 1 deletion df-llm-agent/llm_agent_app/llm_agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ async def llm_agent_config_list(cls, user_info, platform=""):
_enable = _info.get('enable', False)
__info['enable'] = "1" if _enable else "0"
__info['model'] = _info.get('model', '')
__info['engine_name'] = _info.get('engine_name', [])
engine_name = _info.get('engine_name', [])
if not isinstance(engine_name, list):
raise BadRequestException("INVALID_PARAMETERS", f"{const.INVALID_PARAMETERS}, 配置项 engine_name 的值格式错误")
__info['engine_name'] = engine_name

res[f"{_platform}"] = __info

Expand Down

0 comments on commit 1964a4e

Please sign in to comment.