use std::time::Duration;
use super::*;
mod args;
mod blocking;
mod judge;
mod recover;
pub(super) use args::ARG_KEY;
pub use blocking::parse_glm47_answer;
pub(super) use blocking::{TOOL_CALL, TOOL_CALL_END};
pub(super) use judge::split_body;
pub use judge::{REFUSAL_KEY, Verdict, judge, resolve_name};
pub const KEEPALIVE: Duration = Duration::from_secs(5);
impl Verdict {
pub fn into_tool_call(self) -> ToolCall {
let (name, arguments) = match self {
Verdict::Accept { name, arguments }
| Verdict::Refuse {
name, arguments, ..
} => (name, arguments),
};
ToolCall {
id: next_tool_call_id(),
call_type: "function".into(),
function: FunctionCall { name, arguments },
}
}
}
pub struct Glm47Parser;
impl ToolCallParser for Glm47Parser {
fn name(&self) -> &str {
"glm47"
}
fn system_prompt(
&self,
tools: &[ToolDefinition],
tool_choice: &ToolChoice,
levers: &PromptLevers,
) -> String {
PoolsideV1Parser.system_prompt(tools, tool_choice, levers)
}
fn format_tool_calls(&self, calls: &[IncomingToolCall]) -> String {
PoolsideV1Parser.format_tool_calls(calls)
}
fn leak_markers(&self) -> LeakMarkers {
PoolsideV1Parser.leak_markers()
}
fn compile_tool_grammar(
&self,
engine: &mut GrammarEngine,
tools: &[ToolDefinition],
use_triggers: bool,
) -> Option<Result<CompiledGrammar, GrammarError>> {
PoolsideV1Parser.compile_tool_grammar(engine, tools, use_triggers)
}
fn has_tool_grammar(&self) -> bool {
PoolsideV1Parser.has_tool_grammar()
}
fn param_value_close_delim(&self) -> Option<&'static str> {
PoolsideV1Parser.param_value_close_delim()
}
fn promotes_bare_call_names(&self) -> bool {
PoolsideV1Parser.promotes_bare_call_names()
}
fn call_policy(&self) -> CallPolicy {
CallPolicy::FailClosed {
keepalive: KEEPALIVE,
}
}
}