Spaces:
Sleeping
Sleeping
Update application/static/js/components/initialize.js
Browse files
application/static/js/components/initialize.js
CHANGED
@@ -130,5 +130,25 @@ class Initialize {
|
|
130 |
console.error("fetchModels: Error:", error);
|
131 |
}
|
132 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
export default Initialize
|
|
|
130 |
console.error("fetchModels: Error:", error);
|
131 |
}
|
132 |
}
|
133 |
+
// ADD THIS NEW METHOD
|
134 |
+
async createConv() {
|
135 |
+
console.log("createConv called");
|
136 |
+
try {
|
137 |
+
const response = await requests.request('POST', '/create', { "Content-Type": "application/json" }, JSON.stringify({ "system_prompt": this.systemPrompt }), false);
|
138 |
+
if (!response.ok) {
|
139 |
+
const errorText = await response.text();
|
140 |
+
throw new Error(`Error creating conversation: ${response.status} - ${errorText}`);
|
141 |
+
}
|
142 |
+
const data = await response.json();
|
143 |
+
this.convId = data['convId']; // Set the convId
|
144 |
+
console.log("createConv: New convId:", this.convId);
|
145 |
+
return this.convId; // Return the new convId
|
146 |
+
|
147 |
+
} catch (error) {
|
148 |
+
alert(`An error occurred creating a conversation: ${error}`);
|
149 |
+
console.error(error);
|
150 |
+
return null; // Return null on error
|
151 |
+
}
|
152 |
+
}
|
153 |
}
|
154 |
export default Initialize
|