kylecorry31 / ML4K-AI-Extension

Use machine learning in AppInventor, with easy training using text, images, or numbers through the Machine Learning for Kids website.
MIT License
20 stars 15 forks source link

Presetting the API key #14

Closed dalelane closed 5 years ago

dalelane commented 5 years ago

Is there a way that the API key can be read from the aix file, to save the need for students to use the API key block?

If the API key could be read from a properties/config file inside the aix file, then I could get ML4K to dynamically generate that (start from a default aix file of ML4K-AI-Extension, unzip it, modify the properties/config file with the API key, zip it back up, serve that patched aix file for download).

I think that'd be a helpful simplification... what do you think?

kylecorry31 commented 5 years ago

I will look into this, and assess the feasibility.

kylecorry31 commented 5 years ago

Research (WIP):

kylecorry31 commented 5 years ago

It does not look like it is possible to send a file containing the API key through AppInventor. @dalelane

MrMazzone commented 5 years ago

@ewpatton Any ideas about this?

ewpatton commented 5 years ago

Custom assets are packaged in the .aix in a subdirectory assets/. You can read them at runtime by a call to Form.openAssetForExtension(Component, String), which takes an instance of the extension and the name of the asset.

What you could do is compile the AIX with a placeholder key file, and then when you serve up the .aix to the user you could update the key file in the assets directory to be read at runtime.

kylecorry31 commented 5 years ago

Thanks! I'll see what I can do to implement this feature

ewpatton commented 5 years ago

@kylecorry31 You can see an example in our Look extension here.

kylecorry31 commented 5 years ago

@ewpatton Thanks for the help!

@dalelane The latest version of the extension allows you to preset the API key, building instructions are here: https://github.com/kylecorry31/ML4K-AI-Extension/tree/v0.8-beta#building-with-preset-api-key

Let me know if you have any questions.

dalelane commented 5 years ago

@kylecorry31 @ewpatton That's fantastic - thanks so much for doing that!

I've set up the site to support downloading the aix file with the API key already embedded in it.

image