save reasoning_content
This commit is contained in:
@@ -22,6 +22,7 @@ export interface ToolCall {
|
|||||||
export interface Message {
|
export interface Message {
|
||||||
role: "system" | "user" | "assistant" | "tool";
|
role: "system" | "user" | "assistant" | "tool";
|
||||||
content: string | MessageDetail[];
|
content: string | MessageDetail[];
|
||||||
|
reasoning_content?: string | null;
|
||||||
name?: "example_user" | "example_assistant";
|
name?: "example_user" | "example_assistant";
|
||||||
tool_calls?: ToolCall[];
|
tool_calls?: ToolCall[];
|
||||||
tool_call_id?: string;
|
tool_call_id?: string;
|
||||||
@@ -30,6 +31,7 @@ export interface Message {
|
|||||||
interface Delta {
|
interface Delta {
|
||||||
role?: string;
|
role?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
reasoning_content?: string;
|
||||||
tool_calls?: ToolCall[];
|
tool_calls?: ToolCall[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ export function ImageGenDrawer({ disableFactor }: Props) {
|
|||||||
audio: null,
|
audio: null,
|
||||||
logprobs: null,
|
logprobs: null,
|
||||||
response_model_name: imageGenModel,
|
response_model_name: imageGenModel,
|
||||||
|
reasoning_content: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
setChatStore({ ...chatStore });
|
setChatStore({ ...chatStore });
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const AddToolMsg = (props: {
|
|||||||
audio: null,
|
audio: null,
|
||||||
logprobs: null,
|
logprobs: null,
|
||||||
response_model_name: null,
|
response_model_name: null,
|
||||||
|
reasoning_content: null,
|
||||||
});
|
});
|
||||||
setChatStore({ ...chatStore });
|
setChatStore({ ...chatStore });
|
||||||
setNewToolCallID("");
|
setNewToolCallID("");
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ export default function ChatBOX() {
|
|||||||
): Promise<Usage> => {
|
): Promise<Usage> => {
|
||||||
let responseTokenCount = 0;
|
let responseTokenCount = 0;
|
||||||
const allChunkMessage: string[] = [];
|
const allChunkMessage: string[] = [];
|
||||||
|
const allReasoningContentChunk: string[] = [];
|
||||||
const allChunkTool: ToolCall[] = [];
|
const allChunkTool: ToolCall[] = [];
|
||||||
setShowGenerating(true);
|
setShowGenerating(true);
|
||||||
const logprobs: Logprobs = {
|
const logprobs: Logprobs = {
|
||||||
@@ -110,7 +111,13 @@ export default function ChatBOX() {
|
|||||||
console.log(c?.delta?.content, logprob);
|
console.log(c?.delta?.content, logprob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c?.delta?.content) {
|
||||||
allChunkMessage.push(c?.delta?.content ?? "");
|
allChunkMessage.push(c?.delta?.content ?? "");
|
||||||
|
}
|
||||||
|
if (c?.delta?.reasoning_content) {
|
||||||
|
allReasoningContentChunk.push(c?.delta?.reasoning_content ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
const tool_calls = c?.delta?.tool_calls;
|
const tool_calls = c?.delta?.tool_calls;
|
||||||
if (tool_calls) {
|
if (tool_calls) {
|
||||||
for (const tool_call of tool_calls) {
|
for (const tool_call of tool_calls) {
|
||||||
@@ -142,6 +149,11 @@ export default function ChatBOX() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setGeneratingMessage(
|
setGeneratingMessage(
|
||||||
|
(allReasoningContentChunk.length
|
||||||
|
? "----------\nreasoning:\n" +
|
||||||
|
allReasoningContentChunk.join("") +
|
||||||
|
"\n----------\n"
|
||||||
|
: "") +
|
||||||
allChunkMessage.join("") +
|
allChunkMessage.join("") +
|
||||||
allChunkTool.map((tool) => {
|
allChunkTool.map((tool) => {
|
||||||
return `Tool Call ID: ${tool.id}\nType: ${tool.type}\nFunction: ${tool.function.name}\nArguments: ${tool.function.arguments}`;
|
return `Tool Call ID: ${tool.id}\nType: ${tool.type}\nFunction: ${tool.function.name}\nArguments: ${tool.function.arguments}`;
|
||||||
@@ -150,11 +162,13 @@ export default function ChatBOX() {
|
|||||||
}
|
}
|
||||||
setShowGenerating(false);
|
setShowGenerating(false);
|
||||||
const content = allChunkMessage.join("");
|
const content = allChunkMessage.join("");
|
||||||
|
const reasoning_content = allReasoningContentChunk.join("");
|
||||||
|
|
||||||
console.log("save logprobs", logprobs);
|
console.log("save logprobs", logprobs);
|
||||||
const newMsg: ChatStoreMessage = {
|
const newMsg: ChatStoreMessage = {
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content,
|
content,
|
||||||
|
reasoning_content,
|
||||||
hide: false,
|
hide: false,
|
||||||
token: responseTokenCount,
|
token: responseTokenCount,
|
||||||
example: false,
|
example: false,
|
||||||
@@ -211,6 +225,7 @@ export default function ChatBOX() {
|
|||||||
audio: null,
|
audio: null,
|
||||||
logprobs: data.choices[0]?.logprobs,
|
logprobs: data.choices[0]?.logprobs,
|
||||||
response_model_name: data.model,
|
response_model_name: data.model,
|
||||||
|
reasoning_content: data.choices[0]?.message?.reasoning_content ?? null,
|
||||||
});
|
});
|
||||||
setShowGenerating(false);
|
setShowGenerating(false);
|
||||||
|
|
||||||
@@ -375,6 +390,7 @@ export default function ChatBOX() {
|
|||||||
audio: null,
|
audio: null,
|
||||||
logprobs: null,
|
logprobs: null,
|
||||||
response_model_name: null,
|
response_model_name: null,
|
||||||
|
reasoning_content: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
// manually calculate token length
|
// manually calculate token length
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ export interface ChatStoreMessage {
|
|||||||
|
|
||||||
role: "system" | "user" | "assistant" | "tool";
|
role: "system" | "user" | "assistant" | "tool";
|
||||||
content: string | MessageDetail[];
|
content: string | MessageDetail[];
|
||||||
|
reasoning_content: string | null;
|
||||||
name?: "example_user" | "example_assistant";
|
name?: "example_user" | "example_assistant";
|
||||||
tool_calls?: ToolCall[];
|
tool_calls?: ToolCall[];
|
||||||
tool_call_id?: string;
|
tool_call_id?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user