-
Notifications
You must be signed in to change notification settings - Fork 107
Closed as not planned
Closed as not planned
Copy link
Description
Package: lmstudio-1.4.1
LM Studio: 0.3.20(Build 4)
Issue: A structured output does not follow the specified order of the JSON schema provided. Instead the response structure is in alphabetical order. The schema works fine if I use it directly in LM Studio Client.
The current workaround is to add a prefix to the objects in the schema if I want to keep the order.
Tested with various models.
Simple example case:
schema = {
"type": "object",
"properties": {
"name": {"type": "string", "description": "Name of the subject"},
"age": {"type": "string", "description": "Age"},
"a_summary": { # a_ to showcasae alphabetical order
"type": "string",
"description": "Short summary of the person's greatest achievement",
},
},
"required": ["name", "age", "a_summary"],
}
chat_session = lms.Chat()
chat_session.add_system_prompt("You are a helpful AI assistant")
user_input = chat_session.add_user_message("Tell me about a famous person")
result = model.respond(
chat_session, config={"temperature": 0.4}, response_format=schema
)
print(json.dumps(result.parsed, indent=2))In this case "a_summary" ends up first in the response.
Metadata
Metadata
Assignees
Labels
No labels