[Python] Convert Ollama's Structured Output from JSON to Python DF

Discussão em 'Python' iniciado por Stack, Dezembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    I'm having a devil of a time converting structured output from Ollama's new API to a df. The following is JSON output from the Data Extraction example on the Ollama page on structured outputs (https://ollama.com/blog/structured-outputs):

    pets=[
    Pet(name='Luna', animal='cat', age=5, color='grey', favorite_toy='yarn'),
    Pet(name='Loki', animal='cat', age=2, color='black', favorite_toy='tennis balls')
    ]


    After trying several different python-based JSON conversion modules without success, I tried replacing the parentheses with braces and to remove all instances of "Pet", but none of the replace functions work with this structure. Any help is appreciated.

    Continue reading...

Compartilhe esta Página