mirror of https://github.com/buster-so/buster.git
Refactor sequential thinking tool to remove raw LLM message entries
- Removed the creation and handling of raw LLM message entries in both start and finish functions. - Updated message entry updates to only include reasoning messages, simplifying the logic and improving clarity.
This commit is contained in:
parent
50c9575d6f
commit
dcf1687b50
|
@ -1,10 +1,7 @@
|
||||||
import { updateMessageEntries } from '@buster/database';
|
import { updateMessageEntries } from '@buster/database';
|
||||||
import type { ToolCallOptions } from 'ai';
|
import type { ToolCallOptions } from 'ai';
|
||||||
import { normalizeEscapedText } from '../../../utils/streaming/escape-normalizer';
|
import { normalizeEscapedText } from '../../../utils/streaming/escape-normalizer';
|
||||||
import {
|
import { createSequentialThinkingReasoningMessage } from './helpers/sequential-thinking-tool-transform-helper';
|
||||||
createSequentialThinkingRawLlmMessageEntry,
|
|
||||||
createSequentialThinkingReasoningMessage,
|
|
||||||
} from './helpers/sequential-thinking-tool-transform-helper';
|
|
||||||
import type {
|
import type {
|
||||||
SequentialThinkingContext,
|
SequentialThinkingContext,
|
||||||
SequentialThinkingInput,
|
SequentialThinkingInput,
|
||||||
|
@ -31,22 +28,14 @@ export function createSequentialThinkingFinish(
|
||||||
'completed' // Mark as completed when finish is called
|
'completed' // Mark as completed when finish is called
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create final raw LLM message entry
|
|
||||||
const rawLlmMessage = createSequentialThinkingRawLlmMessageEntry(
|
|
||||||
sequentialThinkingState,
|
|
||||||
options.toolCallId
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (context.messageId) {
|
if (context.messageId) {
|
||||||
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
|
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
|
||||||
const rawLlmMessages = rawLlmMessage ? [rawLlmMessage] : [];
|
|
||||||
|
|
||||||
if (reasoningMessages.length > 0 || rawLlmMessages.length > 0) {
|
if (reasoningMessages.length > 0) {
|
||||||
await updateMessageEntries({
|
await updateMessageEntries({
|
||||||
messageId: context.messageId,
|
messageId: context.messageId,
|
||||||
reasoningMessages,
|
reasoningMessages,
|
||||||
rawLlmMessages,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.info('[sequential-thinking] Completed sequential thinking:', {
|
console.info('[sequential-thinking] Completed sequential thinking:', {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { updateMessageEntries } from '@buster/database';
|
import { updateMessageEntries } from '@buster/database';
|
||||||
import type { ToolCallOptions } from 'ai';
|
import type { ToolCallOptions } from 'ai';
|
||||||
import {
|
import { createSequentialThinkingReasoningMessage } from './helpers/sequential-thinking-tool-transform-helper';
|
||||||
createSequentialThinkingRawLlmMessageEntry,
|
|
||||||
createSequentialThinkingReasoningMessage,
|
|
||||||
} from './helpers/sequential-thinking-tool-transform-helper';
|
|
||||||
import type {
|
import type {
|
||||||
SequentialThinkingContext,
|
SequentialThinkingContext,
|
||||||
SequentialThinkingState,
|
SequentialThinkingState,
|
||||||
|
@ -29,22 +26,14 @@ export function createSequentialThinkingStart(
|
||||||
options.toolCallId
|
options.toolCallId
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create initial raw LLM message entry
|
|
||||||
const rawLlmMessage = createSequentialThinkingRawLlmMessageEntry(
|
|
||||||
sequentialThinkingState,
|
|
||||||
options.toolCallId
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (context.messageId) {
|
if (context.messageId) {
|
||||||
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
|
const reasoningMessages = reasoningEntry ? [reasoningEntry] : [];
|
||||||
const rawLlmMessages = rawLlmMessage ? [rawLlmMessage] : [];
|
|
||||||
|
|
||||||
if (reasoningMessages.length > 0 || rawLlmMessages.length > 0) {
|
if (reasoningMessages.length > 0) {
|
||||||
await updateMessageEntries({
|
await updateMessageEntries({
|
||||||
messageId: context.messageId,
|
messageId: context.messageId,
|
||||||
reasoningMessages,
|
reasoningMessages,
|
||||||
rawLlmMessages,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.info('[sequential-thinking] Started sequential thinking:', {
|
console.info('[sequential-thinking] Started sequential thinking:', {
|
||||||
|
|
Loading…
Reference in New Issue