Skip to content

Commit 463b3c5

Browse files
committed
[NEB-231] Show Image response in Nebula
1 parent 669a95f commit 463b3c5

File tree

7 files changed

+554
-291
lines changed

7 files changed

+554
-291
lines changed

apps/dashboard/src/app/nebula-app/(app)/api/chat.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ export async function promptNebula(params: {
9999
break;
100100
}
101101

102+
case "image": {
103+
const data = JSON.parse(event.data) as {
104+
data: {
105+
width: number;
106+
height: number;
107+
url: string;
108+
};
109+
request_id: string;
110+
};
111+
112+
params.handleStream({
113+
event: "image",
114+
data: data.data,
115+
request_id: data.request_id,
116+
});
117+
break;
118+
}
119+
102120
case "action": {
103121
const data = JSON.parse(event.data);
104122

@@ -109,6 +127,7 @@ export async function promptNebula(params: {
109127
event: "action",
110128
type: "sign_transaction",
111129
data: parsedTxData,
130+
request_id: data.request_id,
112131
});
113132
} catch (e) {
114133
console.error("failed to parse action data", e, { event });
@@ -122,6 +141,7 @@ export async function promptNebula(params: {
122141
event: "action",
123142
type: "sign_swap",
124143
data: swapData,
144+
request_id: data.request_id,
125145
});
126146
} catch (e) {
127147
console.error("failed to parse action data", e, { event });
@@ -197,11 +217,22 @@ type ChatStreamedResponse =
197217
event: "action";
198218
type: "sign_transaction";
199219
data: NebulaTxData;
220+
request_id: string;
200221
}
201222
| {
202223
event: "action";
203224
type: "sign_swap";
204225
data: NebulaSwapData;
226+
request_id: string;
227+
}
228+
| {
229+
event: "image";
230+
data: {
231+
width: number;
232+
height: number;
233+
url: string;
234+
};
235+
request_id: string;
205236
}
206237
| {
207238
event: "context";
@@ -225,6 +256,10 @@ type ChatStreamedEvent =
225256
event: "delta";
226257
data: string;
227258
}
259+
| {
260+
event: "image";
261+
data: string;
262+
}
228263
| {
229264
event: "action";
230265
type: "sign_transaction" | "sign_swap";

apps/dashboard/src/app/nebula-app/(app)/api/types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ type SessionContextFilter = {
33
wallet_address: string | null;
44
};
55

6+
export type NebulaSessionHistoryMessage = {
7+
role: "user" | "assistant" | "action" | "image";
8+
content: string;
9+
timestamp: number;
10+
};
11+
612
export type SessionInfo = {
713
id: string;
814
account_id: string;
@@ -11,11 +17,7 @@ export type SessionInfo = {
1117
can_execute: boolean;
1218
created_at: string;
1319
deleted_at: string | null;
14-
history: Array<{
15-
role: "user" | "assistant" | "action";
16-
content: string;
17-
timestamp: number;
18-
}> | null;
20+
history: Array<NebulaSessionHistoryMessage> | null;
1921
updated_at: string;
2022
archived_at: string | null;
2123
title: string | null;

0 commit comments

Comments
 (0)