-
Notifications
You must be signed in to change notification settings - Fork 4
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
Adding a HTTP Interface / REST API? #31
Comments
An HTTP server like this is certainly doable yes. I would not host it myself though, but I assume your plan is to run it yourself just like your recipe manager itself? Note that another possibility would be to have reverse bindings from your language to OCaml. We could in particular turn Kalandralang into a JS lib so that recipes can be executed by the browser. There are a few challenges though. For instance one needs to figure out how to manage the data files. Also I would need to learn how to make reverse bindings. Overall the HTTP server approach would be significantly simpler to implement for me. I look forward to seeing your web project, it sounds very cool :) I'll try to implement the HTTP server. |
I have pushed a branch named
You can then run something like:
(for some reason
Obviously a lot is missing. Can you tell me which of those features would be important for you?
Of course the more features you need the more work it will be for me and I don't know when/if I'll implement them ;) |
Hello! Thank you for taking action on this so quickly. Yes, the idea is for me to run the server. I packaged my local kalandralang copy into a ocalm/opam docker container and have it serving the HTTP interface. I was able to build a super quick PoC (kalandralang http <-> trpc + next.js) this afternoon. It's awesome seeing it work together even in this very primitive form. =) The most important feature would be the JSON output. This would need to minimally include the cost and resulting item as structured data (something like A reverse binding is a really interesting option with the added benefit of bringing the interpreter client side. However, as you pointed out, this would require a lot of upfront work. I think we can take a deeper look into that later if there is excessive challenge with the HTTP approach. I will continue to work on refining the idea and building out the PoC so I can get an accurate picture of what features would be necessary to bring things to life. My current motivation is to setup an archive of crafting recipes for items and assign them to a character. The crafting list across all remaining-to-be-crafted recipes for that character could then be used to determine the total expected costs and raw materials to finish the items. It would bring a whole new level of accuracy to a low budget or high budget build! If anyone has contributing thoughts or experience, please let me know. |
Very nice! Thanks for the screenshot :) Looks cool! And indeed it sounds quite useful to be able to evaluate the budget of a build at any time with real market values. I have pushed a new version of the branch. It now serves JSON instead of plain text. I think you'll find all you need in the data but don't hesitate to tell me if you miss anything. I didn't document the format but I'm sure you'll have no trouble reading the output without documentation, it's pretty self-explanatory. I tested and it appears that one can already perform multiple queries in parallel. The library I use ( |
@cganas are you interested in me rebasing the |
I have a simular request, want to build some tooling around my recipies: could it be possible to add the json output as a flag to main. people then could use what ever language or tools they want to integrate it into there stuff. |
I have rebased the I have added a commit on top of it to add a
@AR-234 I think this should suit your needs. It is possible that there are still some bugs where the program would print stuff on stdout, breaking the JSON output. If you get a JSON parse error, it may be because of such a bug. This is still very experimental and barely tested, so it'll stay in the |
Hello, I want to create a crafting recipe manager web project powered by kalandralang. The challenge of working with OCAML (for us non-ML developers) could be solved with an HTTP interface to the interpreter.
For example, an incoming POST request could contain the recipe in the body of the request and the relevant command line parameters provided by query parameters. The response would be JSON with the recipe output and structured data for the costs and profits of the craft.
It looked to me that a minimal implementation would be straightforward with grinberg/opium. Any thoughts around this?
The text was updated successfully, but these errors were encountered: