dify
dify copied to clipboard
add support for swagger object and array type
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] Pleas do not modify this template :) and fill in all the required fields.
1. Is this request related to a challenge you're experiencing?
Objective: Convert the JSON generated by the LLM into the types defined in the Swagger documentation.
2. Describe the feature you'd like to see
Hi, @Yeuoly ,Dify currently supports simple object types, such as Map<String, String>, but it still lacks support for custom object types and arrays.
I want continue to refine the Swagger parsing to enable Dify to support the following formats:
- support array type:
- example:
- swagger format:
"properties": {
"arr": {
"type": "array",
"description": "array type",
"items": {
"type": "integer"
}
}
}
-
- llm generate:
{"arr" : "['1', '2', '3']"}
- parse to :
{"arr" : [1, 2, 3]}
- llm generate:
- support additional object type:
- example:
- swagger format:
"properties": {
"objectXXX": {
"type": "object",
"description": "object type",
"additionalProperties": {
"type": "integer",
"format": "int32"
}
}
}
-
- llm generate:
{"objectXXX" : "{'field1' : '11', 'field1' : '22'}"}
- parse to:
{"objectXXX" : {'field1' : 11, 'field1' : 22}}
- llm generate:
3. How will this feature improve your workflow or experience?
Regarding nested sub-objects, I've found that the LLM's accuracy in generating nested structures is not very high. I believe that the object structures provided to the LLM should not be too complex and must be easily interpretable. One solution I've thought of is that the tool's input parameters should convert nested sub-objects into simple Object types, and then include a few-shot description. For example: change
"properties": {
"objectNestedType": {
"type": "object",
"additionalProperties": {
"originalRef": "TestReq",
"$ref": "#/definitions/Person"
}
}
}
to
"properties": {
"objectNestedType": {
"type": "object",
"description": "The following information extracted from the conversation: userName, age, sex. such as {'userName' : 'ben'}",
}
}
4. Additional context or comments
No response
5. Can you help us with this feature?
- [X] I am interested in contributing to this feature.
active
Close. because there are very few supported models, such as llama3, which is not supported. I will try another way to support tool calls