Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797

Danielff040a63f7ee
diff --git a/app/src/assets/scss/business/_agentChat.scss b/app/src/assets/scss/business/_agentChat.scss
index 2d048909dc..92f81fc073 100644
--- a/app/src/assets/scss/business/_agentChat.scss
+++ b/app/src/assets/scss/business/_agentChat.scss
@@ -13,6 +13,9 @@
}
.agent-chat__messages-wrap {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
position: relative;
display: flex;
flex-direction: column;
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.ts
index 4b1cd04700..fe55000a94 100644
--- a/app/src/layout/dock/AgentChat.ts
+++ b/app/src/layout/dock/AgentChat.ts
@@ -119,7 +119,7 @@ export class AgentChat extends Model {
'<svg><use xlink:href="#iconMin"></use></svg>' +
"</span>" +
"</div>" +
- '<div class="agent-chat__messages-wrap fn__flex-1">' +
+ '<div class="agent-chat__messages-wrap">' +
'<div class="agent-chat__messages fn__flex-1"></div>' +
'<span class="agent-chat__scroll-bottom ariaLabel" data-position="west" aria-label="' + L.scrollToBottom + '"><svg><use xlink:href="#iconArrowDown"></use></svg></span>' +
"</div>" +
@@ -1134,7 +1134,8 @@ export class AgentChat extends Model {
private tryGenerateTitle() {
if (this.hasTitled) { return; }
this.hasTitled = true;
- const userMsg = this.entries.find((e) => e.type === "user")?.content?.slice(0, 500) || "";
+ const userEntry = this.entries.find((e): e is { type: "user"; content: string } => e.type === "user");
+ const userMsg = userEntry?.content?.slice(0, 500) || "";
fetch("/api/ai/agent/title", {
method: "POST",
headers: {"Content-Type": "application/json"},
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.go
index 6b2c808797..898dc1c219 100644
--- a/kernel/agent/agent.go
+++ b/kernel/agent/agent.go
@@ -503,8 +503,8 @@ func GenerateTitle(client *openai.Client, model string, userMsg string, language
resp, err := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{
Model: model,
Messages: []openai.ChatCompletionMessage{
- {Role: openai.ChatMessageRoleSystem, Content: "Extract a short title (under 12 words) for the conversation provided by the user. Be specific, not generic. Reply in " + language + "."},
- {Role: openai.ChatMessageRoleUser, Content: userMsg},
+ {Role: openai.ChatMessageRoleSystem, Content: "You are a title generator. Below is the first message of a conversation. Write a concise title (under 12 words) that summarizes the topic. Output ONLY the title, no other text."},
+ {Role: openai.ChatMessageRoleUser, Content: "Conversation starts with: " + userMsg},
},
MaxCompletionTokens: 50,
})