Skip to content

Commit 0ed0fc7

Browse files
committed
setup http streaming with dummy data
1 parent f8bf78d commit 0ed0fc7

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

client/packages/lowcoder/src/comps/queries/httpQuery/sseHttpQuery.tsx

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class SseHttpQuery extends SseHttpTmpQuery {
112112
const processedParams = this.processParameters(params, props);
113113

114114
// Build request from processed parameters
115-
const { url, headers, method, body } = this.buildRequestFromParams(processedParams);
115+
const { url, headers, method, body } = this.buildRequestFromParams(processedParams, props.args);
116116

117117
// Execute streaming logic
118118
if (method === "GET") {
@@ -151,41 +151,23 @@ export class SseHttpQuery extends SseHttpTmpQuery {
151151
];
152152
}
153153

154-
private buildRequestFromParams(processedParams: Array<{key: string, value: any}>) {
155-
debugger;
156-
const paramMap = new Map(processedParams.map(p => [p.key, p.value]));
157-
158-
// Extract URL
159-
const baseUrl = paramMap.get('path') || '';
160-
const url = new URL(baseUrl);
161-
162-
// Add query parameters
163-
Object.entries(paramMap).forEach(([key, value]) => {
164-
if (key.startsWith('params.') && key.endsWith('.value')) {
165-
const paramName = key.replace('params.', '').replace('.value', '');
166-
if (value) url.searchParams.append(paramName, String(value));
167-
}
168-
});
169-
170-
// Build headers
171-
const headers: Record<string, string> = {};
172-
Object.entries(paramMap).forEach(([key, value]) => {
173-
if (key.startsWith('headers.') && key.endsWith('.value')) {
174-
const headerName = key.replace('headers.', '').replace('.value', '');
175-
if (value) headers[headerName] = String(value);
176-
}
154+
private buildRequestFromParams(processedParams: Array<{key: string, value: any}>, args: Record<string, unknown> = {}) {
155+
// Hardcoded values from the screenshot for testing
156+
const url = "http://localhost:11434/api/generate";
157+
const headers = {
158+
"Content-Type": "application/json",
159+
"Accept": "text/event-stream"
160+
};
161+
const method = "POST";
162+
const body = JSON.stringify({
163+
"model": "gemma3",
164+
"prompt": "Tell me a short story about a robot",
165+
"stream": true
177166
});
178167

179-
// Get method and body
180-
const method = paramMap.get('httpMethod') || 'GET';
181-
const bodyType = paramMap.get('bodyType');
182-
let body: string | FormData | undefined;
168+
console.log("Hardcoded request:", { url, headers, method, body });
183169

184-
if (bodyType === 'application/json' || bodyType === 'text/plain') {
185-
body = paramMap.get('body') as string;
186-
}
187-
188-
return { url: url.toString(), headers, method, body };
170+
return { url, headers, method, body };
189171
}
190172

191173
private async handleEventSource(
@@ -239,7 +221,6 @@ export class SseHttpQuery extends SseHttpTmpQuery {
239221
headers: {
240222
...headers,
241223
'Accept': 'text/event-stream',
242-
'Cache-Control': 'no-cache',
243224
},
244225
body,
245226
signal: this.controller.signal,

0 commit comments

Comments
 (0)