Restore working Client connection and positional predict arrays in app.js
Browse files- static/app.js +9 -9
static/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import {
|
| 2 |
|
| 3 |
// Global Application State Management
|
| 4 |
const STATE = {
|
|
@@ -69,7 +69,7 @@ marked.setOptions({
|
|
| 69 |
// Setup Initial State & Event Handlers
|
| 70 |
async function initializeApp() {
|
| 71 |
// 1. Connect Gradio Client in background (Non-blocking)
|
| 72 |
-
|
| 73 |
.then(app => {
|
| 74 |
STATE.gradioClient = app;
|
| 75 |
console.log("Successfully connected to Gradio.Server backend.");
|
|
@@ -412,13 +412,13 @@ async function triggerPromptSubmission(inputElement) {
|
|
| 412 |
const responseId = appendAssistantPlaceholderBubble();
|
| 413 |
const startTime = Date.now();
|
| 414 |
|
| 415 |
-
// Call our gradio.Server api endpoint using
|
| 416 |
-
const result = await STATE.gradioClient.predict("/chat_with_step",
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
|
| 423 |
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
| 424 |
const rawData = Array.isArray(result.data) ? result.data[0] : result.data;
|
|
|
|
| 1 |
+
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
|
| 2 |
|
| 3 |
// Global Application State Management
|
| 4 |
const STATE = {
|
|
|
|
| 69 |
// Setup Initial State & Event Handlers
|
| 70 |
async function initializeApp() {
|
| 71 |
// 1. Connect Gradio Client in background (Non-blocking)
|
| 72 |
+
Client.connect(window.location.origin)
|
| 73 |
.then(app => {
|
| 74 |
STATE.gradioClient = app;
|
| 75 |
console.log("Successfully connected to Gradio.Server backend.");
|
|
|
|
| 412 |
const responseId = appendAssistantPlaceholderBubble();
|
| 413 |
const startTime = Date.now();
|
| 414 |
|
| 415 |
+
// Call our gradio.Server api endpoint using standard positional array arguments
|
| 416 |
+
const result = await STATE.gradioClient.predict("/chat_with_step", [
|
| 417 |
+
JSON.stringify(STATE.conversationHistory),
|
| 418 |
+
STATE.reasoningEffort,
|
| 419 |
+
STATE.maxTokens,
|
| 420 |
+
STATE.temperature
|
| 421 |
+
]);
|
| 422 |
|
| 423 |
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
| 424 |
const rawData = Array.isArray(result.data) ? result.data[0] : result.data;
|