Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions apps/dashboard/src/app/nebula-app/(app)/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ export async function promptNebula(params: {
break;
}

case "image": {
const data = JSON.parse(event.data) as {
data: {
width: number;
height: number;
url: string;
};
request_id: string;
};

params.handleStream({
event: "image",
data: data.data,
request_id: data.request_id,
});
break;
}

case "action": {
const data = JSON.parse(event.data);

Expand All @@ -109,6 +127,7 @@ export async function promptNebula(params: {
event: "action",
type: "sign_transaction",
data: parsedTxData,
request_id: data.request_id,
});
} catch (e) {
console.error("failed to parse action data", e, { event });
Expand All @@ -122,6 +141,7 @@ export async function promptNebula(params: {
event: "action",
type: "sign_swap",
data: swapData,
request_id: data.request_id,
});
} catch (e) {
console.error("failed to parse action data", e, { event });
Expand Down Expand Up @@ -197,11 +217,22 @@ type ChatStreamedResponse =
event: "action";
type: "sign_transaction";
data: NebulaTxData;
request_id: string;
}
| {
event: "action";
type: "sign_swap";
data: NebulaSwapData;
request_id: string;
}
| {
event: "image";
data: {
width: number;
height: number;
url: string;
};
request_id: string;
}
| {
event: "context";
Expand All @@ -225,6 +256,10 @@ type ChatStreamedEvent =
event: "delta";
data: string;
}
| {
event: "image";
data: string;
}
| {
event: "action";
type: "sign_transaction" | "sign_swap";
Expand Down
12 changes: 7 additions & 5 deletions apps/dashboard/src/app/nebula-app/(app)/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ type SessionContextFilter = {
wallet_address: string | null;
};

export type NebulaSessionHistoryMessage = {
role: "user" | "assistant" | "action" | "image";
content: string;
timestamp: number;
};

export type SessionInfo = {
id: string;
account_id: string;
Expand All @@ -11,11 +17,7 @@ export type SessionInfo = {
can_execute: boolean;
created_at: string;
deleted_at: string | null;
history: Array<{
role: "user" | "assistant" | "action";
content: string;
timestamp: number;
}> | null;
history: Array<NebulaSessionHistoryMessage> | null;
updated_at: string;
archived_at: string | null;
title: string | null;
Expand Down
Loading
Loading