mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-12 04:44:52 +00:00
fix: adjust default tool choice
This commit is contained in:
parent
da82c63a4f
commit
35f8a88db5
@ -336,8 +336,14 @@ impl ToolGrammar {
|
|||||||
tools: Option<Vec<Tool>>,
|
tools: Option<Vec<Tool>>,
|
||||||
tool_choice: Option<ToolType>,
|
tool_choice: Option<ToolType>,
|
||||||
) -> Result<Option<Tools>, InferError> {
|
) -> Result<Option<Tools>, InferError> {
|
||||||
if let Some((req_tools, tool_choice)) = tools.zip(tool_choice) {
|
if let Some(req_tools) = tools {
|
||||||
// let tool_prompt = tool_prompt.unwrap_or_default();
|
let tool_choice = tool_choice
|
||||||
|
.map(|t| match t {
|
||||||
|
ToolType::FunctionName(name) if name == "auto" => ToolType::OneOf,
|
||||||
|
_ => t,
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
let tools_to_use = match tool_choice {
|
let tools_to_use = match tool_choice {
|
||||||
ToolType::FunctionName(name) => {
|
ToolType::FunctionName(name) => {
|
||||||
vec![req_tools
|
vec![req_tools
|
||||||
|
@ -840,12 +840,16 @@ fn default_tool_prompt() -> Option<String> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, ToSchema)]
|
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize, ToSchema)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ToolType {
|
pub enum ToolType {
|
||||||
|
#[default]
|
||||||
|
#[serde(alias = "auto")]
|
||||||
OneOf,
|
OneOf,
|
||||||
FunctionName(String),
|
FunctionName(String),
|
||||||
Function { function: FunctionName },
|
Function {
|
||||||
|
function: FunctionName,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ToSchema)]
|
||||||
|
Loading…
Reference in New Issue
Block a user