Bug on Anthropic Claude when oneOf
union type comes.
#88
Labels
bug
Something isn't working
help wanted
Extra attention is needed
question
Further information is requested
Summary
When union type comes, Anthropic Claude fills to JSON string value in the function calling.
Such string value filling problem occurs even when the target type is not
string
, butobject
.Here is the TypeScript type (and JSON schema file) tried to run the LLM function calling.
How to reproduce
At first, clone this repository.
And then, create a
.env
file like above.npm install npm run build npm run test -- --include claude_function_calling_union
https://github.com/samchon/openapi/blob/master/test/features/llm/claude/test_claude_function_calling_union.ts
At last, install, build and run test program function of above.
Then you may meet the above error message:
anyOf
instead ofoneOf
npm run test -- --include claude_function_calling_union --model chatgpt
https://github.com/samchon/openapi/blob/master/examples/function-calling/schemas/chatgpt.union.schema.json
If you run the test program function again with the
--mode chatgpt
argument, the test program function will utilize the OpenAI ChatGPT's JSON schema speification instead. And there is not any problem in that case. It is because OpenAI supports onlyanyOf
type, and it has banned theoneOf
type. And theanyOf
type does not occur thestring
value filling bug.By the way, following the Claude documents, it seems like Claude is supporting the
oneOf
type. Also, I prefer theoneOf
type and think that theoneOf
type is much proper for LLM function calling, because it can utilize thediscriminator
property which directly indicates how to distinguish the union type.Therefore, I report this phenomenon considering as a bug.
JSON Schema Speficiation
Looking at guide documents of Claude and taking experiments of function calling, I've defined JSON schema speficiation for Anthropic Claude like below. If you find something wrong, then please comment me to fix it.
IChatGptSchema
: OpenAI ChatGPTIClaudeSchema
: Anthropic Claude (same withILlmSchemaV3_1
)ILlmSchemaV3_1
: middle layer based on OpenAPI v3.1 specificationThe text was updated successfully, but these errors were encountered: