diff --git a/arch/arch_config_schema.yaml b/arch/arch_config_schema.yaml index 6daa29e8..0fe980dd 100644 --- a/arch/arch_config_schema.yaml +++ b/arch/arch_config_schema.yaml @@ -99,6 +99,8 @@ properties: type: string in_path: type: boolean + format: + type: string additionalProperties: false required: - name diff --git a/crates/common/src/api/open_ai.rs b/crates/common/src/api/open_ai.rs index b72185e0..7b42b139 100644 --- a/crates/common/src/api/open_ai.rs +++ b/crates/common/src/api/open_ai.rs @@ -80,6 +80,8 @@ pub struct FunctionParameter { pub enum_values: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub default: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub format: Option, } 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() } } diff --git a/crates/common/src/configuration.rs b/crates/common/src/configuration.rs index 91982846..e83c1117 100644 --- a/crates/common/src/configuration.rs +++ b/crates/common/src/configuration.rs @@ -196,6 +196,7 @@ pub struct Parameter { pub enum_values: Option>, pub default: Option, pub in_path: Option, + pub format: Option, } #[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); } diff --git a/demos/weather_forecast/arch_config.yaml b/demos/weather_forecast/arch_config.yaml index 935be68d..4238352b 100644 --- a/demos/weather_forecast/arch_config.yaml +++ b/demos/weather_forecast/arch_config.yaml @@ -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 diff --git a/e2e_tests/api_model_server.rest b/e2e_tests/api_model_server.rest index 37f31c4f..d01a9a8c 100644 --- a/e2e_tests/api_model_server.rest +++ b/e2e_tests/api_model_server.rest @@ -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 +} diff --git a/e2e_tests/api_prompt_gateway.rest b/e2e_tests/api_prompt_gateway.rest index c4ef844d..537b06ac 100644 --- a/e2e_tests/api_prompt_gateway.rest +++ b/e2e_tests/api_prompt_gateway.rest @@ -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" } ] } diff --git a/e2e_tests/test_prompt_gateway.py b/e2e_tests/test_prompt_gateway.py index 01b2b80c..562a124a 100644 --- a/e2e_tests/test_prompt_gateway.py +++ b/e2e_tests/test_prompt_gateway.py @@ -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, diff --git a/model_server/pyproject.toml b/model_server/pyproject.toml index 9fa447f0..23f8db6a 100644 --- a/model_server/pyproject.toml +++ b/model_server/pyproject.toml @@ -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