Maximilian-Winter / llama-cpp-agent

The llama-cpp-agent framework is a tool designed for easy interaction with Large Language Models (LLMs). Allowing users to chat with LLM models, execute structured function calls and get structured output. Works also with models not fine-tuned to JSON output and function calls.
Other
472 stars 42 forks source link

Error: AttributeError: type object 'Book' has no attribute 'model_fields' #29

Closed ibehnam closed 6 months ago

ibehnam commented 6 months ago

I've been trying to use the package. Trying the example shown here throws the said error:

https://github.com/Maximilian-Winter/llama-cpp-agent/blob/master/examples/02_Structured_Output/book_dataset_creation.py

More details:

generate_field_markdown(field_name, field_type, model, depth, documentation_with_field_description)
   (...)
--> [752](https://file+.vscode-resource.vscode-cdn.net.../.venv/lib/python3.12/site-packages/llama_cpp_agent/gbnf_grammar_generator/gbnf_grammar_from_pydantic_models.py:752) field_info = model.model_fields.get(field_name)
Maximilian-Winter commented 6 months ago

Hi, I just released a new version and tested it. It should work now.

ibehnam commented 6 months ago

@Maximilian-Winter Thanks, that seems to have solved the problem.