mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-08-15 04:33:06 -04:00
gpt-oss: implement harmony parsing (#15181)
* model : add harmony parser for gpt-oss * gpt-oss : fix grammar trigger from causing empty stack * gpt-oss: tweak the grammar trigger again * gpt-oss : add support for recipient in role header * gpt-oss : fix ungrouped tool calls in grammar * gpt-oss : loosen function name matching during parse * gpt-oss : clean up workarounds * gpt-oss : add template tests * gpt-oss : simulate thinking and tool call tags * gpt-oss : undo think tags when reasoning_format is none * gpt-oss : set special tokens back to user defined * gpt-oss : update openai-gpt-oss template * server : filter out harmony thought messages * gpt-oss : simplify parsing
This commit is contained in:
Binary file not shown.
@@ -62,8 +62,7 @@ export default function ChatMessage({
|
||||
return { content: msg.content };
|
||||
}
|
||||
const REGEX_THINK_OPEN = /<think>|<\|channel\|>analysis<\|message\|>/;
|
||||
const REGEX_THINK_CLOSE =
|
||||
/<\/think>|<\|start\|>assistant<\|channel\|>final<\|message\|>/;
|
||||
const REGEX_THINK_CLOSE = /<\/think>|<\|end\|>/;
|
||||
let actualContent = '';
|
||||
let thought = '';
|
||||
let isThinking = false;
|
||||
|
@@ -131,9 +131,7 @@ export function filterThoughtFromMsgs(messages: APIMessage[]) {
|
||||
content:
|
||||
msg.role === 'assistant'
|
||||
? contentStr
|
||||
.split(
|
||||
/<\/think>|<\|start\|>assistant<\|channel\|>final<\|message\|>/
|
||||
)
|
||||
.split(/<\/think>|<\|end\|>/)
|
||||
.at(-1)!
|
||||
.trim()
|
||||
: contentStr,
|
||||
|
Reference in New Issue
Block a user