mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-01 10:24:56 -05:00
fix: handle string settings in LibraryAgent.from_db
Fixes AUTOGPT-SERVER-7N6 - Some DB records have settings stored as a JSON string instead of a dict, causing GraphSettings.model_validate to fail with 'str' object has no attribute 'value'.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, Any, Optional
|
||||
|
||||
@@ -239,7 +240,11 @@ class LibraryAgent(pydantic.BaseModel):
|
||||
is_latest_version=is_latest_version,
|
||||
is_favorite=agent.isFavorite,
|
||||
recommended_schedule_cron=agent.AgentGraph.recommendedScheduleCron,
|
||||
settings=GraphSettings.model_validate(agent.settings),
|
||||
settings=GraphSettings.model_validate(
|
||||
json.loads(agent.settings)
|
||||
if isinstance(agent.settings, str)
|
||||
else agent.settings
|
||||
),
|
||||
marketplace_listing=marketplace_listing_data,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user