Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify response_format to take in JSON object instead of string #11542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frankaloia
Copy link
Contributor

Description

Tests

Ran against local endpoint:

Request:

{
      "specification_hash": "973a5fa849b584b384cdd87b70bd7e03ebf12227edf0ff50e9e7f08fa7a27c86",
      "config": {
        "MODEL": {
          "provider_id": "openai",
          "model_id": "gpt-4.5-preview-2025-02-27",
          "function_call": null,
          "use_cache": false,
          "response_format": {
            "type": "json_schema",
            "json_schema": {
              "name": "ABeautifulTest",
              "strict": true,
              "schema": {
              "type": "object",
              "properties": {
                "Name": {
                  "type": "string"
                },
                "Description": {
                    "type": "string"
                }
              },
              "required": ["Name", "Description"],
              "additionalProperties": false
              }
            }
          }
        }
      },
      "blocking": true,
      "inputs": [{"hello":"world"}]
    }

Output:

 {"run":{"run_id":"730bf651dfc1b78f54223084c300dc54339490bd1ed4fbb816b70b06b4d68560","created":1742578696878,"run_type":"deploy","config":{"blocks":{"MODEL":{"provider_id":"openai","model_id":"gpt-4.5-preview-2025-02-27","function_call":null,"use_cache":false,"response_format":{"type":"json_schema","json_schema":{"name":"ABeautifulTest","strict":true,"schema":{"type":"object","properties":{"Name":{"type":"string"},"Description":{"type":"string"}},"required":["Name","Description"],"additionalProperties":false}}}}}},"status":{"run":"succeeded","blocks":[{"block_type":"input","name":"INPUT","status":"succeeded","success_count":1,"error_count":0},{"block_type":"chat","name":"MODEL","status":"succeeded","success_count":1,"error_count":0}]},"traces":[[["input","INPUT"],[[{"value":{"hello":"world"},"error":null,"meta":null}]]],[["chat","MODEL"],[[{"value":{"message":{"content":"{\"Name\":\"Hello\",\"Description\":\"Hi! How can I assist you today?\"}","role":"assistant"}},"error":null,"meta":{"logs":[],"token_usage":{"prompt_tokens":52,"completion_tokens":18},"provider_request_id":"req_b75b23937184f73151094d25df79c036"}}]]]],"specification_hash":"973a5fa849b584b384cdd87b70bd7e03ebf12227edf0ff50e9e7f08fa7a27c86","results":[[{"value":{"message":{"content":"{\"Name\":\"Hello\",\"Description\":\"Hi! How can I assist you today?\"}","role":"assistant"}},"error":null,"meta":{"logs":[],"token_usage":{"prompt_tokens":52,"completion_tokens":18},"provider_request_id":"req_b75b23937184f73151094d25df79c036"}}]]}}

Risk

N/A - I don't believe this is directly exposed to customers yet via the console. It should fix an existing issue.

Deploy Plan

Deploy via Github

@frankaloia frankaloia requested a review from flvndvd March 21, 2025 17:43
@@ -313,7 +313,7 @@ impl Block for Chat {
if let Some(Value::String(s)) = v.get("openai_organization_id") {
extras["openai_organization_id"] = json!(s.clone());
}
if let Some(Value::String(s)) = v.get("response_format") {
if let Some(Value::Object(s)) = v.get("response_format") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this used to work, does it mean that response_format was a string? Or was it simply never meeting this condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants