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

Expanding Swift Package Functionality #7186

Closed
spprichard opened this issue May 9, 2024 Discussed in #7053 · 2 comments
Closed

Expanding Swift Package Functionality #7186

spprichard opened this issue May 9, 2024 Discussed in #7053 · 2 comments

Comments

@spprichard
Copy link
Contributor

Discussed in #7053

Originally posted by **FreakTheMighty** May 2, 2024 I'm using the example swiftui application as a starting place and would like to add grammar constraints. I'm a bit stuck on how to actually load a grammar file. In the c++ examples, the [grammar_parser::parse](https://github.com/ggerganov/llama.cpp/blob/master/common/grammar-parser.h), but in swift this API doesn't appear to be exposed.

Any suggested on how to load a grammar would be much appreciated.

Would it be possible to expand the Swift package to include more functionality found in common?

@spprichard spprichard changed the title Loading Grammar From Swift Expanding Swift Package Functionality May 9, 2024
@ggerganov
Copy link
Owner

The logic is that everything inside the examples folder is a demonstration of how to use the llama.cpp library that currently has only a C-style API defined in llama.h. There are many useful bits in the examples and especially in common that with time, as they mature, make their way into the core llama library, available through the C-style API. The grammar parser is one such thing that will at some point get tightly integrated - just need developer time to find the best way

We don't want to expose a C++ API of the stuff in common because C++ APIs are very difficult to adopt compared to C-style APIs and it is not worth the effort.

Would it be possible to expand the Swift package to include more functionality found in common?

For now, it's better to replicate the common functionality that you are interested in your Swift project.

@spprichard
Copy link
Contributor Author

Sweet! Makes sense. Thank you for the explanation 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants