update applying current ai insight from dashboard-cpsp
This commit is contained in:
1 parent
31272035e9
commit
b87f20e3b3
27 files changed
+5300
-343
No files matched your search
@@ -136,3 +136,18 @@ class AIInsightSerializer(PkAsIdMixin, CycleContextMixin, serializers.ModelSeria
|
||||
model = AIInsight
|
||||
fields = "__all__"
|
||||
read_only_fields = ["id", "created_at", "updated_at"]
|
||||
|
||||
def to_representation(self, instance):
|
||||
import json
|
||||
data = super().to_representation(instance)
|
||||
raw_citations = getattr(instance, "citations", "")
|
||||
if isinstance(raw_citations, list):
|
||||
data["citations"] = raw_citations
|
||||
elif isinstance(raw_citations, str) and raw_citations.strip():
|
||||
try:
|
||||
data["citations"] = json.loads(raw_citations)
|
||||
except Exception:
|
||||
data["citations"] = []
|
||||
else:
|
||||
data["citations"] = []
|
||||
return data
|
||||
Reference in new issue
Block a user