diff --git a/apps/application/migrations/0009_alter_chatrecord_dataset_alter_chatrecord_paragraph.py b/apps/application/migrations/0009_alter_chatrecord_dataset_alter_chatrecord_paragraph.py
new file mode 100644
index 000000000..3b5829d07
--- /dev/null
+++ b/apps/application/migrations/0009_alter_chatrecord_dataset_alter_chatrecord_paragraph.py
@@ -0,0 +1,25 @@
+# Generated by Django 4.1.10 on 2023-12-11 10:12
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('dataset', '0001_initial'),
+ ('application', '0008_remove_application_api_key_is_active_and_more'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='chatrecord',
+ name='dataset',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.dataset', verbose_name='数据集'),
+ ),
+ migrations.AlterField(
+ model_name='chatrecord',
+ name='paragraph',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.paragraph', verbose_name='段落id'),
+ ),
+ ]
diff --git a/apps/application/models/application.py b/apps/application/models/application.py
index a81b3d70e..1cba2ce3d 100644
--- a/apps/application/models/application.py
+++ b/apps/application/models/application.py
@@ -65,8 +65,8 @@ class ChatRecord(AppModelMixin):
chat = models.ForeignKey(Chat, on_delete=models.CASCADE)
vote_status = models.CharField(verbose_name='投票', max_length=10, choices=VoteChoices.choices,
default=VoteChoices.UN_VOTE)
- dataset = models.ForeignKey(DataSet, on_delete=models.DO_NOTHING, verbose_name="数据集", blank=True, null=True)
- paragraph = models.ForeignKey(Paragraph, on_delete=models.DO_NOTHING, verbose_name="段落id", blank=True, null=True)
+ dataset = models.ForeignKey(DataSet, on_delete=models.SET_NULL, verbose_name="数据集", blank=True, null=True)
+ paragraph = models.ForeignKey(Paragraph, on_delete=models.SET_NULL, verbose_name="段落id", blank=True, null=True)
source_id = models.UUIDField(max_length=128, verbose_name="资源id 段落/问题 id ", null=True)
source_type = models.CharField(verbose_name='资源类型', max_length=2, choices=SourceType.choices,
default=SourceType.PROBLEM, blank=True, null=True)
diff --git a/apps/application/serializers/application_serializers.py b/apps/application/serializers/application_serializers.py
index 7bff525a2..b9d6de653 100644
--- a/apps/application/serializers/application_serializers.py
+++ b/apps/application/serializers/application_serializers.py
@@ -235,7 +235,7 @@ class ApplicationSerializer(serializers.Serializer):
class ApplicationModel(serializers.ModelSerializer):
class Meta:
model = Application
- fields = ['id', 'name', 'desc', 'prologue', 'example', 'dialogue_number', 'status']
+ fields = ['id', 'name', 'desc', 'prologue', 'example', 'dialogue_number']
class Operate(serializers.Serializer):
application_id = serializers.UUIDField(required=True)
diff --git a/ui/public/embeb.js b/ui/public/embeb.js
index f8c3ea147..31a9be181 100644
--- a/ui/public/embeb.js
+++ b/ui/public/embeb.js
@@ -1,66 +1,88 @@
-// async function embedChatbot() {
-// const t = window.difyChatbotConfig
-// if (t && t.token) {
-// var e = !!t.isDev
-// const o = t.baseUrl || `https://${e ? 'dev.' : ''}udify.app`,
-// n = ``,
-// i = ``
-// if (!document.getElementById('dify-chatbot-bubble-button')) {
-// e = document.createElement('div')
-// ;(e.id = 'dify-chatbot-bubble-button'),
-// (e.style.cssText =
-// 'position: fixed; bottom: 1rem; right: 1rem; width: 50px; height: 50px; border-radius: 25px; background-color: #155EEF; box-shadow: rgba(0, 0, 0, 0.2) 0px 4px 8px 0px; cursor: pointer; z-index: 2147483647; transition: all 0.2s ease-in-out 0s; left: unset; transform: scale(1); :hover {transform: scale(1.1);}')
-// const d = document.createElement('div')
-// ;(d.style.cssText =
-// 'display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; z-index: 2147483647;'),
-// (d.innerHTML = n),
-// e.appendChild(d),
-// document.body.appendChild(e),
-// e.addEventListener('click', function () {
-// var e = document.getElementById('dify-chatbot-bubble-window')
-// e
-// ? 'none' === e.style.display
-// ? ((e.style.display = 'block'), (d.innerHTML = i))
-// : ((e.style.display = 'none'), (d.innerHTML = n))
-// : (((e = document.createElement('iframe')).allow = 'fullscreen;microphone'),
-// (e.title = 'dify chatbot bubble window'),
-// (e.id = 'dify-chatbot-bubble-window'),
-// (e.src = o + '/chatbot/' + t.token),
-// (e.style.cssText =
-// 'border: none; position: fixed; flex-direction: column; justify-content: space-between; box-shadow: rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px; bottom: 5rem; right: 1rem; width: 24rem; max-width: calc(100vw - 2rem); height: 40rem; max-height: calc(100vh - 6rem);border-radius: 0.75rem; display: flex; z-index: 2147483647; overflow: hidden; left: unset; background-color: #F3F4F6;'),
-// document.body.appendChild(e),
-// (d.innerHTML = i))
-// })
-// }
-// } else console.error('difyChatbotConfig is empty or token is not provided')
-// }
-// document.body.onload = embedChatbot
+ function embedChatbot() {
+ const t = window.maxkbChatConfig
+ if (t && t.token) {
+ icon = ``;
+ chat_button = document.createElement("div");
+ chat_button.style =
+ "position: absolute;bottom: 40px;right: 20px;cursor: pointer;";
+ chat_button.innerHTML = icon;
+
+ chat_container = document.createElement("div");
+ chat_container.id = "chat_container";
+ chat_container.style.cssText = `position: relative;
+ width: 420px;
+ height: 600px;
+ border: none;
+ border-radius: 7px 7px 7px 7px;
+ position: absolute;bottom: 40px;right: 20px`;
+ chat_container.style["display"] = "none";
+
+ chat = document.createElement("iframe");
+ chat.src = `http://${window.maxkbChatConfig.host}/ui/chat/${window.maxkbChatConfig.token}`;
+ chat.id = "chat";
+ chat_container.append(chat);
+ chat.style.cssText = `border: none;height:100%;width:100%`;
+
+ close_button = document.createElement("div");
+
+ close_button.innerHTML = ``;
+ close_button.style.cssText = `position: absolute;
+ top: 10px;
+ right: 10px;
+ cursor: pointer;
+ `;
+ close_button.onclick = () => {
+ chat_container.style["display"] = "none";
+ chat_button.style["display"] = "block";
+ };
+
+ chat_container.append(close_button);
+ document.body.append(chat_container);
+
+ chat_button.onclick = ($event) => {
+ chat_container.style["display"] = "block";
+ chat_button.style["display"] = "none";
+ };
+ sty=document.createElement("style")
+ sty.innerText=` #chat_container {
+ animation: appear .4s ease-in-out;
+ }
+ @keyframes appear {
+ from {
+ height: 0;;
+ }
+
+ to {
+ height: 600px;
+ }
+ }`
+ document.head.append(sty)
+ document.body.append(chat_button);
+ } else console.error('difyChatbotConfig is empty or token is not provided')
+ }
+ document.body.onload = embedChatbot
diff --git a/ui/src/views/chat/index.vue b/ui/src/views/chat/index.vue
index cd9c49888..91b1b4265 100644
--- a/ui/src/views/chat/index.vue
+++ b/ui/src/views/chat/index.vue
@@ -79,7 +79,7 @@ onMounted(() => {
}
}
.chat-width {
- width: 860px;
+ max-width: var(--app-chat-width, 860px);
margin: 0 auto;
}
}