Find answers from the community

Updated 2 months ago

Hi @Logan M , what would be the easiest

Hi @Logan M , what would be the easiest way to infer the fn_schema to pass in a Function Tool?

Context: The function tool is hosted elsewhere and the schema varies per use-case. At inference, I want to be able to send a string that can be used as the fn_schema. My question will then be, what should be the structure and the contents of this string and how to parse it into a llama index compatible fn_schema?
L
b
4 comments
The string is just an typical json schema -- its a standard structure you can find online

Generally it looks like

Plain Text
{
    "type": "object",
    "properties": {
        "input": {"title": "input query string", "type": "string"},
    },
    "required": ["input"],
}
You can also leverage a pydantic model for this
Plain Text
schema_dict = pydanitc_model.model_json_schema()
parameters = {
    k: v
    for k, v in parameters.items()
    if k in ["type", "properties", "required", "definitions", "$defs"]
}
Gotcha, thanks @Logan M !
Add a reply
Sign up and join the conversation on Discord