mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
Merge 4c30fcc2e6
into d87922c0eb
This commit is contained in:
commit
2383079b49
1 changed files with 30 additions and 3 deletions
|
@ -285,6 +285,32 @@ export namespace Session {
|
|||
})
|
||||
}
|
||||
|
||||
function hasValidContent(msg: UIMessage): boolean {
|
||||
return (
|
||||
(msg.parts?.length ?? 0) > 0 &&
|
||||
msg.parts.some((part) => {
|
||||
switch (part.type) {
|
||||
case "text":
|
||||
return part.text && part.text.trim().length > 0
|
||||
case "file":
|
||||
return part.data && part.data.length > 0
|
||||
case "tool-invocation":
|
||||
return true
|
||||
case "reasoning":
|
||||
return true
|
||||
case "source":
|
||||
return true
|
||||
case "step-start":
|
||||
// Start Step Part - indicates start of a step (UI metadata only)
|
||||
// See: https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#start-step-part
|
||||
return false
|
||||
default:
|
||||
return false // all known types handled above
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export async function chat(input: {
|
||||
sessionID: string
|
||||
providerID: string
|
||||
|
@ -466,6 +492,9 @@ export namespace Session {
|
|||
system.push(...(await SystemPrompt.environment()))
|
||||
system.push(...(await SystemPrompt.custom()))
|
||||
|
||||
const filteredMessages = msgs.map(toUIMessage).filter(hasValidContent)
|
||||
const coreMessages = convertToCoreMessages(filteredMessages)
|
||||
|
||||
const next: Message.Info = {
|
||||
id: Identifier.ascending("message"),
|
||||
role: "assistant",
|
||||
|
@ -653,9 +682,7 @@ export namespace Session {
|
|||
content: x,
|
||||
}),
|
||||
),
|
||||
...convertToCoreMessages(
|
||||
msgs.map(toUIMessage).filter((x) => x.parts.length > 0),
|
||||
),
|
||||
...coreMessages,
|
||||
],
|
||||
temperature: model.info.temperature ? 0 : undefined,
|
||||
tools: model.info.tool_call === false ? undefined : tools,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue