[ANN]: AskAI - Your Direct AI Support in REPL :)

,

AskAI in REPL

Hi everyone!

I am happy to finally share my first julia package, AskAI! As the name suggests, it is a straightforward tool for AI queries in REPL. Currently, it utilizes Google’s Gemini model due to its free API. :blush:

Key Features:

  • Use @ai to query and receive AI responses.
  • Use @AI to directly execute the AI response as Julia code and obtain the result.
    the codes would be executed under the Main.playground

Usage

julia> using AskAI
# set your gemini key, or set  ENV["AI_API_KEY"] in  your startup.jl
julia> setapi("1234567890abcdef1234567890abcdef") 

julia> @ai "sort a dict by the values"
  function sort_dict_by_value(d::Dict)
      return Dict(sort(collect(d), by=x->x[2]))
  end

BTW, the query history stored in the AskAI.Brain;

more usage example:

@AI "create a new project in /tmp, name it as demo + date, activate it"
@AI "load my data as df, the data file is in /tmp/celldata.csv"
@AI "install the package to support figure display in the terminal"
@AI "plot a scatter plot of geneX and geneY, I want the geneX on axis Y"
@AI "fit a linear model to predict value of geneY from geneX,using GLM"

Screenshot

This is my first Julia package, and I would love to hear any suggestions or advice you may have!

Thank you for your support!

27 Likes

That’s a really useful package I think. One suggestion would be to generalise the backend by supporting ollama. Nice work!

1 Like

Thanks, that’s a good suggestion. Comprehensive backend support is needed. :grin:included in the next steps.

2 Likes

This sounds like an interesting approach to use AI – thanks for starting such a package.

One possible feature could be to consider integrating it with REPL similar to ?, ], or ; (help, pkg, shell mode) and have an “AI mode”. It would have to be something no usual command starts with, so maybe also some closing “thing” like }? You could try to then switch to a (maybe purple?) AI> mode. For completeness it could even display which one it uses like pkg shows its env, so maybe even AI (Gemini)>?

8 Likes

That’s a really nice package idea, thanks for your work!

But you definitely should change the example in the Readme, because Dicts are unordered.
Maybe we should feed some Julia trivia to the AI in the beginning of each session?

2 Likes

This is pretty neat, thank you for sharing this. With Gemini gaining more and more prominence, it’s nice to see first-hand support for it from the REPL.

It doesn’t look like this doesn’t involve any fine-tuning or context-access to the AI, so it would be interesting to see how the results compare with something like AIHelpMe.jl - whether the Gemini model is better enough to offset its lack of specialization.

Note that JuliaHub also has their own “AskAI” feature on their website - at first I assumed this was related to that. It’s a generic enough name, and it doesn’t seem too actively maintained anyway, but it might be worthing adding a disclaimer to say this is unrelated to the JuliaHub AskAI.

1 Like

I was thinking the same. A package that could help to achieve this is ReplMaker.jl

2 Likes

I disagree, I think it should be kept as the front page example, as to remember that half the time the AI will probably be spewing bullshit.

2 Likes

I could not get it to work, this is what I did:

using Pkg
module playground end
pkg"activate --temp"
pkg"add https://github.com/AIBioLab/AskAI"
using AskAI
read("gemini-api-key.txt", String) |> AskAI.setapi
@ai "what is a dog?"

Full bug report at HTTP 403 Forbidden error · Issue #1 · AIBioLab/AskAI · GitHub

The REPL mode feature has been requested in the past in PromptingTools.jl and AIHelpMe.jl, see:

So if you can make it happen in AskAI.jl you will certainly get some users.

2 Likes

In your case the api string would contain extra \n in the end, try to strip it would work?

Thanks for your feedback! You’re absolutely right—this implementation doesn’t involve fine-tuning, it works directly but can be adjust by setting prompt, like AskAI.Brain.Prompt = “your prefer prompt” would give some improvement for the AI answer ( anyway in most cases the AI answer should be reviewed)

Also, appreciate the note about JuliaHub’s ‘ask ai ’ feature on their webpage—I’ll make sure to clarify that this is an independent project to avoid any confusion. Thanks for pointing that out!

I don’t think that that was the problem, I submitted a PR that fixed it for me (and includes some other improvements as well)

1 Like

Yes, I finally realized in the previous verion the set api function only work when the api key was set in ENV.

Great thanks to @GHTaarn PR now the package also support an “ai mode” , Thanks to all suggestions here too!!

2 Likes

Good to hear that the PR was merged in.

I saw that you were struggling with putting it in your startup.jl, the following line should load it correctly:

atreplinit(_ -> eval(Meta.parse("using AskAI")))
3 Likes