Skip to content

Commit e00b599

Browse files
Merge pull request #6 from KintsugiMindfulWellness/update_parsing
updating prediction result parsing.
2 parents fd91352 + 3e76735 commit e00b599

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "kintsugi-python"
3-
version = "0.1.7"
3+
version = "0.1.8"
44

55
description = "Python SDK to access Kintsugi Voice API V2."
66
authors = [

src/kintsugi/model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22
from datetime import datetime
3-
3+
from dataclasses import dataclass, field
4+
from typing import Optional
45

56
class FeedbackScore:
67
category: str
@@ -9,14 +10,15 @@ class FeedbackScore:
910
phq_9: str
1011

1112

13+
@dataclass
1214
class Prediction:
1315
session_id: str
14-
predicted_score: dict = {}
15-
feedback_score: FeedbackScore
1616
created_at: datetime
1717
updated_at: datetime
1818
is_calibrated: bool
1919
status: str
20+
feedback_score: Optional[FeedbackScore] = None
21+
predicted_score: dict = field(default_factory=dict)
2022

2123
def get_score(self, category: str) -> str | None:
2224
return self.predicted_score.get(category, None)

src/kintsugi/parsers.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ def parse(self, data: dict) -> FeedbackScore:
2121

2222
class PredictionParser:
2323
def parse(self, data: dict) -> Prediction:
24-
output = Prediction()
24+
output = Prediction(
25+
session_id=data['session_id'],
26+
created_at=data['created_at'],
27+
updated_at=data['updated_at'],
28+
is_calibrated=data['is_calibrated'],
29+
status=data['status'],
30+
)
2531

26-
output.session_id = data['session_id']
27-
output.created_at = data['created_at']
28-
output.updated_at = data['updated_at']
29-
output.is_calibrated = data['is_calibrated']
30-
output.status = data['status']
3132

3233
if output.status != 'processing':
3334
categories = data['model_category'].split(',')

0 commit comments

Comments
 (0)