search through conversation history
- instead of using toolcallstates
This commit is contained in:
parent
c000943d3b
commit
e08aa8533a
1 changed files with 6 additions and 7 deletions
|
|
@ -55,15 +55,14 @@ export async function compactConversation({
|
|||
messages.push(item.message);
|
||||
// toolcalls only exist in an assistant message
|
||||
if (item.message.role === "assistant" && item.message.toolCalls) {
|
||||
// for every toolcall, if there is no toolcallstate or its output, add a chat message saying that it is empty
|
||||
// for every toolcall, if there is no tool message with a tool call id already, add a chat message saying that it is empty
|
||||
item.message.toolCalls.forEach((toolCall) => {
|
||||
const foundToolCallState = item.toolCallStates?.find(
|
||||
(toolCallState) => toolCallState.toolCallId === toolCall.id,
|
||||
);
|
||||
if (
|
||||
!foundToolCallState ||
|
||||
!foundToolCallState.output ||
|
||||
!foundToolCallState.output.length
|
||||
!filteredHistory.find(
|
||||
(item) =>
|
||||
item.message.role === "tool" &&
|
||||
item.message.toolCallId === toolCall.id,
|
||||
)
|
||||
) {
|
||||
messages.push({
|
||||
role: "tool",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue