mirror of https://github.com/buster-so/buster.git
message user clarifying
This commit is contained in:
parent
641765b430
commit
cdb7e4f17e
|
@ -1,24 +1,56 @@
|
|||
import { updateMessageEntries } from '@buster/database';
|
||||
import { wrapTraced } from 'braintrust';
|
||||
import { createRawToolResultEntry } from '../../shared/create-raw-llm-tool-result-entry';
|
||||
import type {
|
||||
MessageUserClarifyingQuestionContext,
|
||||
MessageUserClarifyingQuestionInput,
|
||||
MessageUserClarifyingQuestionOutput,
|
||||
MessageUserClarifyingQuestionState,
|
||||
} from './message-user-clarifying-question';
|
||||
import { MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME } from './message-user-clarifying-question';
|
||||
|
||||
// Process message user clarifying question tool execution
|
||||
async function processMessageUserClarifyingQuestion(): Promise<MessageUserClarifyingQuestionOutput> {
|
||||
return {};
|
||||
async function processMessageUserClarifyingQuestion(
|
||||
toolCallId: string,
|
||||
messageId: string
|
||||
): Promise<MessageUserClarifyingQuestionOutput> {
|
||||
const output: MessageUserClarifyingQuestionOutput = {
|
||||
success: true,
|
||||
};
|
||||
|
||||
const rawToolResultEntry = createRawToolResultEntry(
|
||||
toolCallId,
|
||||
MESSAGE_USER_CLARIFYING_QUESTION_TOOL_NAME,
|
||||
output
|
||||
);
|
||||
|
||||
try {
|
||||
await updateMessageEntries({
|
||||
messageId,
|
||||
rawLlmMessages: [rawToolResultEntry],
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[message-user-clarifying-question] Error updating message entries:', error);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Factory function for execute callback
|
||||
export function createMessageUserClarifyingQuestionExecute() {
|
||||
export function createMessageUserClarifyingQuestionExecute(
|
||||
context: MessageUserClarifyingQuestionContext,
|
||||
state: MessageUserClarifyingQuestionState
|
||||
) {
|
||||
// Wrap the execution with tracing
|
||||
const executeMessageUserClarifyingQuestion = wrapTraced(
|
||||
async (
|
||||
_input: MessageUserClarifyingQuestionInput
|
||||
): Promise<MessageUserClarifyingQuestionOutput> => {
|
||||
return processMessageUserClarifyingQuestion();
|
||||
if (!state.toolCallId) {
|
||||
throw new Error('Tool call ID is required');
|
||||
}
|
||||
|
||||
return processMessageUserClarifyingQuestion(state.toolCallId, context.messageId);
|
||||
},
|
||||
{ name: 'Message User Clarifying Question' }
|
||||
);
|
||||
|
|
|
@ -17,7 +17,9 @@ const MessageUserClarifyingQuestionInputSchema = z.object({
|
|||
),
|
||||
});
|
||||
|
||||
const MessageUserClarifyingQuestionOutputSchema = z.object({});
|
||||
const MessageUserClarifyingQuestionOutputSchema = z.object({
|
||||
success: z.boolean().describe('Whether the operation was successful'),
|
||||
});
|
||||
|
||||
const MessageUserClarifyingQuestionContextSchema = z.object({
|
||||
messageId: z.string().describe('The message ID of the message that triggered the tool'),
|
||||
|
@ -59,7 +61,7 @@ export function createMessageUserClarifyingQuestionTool(
|
|||
};
|
||||
|
||||
// Create all functions with the context and state passed
|
||||
const execute = createMessageUserClarifyingQuestionExecute();
|
||||
const execute = createMessageUserClarifyingQuestionExecute(context, state);
|
||||
const onInputStart = createMessageUserClarifyingQuestionStart(context, state);
|
||||
const onInputDelta = createMessageUserClarifyingQuestionDelta(context, state);
|
||||
const onInputAvailable = createMessageUserClarifyingQuestionFinish(context, state);
|
||||
|
|
Loading…
Reference in New Issue