Skip to content

Commit b3f3ce4

Browse files
committed
resolve conflict
1 parent d473867 commit b3f3ce4

File tree

2 files changed

+56
-24
lines changed

2 files changed

+56
-24
lines changed

templates/types/streaming/express/src/controllers/stream-helper.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ export function appendImageData(data: StreamData, imageUrl?: string) {
1717
});
1818
}
1919

20-
export type UploadedCsv = {
21-
content: string;
22-
filename: string;
23-
filesize: number;
24-
};
25-
26-
export function appendCsvData(data: StreamData, uploadedCsv?: UploadedCsv) {
27-
if (!uploadedCsv) return;
28-
data.appendMessageAnnotation({
29-
type: "csv",
30-
data: uploadedCsv,
31-
});
20+
function getNodeUrl(metadata: Metadata) {
21+
const url = metadata["URL"];
22+
if (url) return url;
23+
const fileName = metadata["file_name"];
24+
if (!process.env.FILESERVER_URL_PREFIX) {
25+
console.warn(
26+
"FILESERVER_URL_PREFIX is not set. File URLs will not be generated.",
27+
);
28+
return undefined;
29+
}
30+
if (fileName) {
31+
return `${process.env.FILESERVER_URL_PREFIX}/data/${fileName}`;
32+
}
33+
return undefined;
3234
}
3335

3436
export function appendSourceData(
@@ -119,3 +121,17 @@ export function createCallbackManager(stream: StreamData) {
119121

120122
return callbackManager;
121123
}
124+
125+
export type UploadedCsv = {
126+
content: string;
127+
filename: string;
128+
filesize: number;
129+
};
130+
131+
export function appendCsvData(data: StreamData, uploadedCsv?: UploadedCsv) {
132+
if (!uploadedCsv) return;
133+
data.appendMessageAnnotation({
134+
type: "csv",
135+
data: uploadedCsv,
136+
});
137+
}

templates/types/streaming/nextjs/app/api/chat/stream-helper.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ export function appendImageData(data: StreamData, imageUrl?: string) {
1717
});
1818
}
1919

20-
export type UploadedCsv = {
21-
content: string;
22-
filename: string;
23-
filesize: number;
24-
};
25-
26-
export function appendCsvData(data: StreamData, uploadedCsv?: UploadedCsv) {
27-
if (!uploadedCsv) return;
28-
data.appendMessageAnnotation({
29-
type: "csv",
30-
data: uploadedCsv,
31-
});
20+
function getNodeUrl(metadata: Metadata) {
21+
const url = metadata["URL"];
22+
if (url) return url;
23+
const fileName = metadata["file_name"];
24+
if (!process.env.FILESERVER_URL_PREFIX) {
25+
console.warn(
26+
"FILESERVER_URL_PREFIX is not set. File URLs will not be generated.",
27+
);
28+
return undefined;
29+
}
30+
if (fileName) {
31+
return `${process.env.FILESERVER_URL_PREFIX}/data/${fileName}`;
32+
}
33+
return undefined;
3234
}
3335

3436
export function appendSourceData(
@@ -119,3 +121,17 @@ export function createCallbackManager(stream: StreamData) {
119121

120122
return callbackManager;
121123
}
124+
125+
export type UploadedCsv = {
126+
content: string;
127+
filename: string;
128+
filesize: number;
129+
};
130+
131+
export function appendCsvData(data: StreamData, uploadedCsv?: UploadedCsv) {
132+
if (!uploadedCsv) return;
133+
data.appendMessageAnnotation({
134+
type: "csv",
135+
data: uploadedCsv,
136+
});
137+
}

0 commit comments

Comments
 (0)