Skip to content

Commit 566a4a9

Browse files
authored
Merge pull request #2326 from anth-volk/fix/refactor-society-wide-ai
Refactor society-wide AI component
2 parents f4b1097 + 577ffbb commit 566a4a9

File tree

2 files changed

+294
-167
lines changed

2 files changed

+294
-167
lines changed

src/modals/HouseholdAIModal.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ export default function HouseholdAIModal(props) {
6565
return;
6666
}
6767

68+
// Response can either be static or streaming; if static, parse and set analysis
69+
if (res.headers.get("Content-Type") !== "application/x-ndjson") {
70+
const resJson = await res.json();
71+
const result = await JSON.parse(resJson.result);
72+
setIsLoading(false);
73+
setAnalysis(result);
74+
return;
75+
}
76+
77+
// Otherwise, handle streaming using ReadableStream
6878
const reader = res.body.getReader();
6979
const decoder = new TextDecoder();
7080
setIsLoading(false);

0 commit comments

Comments
 (0)