Skip to content

feat: JBangGPT -> JBang AI with multiple providers and no-preview - #2324

Merged
maxandersen merged 2 commits into
jbangdev:mainfrom
maxandersen:jbangai
Nov 24, 2025
Merged

maxandersen merged 2 commits into
jbangdev:mainfrom
maxandersen:jbangai

Conversation

@maxandersen

Copy link
Copy Markdown
Collaborator

realized i never really used jbanggpt because it was A) behind preview flag B) broken.

this fixes it, removes preview requirement + calls it JBang AI instead of GPT ...and introduce mechanism of picking a key from env and guess potential providers - incl. option of overriding it with JBANG_AI_* env.

should we add jbang config flags for them?

wdyt?

@quintesse

Copy link
Copy Markdown
Contributor

Yes, I think it would be a good idea to provide flags. It will also give more attention to this feature when people run jbang init --help

@maxandersen

Copy link
Copy Markdown
Collaborator Author

implemented ai arggroup that uses environment/jbang options to look up values - @quintesse did i do that right ?

also moved file check to before ai call so you dont wait several seconds to then get rejected.

jbang init --ai-model=gpt-5.1 tetris.java implement tetris using whatever library that makes the most sense , javafx, libgdx or something else as long as its java using jbang syntax in one file.

gives you:

2025-11-22_09-10-58.mp4

https://gist.github.com/maxandersen/ad1eed2e9daf1be6285cbab9ce095511

i kinda wish we could come up with a way to detect ollama running locally but just a bit too many variants and models to make it worthwhile...user can always set the --ai-* config or env to make it work though.

@maxandersen
maxandersen force-pushed the jbangai branch 5 times, most recently from 2ca40da to 0fc60db Compare November 22, 2025 23:49
@maxandersen

Copy link
Copy Markdown
Collaborator Author

plan to merge this if tests passes as its isolated change and would like a release out

@maxandersen
maxandersen force-pushed the jbangai branch 2 times, most recently from 5aa1155 to ff088e8 Compare November 24, 2025 02:36
@maxandersen

Copy link
Copy Markdown
Collaborator Author

i commented out providers i haven't had time to verify - just in case.
i moved the system prompt to a qute template + made it way more directed to increase likelihood of code actually working (but still not a gurantee - but still pretty damn good).

@maxandersen
maxandersen merged commit 85a0e06 into jbangdev:main Nov 24, 2025
28 checks passed

[source,bash]
----
$ jbang config set default.ai.provider openai

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, except for this, the default values don't start with "default.". THe fact that in the code you have to do:

defaultValue = "${JBANG_AI_PROVIDER:-${default.ai.provider)}"

is just an internal implementation detail.

Also, special chars are removed from the names. In this case you're using a . in the name, which is not valid. So the actual name becomes: aiprovider. (Although the fqn can also be used, which would be app.init.aiprovider, but in this case that's not very interesting/useful)

public class AIOptions {

@CommandLine.Option(names = {
"--ai-provider" }, description = "Provider to use (openai, openrouter, etc.) when using init with a prompt - if none specified will use the default provider from environment variables", defaultValue = "${JBANG_AI_PROVIDER:-${default.ai.provider)}")

@quintesse quintesse Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't do default.ai.provider here, you have to use the fully qualified name (without special chars like I said earlier), so it becomes default.init.aiprovider.

And finally I see you have typos in those lines, you're using a ) instead of as }:

${JBANG_AI_PROVIDER:-${default.ai.provider)}
                                          ^

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

Successfully merging this pull request may close these issues.

2 participants