-
Notifications
You must be signed in to change notification settings - Fork 13
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
aiextract and parametric types #81
Comments
I’ll have a look later but there are two challenges:
It might be easier to enable passing a vector of types and pass both to the “tools”. At the moment, I fix it to one return type only but theoretically the model can choose its tool. EDIT: After the second read, I'm fairly confident that you're hitting the 2) highlighted above. JSON3 has no idea what to unpack into, eg, using JSON3
abstract type AbstractThing end
struct Dolphin <: AbstractThing end
struct NotDolphin <: AbstractThing end
struct ThingHolder{C<:AbstractThing}
dolphin_or_not::C
end
obj = ThingHolder(Dolphin())
str = JSON3.write(obj)
# "\"ThingHolder{Dolphin}(Dolphin())\""
JSON3.read(str, ThingHolder) The third issue is that the "name" (type) of the struct without any fields is hard to capture in JSON. See what PromptingTools creates as the signature for the above object: PT.function_call_signature(typeof(obj))
## Dict{String, Any} with 2 entries:
## "name" => "ThingHolderDolphin_extractor"
## "parameters" => Dict{String, Any}("properties"=>Dict{String, Any}("dolphin_or_not"=>Dict{String, Any}("properties"=>Dict{String, Any}(), "type"=>"object")), "required"=>["dolphin_or_not"], "type"=>"object") Properties are effectively an empty Dict, because the Struct is empty. So either add the necessary annotating fields for your struct to enable the StructType dispatch with abstract types or simply use Enum/vector of symbols, or just use aiclassify as a router (more "token efficient" and faster!) |
Not quite sure what's up with this example, but
aiextract
doesn't seem to know what to do here:In both cases, I get a
Dict
:I think my expectation here would be that I'd get a
ThingHolder
, but the fallback seems to be to aDict
. Anyway thought I'd type this one up in case it's unexpected behavior.Here's the warnings indicating that the JSON could not be read:
The text was updated successfully, but these errors were encountered: