diff --git a/api-reference/llm_queries/chat_completions.mdx b/api-reference/llm_queries/chat_completions.mdx index 81aa044ae..ffe10fc39 100644 --- a/api-reference/llm_queries/chat_completions.mdx +++ b/api-reference/llm_queries/chat_completions.mdx @@ -194,8 +194,8 @@ curl --request POST \ "response_format": "{ \"type\": \"json_mode\"}", "seed": 11, "stream_options": [ - "include_usage", - true + true, + "include_usage" ], "top_p": 0.5, "tool_choice": "{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}", @@ -218,7 +218,7 @@ url = "https://api.unify.ai/v0/chat/completions" headers = {"Authorization": "Bearer "} -json_input = {"messages": [{"content": "Tell me a joke", "role": "user"}], "model": "gpt-4o-mini@openai", "max_tokens": 1024, "stop": ["The End.", " is the answer."], "stream": False, "temperature": 0.9, "frequency_penalty": 1.5, "logit_bias": {"0": 10, "1": -75, "2": 90}, "logprobs": False, "top_logprobs": 15, "n": 15, "presence_penalty": -1.1, "response_format": "{ "type": "json_mode"}", "seed": 11, "stream_options": ["include_usage", True], "top_p": 0.5, "tool_choice": "{"type": "function", "function": {"name": "my_function"}}", "parallel_tool_calls": True, "user": "some_user", "signature": "python", "use_custom_keys": True, "tags": ["user123", "CompanyABC"], "drop_params": True} +json_input = {"messages": [{"content": "Tell me a joke", "role": "user"}], "model": "gpt-4o-mini@openai", "max_tokens": 1024, "stop": ["The End.", " is the answer."], "stream": False, "temperature": 0.9, "frequency_penalty": 1.5, "logit_bias": {"0": 10, "1": -75, "2": 90}, "logprobs": False, "top_logprobs": 15, "n": 15, "presence_penalty": -1.1, "response_format": "{ "type": "json_mode"}", "seed": 11, "stream_options": [True, "include_usage"], "top_p": 0.5, "tool_choice": "{"type": "function", "function": {"name": "my_function"}}", "parallel_tool_calls": True, "user": "some_user", "signature": "python", "use_custom_keys": True, "tags": ["user123", "CompanyABC"], "drop_params": True} response = requests.request("POST", url, json=json_input, headers=headers) diff --git a/api-reference/logs/create_log.mdx b/api-reference/logs/create_logs.mdx similarity index 53% rename from api-reference/logs/create_log.mdx rename to api-reference/logs/create_logs.mdx index fd9fcce53..40951118b 100644 --- a/api-reference/logs/create_log.mdx +++ b/api-reference/logs/create_logs.mdx @@ -1,15 +1,15 @@ --- -title: 'Create Log' -api: 'POST /v0/log' +title: 'Create Logs' +api: 'POST /v0/logs' --- -Creates a log associated to a project. Logs are +Creates one or more logs associated to a project. Logs are LLM-call-level data that might depend on other variables. A "explicit_types" dictionary can be passed as part of the `entries`. If present, any matching key inside this dictionary will override the inferred type of that particular entry. -This method returns the id of the new stored log. +This method returns the ids of the new stored logs. #### Authorizations @@ -23,12 +23,12 @@ This method returns the id of the new stored log. Name of the project the stored entries will be associated to. - -Dictionary containing one or more key:value pairs that will be logged into the platform. Parameters will be automatically versioned based on their values. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries. + +Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Parameters will be automatically versioned based on their values. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries. - -Dictionary containing one or more key:value pairs that will be logged into the platform. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries. + +Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries. @@ -39,36 +39,22 @@ Enforce strong typing for fields. ```bash cURL curl --request POST \ - --url 'https://api.unify.ai/v0/log' \ + --url 'https://api.unify.ai/v0/logs' \ --header "Authorization: Bearer $UNIFY_KEY" \ --header 'Content-Type: application/json' \ --data '{ - "project": "eval-project", - "params": { - "explicit_types": { - "system-prompt": "str" - }, - "function_definition": "...", - "system-prompt": "..." - }, - "entries": { - "explicit_types": { - "input": "Image" - }, - "input": "...", - "score-test-1": "..." - } + "project": "eval-project" }' ``` ```python Python import requests -url = "https://api.unify.ai/v0/log" +url = "https://api.unify.ai/v0/logs" headers = {"Authorization": "Bearer "} -json_input = {"project": "eval-project", "params": {"explicit_types": {"system-prompt": "str"}, "function_definition": "...", "system-prompt": "..."}, "entries": {"explicit_types": {"input": "Image"}, "input": "...", "score-test-1": "..."}} +json_input = {"project": "eval-project"} response = requests.request("POST", url, json=json_input, headers=headers) @@ -80,7 +66,12 @@ print(response.text) ```json 200 { - "info": "Log created successfully!" + "info": "Logs created successfully!", + "log_event_ids": [ + 1, + 2, + 3 + ] } ``` diff --git a/api-reference/openapi.json b/api-reference/openapi.json index f828893be..661a9c4cf 100644 --- a/api-reference/openapi.json +++ b/api-reference/openapi.json @@ -2828,94 +2828,41 @@ } } }, - "/v0/log": { + "/v0/logs": { "post": { "tags": [ "Logs" ], - "summary": "Create Log", - "description": "Creates a log associated to a project. Logs are\nLLM-call-level data that might depend on other variables.\n\nA \"explicit_types\" dictionary can be passed as part of the `entries`.\nIf present, any matching key inside this dictionary will override the\ninferred type of that particular entry.\n\nThis method returns the id of the new stored log.", - "operationId": "create_log_v0_log_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateLogConfig" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": {}, - "example": { - "info": "Log created successfully!" - } - } - } - }, - "404": { - "description": "Project Not Found", - "content": { - "application/json": { - "example": { - "detail": "Project not found." - } - } - } - }, - "422": { - "description": "Validation Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HTTPValidationError" - } - } - } - } - }, + "summary": "Create Logs", + "description": "Creates one or more logs associated to a project. Logs are\nLLM-call-level data that might depend on other variables.\n\nA \"explicit_types\" dictionary can be passed as part of the `entries`.\nIf present, any matching key inside this dictionary will override the\ninferred type of that particular entry.\n\nThis method returns the ids of the new stored logs.", + "operationId": "create_logs_v0_logs_post", "security": [ { "HTTPBearer": [] } - ] - } - }, - "/v0/log/derived": { - "put": { - "tags": [ - "Logs" ], - "summary": "Create Derived Entry", - "description": "Creates one or more derived-log entries based on `body.equation` and `body.referenced_logs`.\nEagerly computes each derived value and stores it in DerivedLog.value.", - "operationId": "create_derived_entry_v0_log_derived_put", "requestBody": { + "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateDerivedEntriesConfig" + "$ref": "#/components/schemas/CreateLogConfig" } } - }, - "required": true + } }, "responses": { "200": { - "description": "Derived log entries created successfully.", + "description": "Successful Response", "content": { "application/json": { "schema": {}, "example": { - "info": "Created 3 derived logs with key='example_key'.", - "derived_log_ids": [ - 101, - 102, - 103 + "info": "Logs created successfully!", + "log_event_ids": [ + 1, + 2, + 3 ] } } @@ -2926,17 +2873,7 @@ "content": { "application/json": { "example": { - "detail": "Project 'example_project' not found." - } - } - } - }, - "400": { - "description": "Bad Request", - "content": { - "application/json": { - "example": { - "detail": "All referenced log lists must have the same length. Found lengths: [2, 3]." + "detail": "Project not found." } } } @@ -2951,15 +2888,8 @@ } } } - }, - "security": [ - { - "HTTPBearer": [] - } - ] - } - }, - "/v0/logs": { + } + }, "put": { "tags": [ "Logs" @@ -3366,6 +3296,79 @@ } } }, + "/v0/log/derived": { + "put": { + "tags": [ + "Logs" + ], + "summary": "Create Derived Entry", + "description": "Creates one or more derived-log entries based on `body.equation` and `body.referenced_logs`.\nEagerly computes each derived value and stores it in DerivedLog.value.", + "operationId": "create_derived_entry_v0_log_derived_put", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateDerivedEntriesConfig" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Derived log entries created successfully.", + "content": { + "application/json": { + "schema": {}, + "example": { + "info": "Created 3 derived logs with key='example_key'.", + "derived_log_ids": [ + 101, + 102, + 103 + ] + } + } + } + }, + "404": { + "description": "Project Not Found", + "content": { + "application/json": { + "example": { + "detail": "Project 'example_project' not found." + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "example": { + "detail": "All referenced log lists must have the same length. Found lengths: [2, 3]." + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "security": [ + { + "HTTPBearer": [] + } + ] + } + }, "/v0/logs/latest_timestamp": { "get": { "tags": [ @@ -4765,8 +4768,8 @@ "title": "Stream Options", "description": "Options for streaming response. Only set this when you set `stream: true`.", "example": [ - "include_usage", - true + true, + "include_usage" ] }, "top_p": { @@ -5057,30 +5060,72 @@ "example": "eval-project" }, "params": { - "type": "object", + "anyOf": [ + { + "type": "object" + }, + { + "items": { + "type": "object" + }, + "type": "array" + } + ], "title": "Params", - "description": "Dictionary containing one or more key:value pairs that will be logged into the platform. Parameters will be automatically versioned based on their values. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries.", + "description": "Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Parameters will be automatically versioned based on their values. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries.", "default": {}, - "example": { - "explicit_types": { - "system-prompt": "str" + "examples": [ + { + "explicit_types": { + "system-prompt": "str" + }, + "function_definition": "...", + "system-prompt": "..." }, - "function_definition": "...", - "system-prompt": "..." - } + [ + { + "system-prompt": "prompt1" + }, + { + "system-prompt": "prompt2" + } + ] + ] }, "entries": { - "type": "object", + "anyOf": [ + { + "type": "object" + }, + { + "items": { + "type": "object" + }, + "type": "array" + } + ], "title": "Entries", - "description": "Dictionary containing one or more key:value pairs that will be logged into the platform. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries.", + "description": "Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Values must be JSON serializable. If a `explicit_types` dictionary is present, its values will override the inferred types of the entries.", "default": {}, - "example": { - "explicit_types": { - "input": "Image" + "examples": [ + { + "explicit_types": { + "input": "Image" + }, + "input": "...", + "score-test-1": "..." }, - "input": "...", - "score-test-1": "..." - } + [ + { + "input": "test1", + "score": 0.8 + }, + { + "input": "test2", + "score": 0.9 + } + ] + ] }, "strongly_typed": { "anyOf": [ diff --git a/mint.json b/mint.json index e6363a68a..dfb15a9f0 100644 --- a/mint.json +++ b/mint.json @@ -442,11 +442,11 @@ { "group": "Logs", "pages": [ - "api-reference/logs/create_log", - "api-reference/logs/create_derived_entry", + "api-reference/logs/create_logs", "api-reference/logs/update_logs", "api-reference/logs/delete_logs", "api-reference/logs/get_logs", + "api-reference/logs/create_derived_entry", "api-reference/logs/get_logs_latest_timestamp", "api-reference/logs/get_logs_metric", "api-reference/logs/get_log_groups",