Compare commits
2 Commits
437f49fb20
...
50133684c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
50133684c7
|
|||
|
befde25266
|
@@ -21,6 +21,7 @@ public class ThoughtController(ThoughtProvider provider, ThoughtService service)
|
||||
{
|
||||
[Required] public string UserMessage { get; set; } = null!;
|
||||
public Guid? SequenceId { get; set; }
|
||||
public List<string> AcceptProposals { get; set; } = [];
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -69,6 +70,18 @@ public class ThoughtController(ThoughtProvider provider, ThoughtService service)
|
||||
"When the user asks questions about the Solar Network (also known as SN and Solian), try use the tools you have to get latest and accurate data."
|
||||
);
|
||||
|
||||
chatHistory.AddSystemMessage(
|
||||
"You can issue some proposals to user, like creating a post. The proposal syntax is like a xml tag, with an attribute indicates which proposal.\n" +
|
||||
"Depends on the proposal type, the payload (content inside the xml tag) might be different.\n" +
|
||||
"\n" +
|
||||
"Example: <proposal type=\"post_create\">...post content...</proposal>\n" +
|
||||
"\n" +
|
||||
"Here are some references of the proposals you can issue, but if you want to issue one, make sure the user is accept it.\n" +
|
||||
"1. post_create: body takes simple string, create post for user." +
|
||||
"\n" +
|
||||
$"The user currently accept these proposals: {string.Join(',', request.AcceptProposals)}"
|
||||
);
|
||||
|
||||
chatHistory.AddSystemMessage(
|
||||
$"The user you're currently talking to is {currentUser.Nick} ({currentUser.Name}), ID is {currentUser.Id}"
|
||||
);
|
||||
@@ -119,19 +132,23 @@ public class ThoughtController(ThoughtProvider provider, ThoughtService service)
|
||||
{ Type = StreamingContentType.Text, Data = new() { ["text"] = textContent.Text ?? "" } },
|
||||
StreamingReasoningContent reasoningContent => new SnThinkingChunk
|
||||
{
|
||||
Type = StreamingContentType.Reasoning, Data = new() { ["text"] = reasoningContent.Text ?? "" }
|
||||
},
|
||||
StreamingFunctionCallUpdateContent functionCall => new SnThinkingChunk
|
||||
{
|
||||
Type = StreamingContentType.FunctionCall,
|
||||
Data = JsonSerializer.Deserialize<Dictionary<string, object>>(
|
||||
JsonSerializer.Serialize(functionCall)) ?? new()
|
||||
Type = StreamingContentType.Reasoning, Data = new() { ["text"] = reasoningContent.Text }
|
||||
},
|
||||
StreamingFunctionCallUpdateContent functionCall => string.IsNullOrEmpty(functionCall.CallId)
|
||||
? null
|
||||
: new SnThinkingChunk
|
||||
{
|
||||
Type = StreamingContentType.FunctionCall,
|
||||
Data = JsonSerializer.Deserialize<Dictionary<string, object>>(
|
||||
JsonSerializer.Serialize(functionCall)) ?? new Dictionary<string, object>()
|
||||
},
|
||||
_ => new SnThinkingChunk
|
||||
{
|
||||
Type = StreamingContentType.Unknown, Data = new() { ["data"] = JsonSerializer.Serialize(item) }
|
||||
}
|
||||
};
|
||||
if (streamingChunk == null) continue;
|
||||
|
||||
thinkingChunks.Add(streamingChunk);
|
||||
|
||||
var messageJson = item switch
|
||||
@@ -139,7 +156,7 @@ public class ThoughtController(ThoughtProvider provider, ThoughtService service)
|
||||
StreamingTextContent textContent =>
|
||||
JsonSerializer.Serialize(new { type = "text", data = textContent.Text ?? "" }),
|
||||
StreamingReasoningContent reasoningContent =>
|
||||
JsonSerializer.Serialize(new { type = "reasoning", data = reasoningContent.Text ?? "" }),
|
||||
JsonSerializer.Serialize(new { type = "reasoning", data = reasoningContent.Text }),
|
||||
StreamingFunctionCallUpdateContent functionCall =>
|
||||
JsonSerializer.Serialize(new { type = "function_call", data = functionCall }),
|
||||
_ =>
|
||||
|
||||
Reference in New Issue
Block a user