mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
add support for format
This commit is contained in:
parent
5bf9a80283
commit
0ef9d62565
8 changed files with 83 additions and 19 deletions
|
|
@ -99,6 +99,8 @@ properties:
|
|||
type: string
|
||||
in_path:
|
||||
type: boolean
|
||||
format:
|
||||
type: string
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ pub struct FunctionParameter {
|
|||
pub enum_values: Option<Vec<String>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub default: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub format: Option<String>,
|
||||
}
|
||||
|
||||
impl Serialize for FunctionParameter {
|
||||
|
|
@ -96,6 +98,9 @@ impl Serialize for FunctionParameter {
|
|||
if let Some(default) = &self.default {
|
||||
map.serialize_entry("default", default)?;
|
||||
}
|
||||
if let Some(format) = &self.format {
|
||||
map.serialize_entry("format", format)?;
|
||||
}
|
||||
map.end()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ pub struct Parameter {
|
|||
pub enum_values: Option<Vec<String>>,
|
||||
pub default: Option<String>,
|
||||
pub in_path: Option<bool>,
|
||||
pub format: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Default)]
|
||||
|
|
@ -250,6 +251,7 @@ impl From<&PromptTarget> for ChatCompletionTool {
|
|||
required: entity.required,
|
||||
enum_values: entity.enum_values.clone(),
|
||||
default: entity.default.clone(),
|
||||
format: entity.format.clone(),
|
||||
};
|
||||
properties.insert(entity.name.clone(), param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ prompt_targets:
|
|||
description: The location to get the weather for
|
||||
required: true
|
||||
type: string
|
||||
format: city, state
|
||||
- name: days
|
||||
description: the number of days for the request
|
||||
required: true
|
||||
|
|
|
|||
|
|
@ -28,12 +28,6 @@ Content-Type: application/json
|
|||
"description": "The location to get the weather for",
|
||||
"format": "City, State"
|
||||
},
|
||||
"unit": {
|
||||
"type": "str",
|
||||
"description": "The unit to return the weather in.",
|
||||
"enum": ["celsius", "fahrenheit"],
|
||||
"default": "celsius"
|
||||
},
|
||||
"days": {
|
||||
"type": "str",
|
||||
"description": "the number of days for the request."
|
||||
|
|
@ -236,7 +230,6 @@ Content-Type: application/json
|
|||
}
|
||||
|
||||
|
||||
|
||||
### archgw to model_server 2
|
||||
POST {{model_server_endpoint}}/function_calling HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
|
@ -292,3 +285,66 @@ Content-Type: application/json
|
|||
],
|
||||
"stream": false
|
||||
}
|
||||
|
||||
|
||||
### archgw to model_server 3
|
||||
POST {{model_server_endpoint}}/function_calling HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"model": "--",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "how is the weather in seattle"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Of course, I can help with that. Could you please specify the days you want the weather forecast for?",
|
||||
"model": "Arch-Function"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "for 2 days please"
|
||||
}
|
||||
],
|
||||
"tools": [
|
||||
{
|
||||
"id": "weather-112",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_current_weather",
|
||||
"description": "Get current weather at a location.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "str",
|
||||
"description": "The location to get the weather for",
|
||||
"format": "City, State"
|
||||
},
|
||||
"days": {
|
||||
"type": "str",
|
||||
"description": "the number of days for the request"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"days", "location"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "default_target",
|
||||
"description": "This is the default target for all unmatched prompts.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"stream": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,15 +73,6 @@ Content-Type: application/json
|
|||
{
|
||||
"role": "user",
|
||||
"content": "for next 10 days"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Could you tell me what units you want the weather in? (For example: Celsius or Fahrenheit)",
|
||||
"model": "Arch-Function-1.5b"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Fahrenheit"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ def test_prompt_gateway_param_gathering(stream):
|
|||
def test_prompt_gateway_param_tool_call(stream):
|
||||
expected_tool_call = {
|
||||
"name": "get_current_weather",
|
||||
"arguments": {"location": "seattle", "days": "2"},
|
||||
"arguments": {"location": "seattle, wa", "days": "2"},
|
||||
}
|
||||
|
||||
body = {
|
||||
|
|
@ -181,11 +181,11 @@ def test_prompt_gateway_param_tool_call(stream):
|
|||
{
|
||||
"role": "assistant",
|
||||
"content": "Of course, I can help with that. Could you please specify the days you want the weather forecast for?",
|
||||
"model": "Arch-Function-1.5B",
|
||||
"model": "Arch-Function",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "2 days",
|
||||
"content": "for 2 days please",
|
||||
},
|
||||
],
|
||||
"stream": stream,
|
||||
|
|
|
|||
|
|
@ -42,3 +42,10 @@ archgw_modelserver = "src.cli:run_server"
|
|||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
python_files = ["test*.py"]
|
||||
addopts = ["-v", "-s"]
|
||||
retries = 2
|
||||
retry_delay = 0.5
|
||||
cumulative_timing = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue