mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
Working json and ui
This commit is contained in:
parent
be6ef2a2bc
commit
8691eb5dbd
@ -951,11 +951,12 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
|
||||
def update_message_metadata(self, client_id, metadata):
|
||||
client = self.session.get_client(client_id)
|
||||
md = json.dumps(metadata) if type(metadata)==dict or type(metadata)==list else metadata
|
||||
run_async(
|
||||
partial(self.sio.emit,'update_message', {
|
||||
"sender": self.personality.name,
|
||||
'id':client.discussion.current_message.id,
|
||||
'metadata': metadata if type(metadata) in [str, None] else json.dumps(metadata) if type(metadata)==dict else None,
|
||||
'metadata': md,
|
||||
'discussion_id':client.discussion.discussion_id,
|
||||
'operation_type': MSG_OPERATION_TYPE.MSG_OPERATION_TYPE_JSON_INFOS.value,
|
||||
}, to=client_id
|
||||
@ -966,6 +967,8 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
|
||||
def update_message_ui(self, client_id, ui):
|
||||
client = self.session.get_client(client_id)
|
||||
|
||||
|
||||
run_async(
|
||||
partial(self.sio.emit,'update_message', {
|
||||
"sender": self.personality.name,
|
||||
@ -977,6 +980,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
client.discussion.update_message_ui(ui)
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
web/dist/index.html
vendored
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-56d1192c.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-b96696ba.css">
|
||||
<script type="module" crossorigin src="/assets/index-12b90ca6.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-f1d31414.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -91,12 +91,10 @@
|
||||
</div>
|
||||
<div v-if="message.metadata !== null">
|
||||
<div v-for="(metadata, index) in (message.metadata?.filter(metadata => metadata!=null && metadata.hasOwnProperty('title') && metadata.hasOwnProperty('content')) || [])" :key="'json-' + message.id + '-' + index" class="json font-bold">
|
||||
<JsonViewer :jsonFormText="metadata.title" :jsonData="metadata.content" />
|
||||
<JsonViewer :jsonFormText="metadata.title" :jsonData="metadata.content" :key="'msgjson-' + message.id" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="message.ui != null">
|
||||
<DynamicUIRenderer ref="ui" class="w-full" :ui="message.ui"></DynamicUIRenderer>
|
||||
</div>
|
||||
<DynamicUIRenderer ref="ui" class="w-full" :ui="message.ui" :key="'msgui-' + message.id" />
|
||||
|
||||
<audio controls v-if="audio_url!=null" :key="audio_url">
|
||||
<source :src="audio_url" type="audio/wav" ref="audio_player" >
|
||||
|
@ -1002,7 +1002,7 @@ export default {
|
||||
)
|
||||
this.discussionArr.forEach((item) => {
|
||||
item.status_message = "Done";
|
||||
});
|
||||
});
|
||||
|
||||
console.log("this.discussionArr")
|
||||
console.log(this.discussionArr)
|
||||
@ -1654,14 +1654,15 @@ export default {
|
||||
this.setDiscussionLoading(this.discussion_id, true);
|
||||
|
||||
if (this.currentDiscussion.id == this.discussion_id) {
|
||||
console.log("discussion ok")
|
||||
//this.isGenerating = true;
|
||||
const index = this.discussionArr.findIndex((x) => x.id == msgObj.id)
|
||||
const messageItem = this.discussionArr[index]
|
||||
|
||||
if (
|
||||
messageItem && (msgObj.operation_type==this.operationTypes.MSG_OPERATION_TYPE_SET_CONTENT ||
|
||||
msgObj.operation_type==this.operationTypes.MSG_OPERATION_TYPE_SET_CONTENT_INVISIBLE_TO_AI)
|
||||
) {
|
||||
console.log("Content triggered")
|
||||
this.isGenerating = true;
|
||||
messageItem.content = msgObj.content
|
||||
messageItem.created_at = msgObj.created_at
|
||||
@ -1673,6 +1674,7 @@ export default {
|
||||
else if(messageItem && msgObj.operation_type==this.operationTypes.MSG_OPERATION_TYPE_ADD_CHUNK){
|
||||
this.isGenerating = true;
|
||||
messageItem.content += msgObj.content
|
||||
console.log("Chunk triggered")
|
||||
//console.log("content")
|
||||
//console.log(messageItem.content)
|
||||
messageItem.created_at = msgObj.created_at
|
||||
@ -1690,12 +1692,26 @@ export default {
|
||||
console.error("Invalid steps data:", msgObj.steps);
|
||||
}
|
||||
|
||||
} else if (msgObj.message_type == this.operationTypes.MSG_TYPE_JSON_INFOS) {
|
||||
messageItem.metadata = msgObj.metadata
|
||||
} else if (msgObj.message_type == this.operationTypes.MSG_OPERATION_TYPE_UI) {
|
||||
} else if (msgObj.operation_type == this.operationTypes.MSG_OPERATION_TYPE_JSON_INFOS) {
|
||||
console.log("metadata triggered", msgObj.operation_type)
|
||||
console.log("metadata", msgObj.metadata)
|
||||
if (typeof msgObj.metadata === 'string') {
|
||||
try {
|
||||
messageItem.metadata = JSON.parse(msgObj.metadata);
|
||||
} catch (error) {
|
||||
console.error("Error parsing metadata string:", error);
|
||||
messageItem.metadata = { raw: msgObj.metadata }; // Fallback: store as raw string in an object
|
||||
}
|
||||
} else if (Array.isArray(msgObj.metadata) || typeof msgObj.metadata === 'object') {
|
||||
messageItem.metadata = msgObj.metadata; // Already an array or object, assign directly
|
||||
} else {
|
||||
messageItem.metadata = { value: msgObj.metadata }; // For any other type, wrap in an object
|
||||
}
|
||||
} else if (msgObj.operation_type == this.operationTypes.MSG_OPERATION_TYPE_UI) {
|
||||
console.log("UI triggered",msgObj.operation_type)
|
||||
console.log("UI", msgObj.ui)
|
||||
messageItem.ui = msgObj.ui
|
||||
} else if (msgObj.message_type == this.operationTypes.MSG_OPERATION_TYPE_EXCEPTION) {
|
||||
} else if (msgObj.operation_type == this.operationTypes.MSG_OPERATION_TYPE_EXCEPTION) {
|
||||
this.$store.state.toast.showToast(msgObj.content, 5, false)
|
||||
}
|
||||
// // Disables as per request
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3888e216475c2946a8a7dd0367eea420acb7efd7
|
||||
Subproject commit 9e2a5cb5404a957bb211b87bee666a11588e611f
|
Loading…
Reference in New Issue
Block a user