Skip to content
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

Bug: pydantic_models_to_grammar_examples.py is broken #8471

Closed
maruel opened this issue Jul 13, 2024 · 2 comments · Fixed by #8474
Closed

Bug: pydantic_models_to_grammar_examples.py is broken #8471

maruel opened this issue Jul 13, 2024 · 2 comments · Fixed by #8474
Labels
bug-unconfirmed low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches)

Comments

@maruel
Copy link
Contributor

maruel commented Jul 13, 2024

What happened?

3fd62a6 by @compilade broke pydantic_models_to_grammar.py

@jaime-m-p FYI

Name and Version

Reproduced on:

  • python 3.10.12 on Ubuntu 22.04.4 LTS
  • python 3.12.2 on macOS 14.5

The regression occurred in 3fd62a6

What operating system are you seeing the problem on?

Linux, Mac

Relevant log output

# Start a server
./llama-server --model ./models/Mistral-7B-Instruct-v0.3.fp16.gguf -ngl 9999 --port 8080

# Commands
python3 -m venv venv
source venv/bin/activate
pip install docstring_parser pydantic requests
cd examples
python3 pydantic_models_to_grammar_examples.py

# Outputs
Traceback (most recent call last):
  File "$HOME/llama.cpp/examples/pydantic_models_to_grammar_examples.py", line 75, in <module>
    gbnf_grammar, documentation = generate_gbnf_grammar_and_documentation(
  File "$HOME/llama.cpp/examples/pydantic_models_to_grammar.py", line 1080, in generate_gbnf_grammar_and_documentation
    documentation = generate_markdown_documentation(
  File "/$HOME/llama.cpp/examples/pydantic_models_to_grammar.py", line 721, in generate_markdown_documentation
    documentation += generate_field_markdown(
  File "$HOME/llama.cpp/examples/pydantic_models_to_grammar.py", line 775, in generate_field_markdown
    field_text = f"{indent}{field_name} ({format_model_and_field_name(field_type.__name__)})"
AttributeError: 'str' object has no attribute '__name__'. Did you mean: '__ne__'?

# Trying previous version:
git checkout 3fd62a6b1c9ca7b7c0093e984cc9c133c6f2726d~1
python3 pydantic_models_to_grammar_examples.py

# (Success on python3.12, different error on python3.10)
@maruel maruel added bug-unconfirmed low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches) labels Jul 13, 2024
@compilade
Copy link
Collaborator

@maruel Thanks for reporting, I'll look into this.

At first glance it's not obvious which line change(s) from #8341 caused this, but I'll try to fix this.

@compilade
Copy link
Collaborator

@maruel I found the problem and pushed a fix in #8474.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants