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

**URL:** https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042
**Category:** Package Announcements
**Tags:** repl, ai
**Created:** [April 14, 2025, 5:09am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042 "2025-04-14T05:09:51Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 14, 2025, 5:09am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/1 "2025-04-14T05:09:51Z")

</div>

# [AskAI](https://github.com/AIBioLab/AskAI) in REPL

Hi everyone!

I am happy to finally share my first julia package, **[AskAI](https://github.com/AIBioLab/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. 😊

## **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-auto
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:

```julia
@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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/c/2cb31f6e8282e0789ecf0f68f51a130acab8e925.png)

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

Thank you for your support!

---

<div class="post-metadata">

### Author: ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)
#### Post date: [April 14, 2025, 5:38am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/2 "2025-04-14T05:38:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 14, 2025, 5:53am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/3 "2025-04-14T05:53:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)
#### Post date: [April 14, 2025, 6:52am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/4 "2025-04-14T06:52:01Z")

</div>

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)>`?

---

<div class="post-metadata">

### Author: ![aryavorskiy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aryavorskiy/32/43466_2.png) [@aryavorskiy](https://discourse.julialang.org/u/aryavorskiy)
#### Post date: [April 14, 2025, 1:51pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/5 "2025-04-14T13:51:33Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [April 14, 2025, 3:39pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/6 "2025-04-14T15:39:25Z")

</div>

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](https://juliahub.com/ui/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.

---

<div class="post-metadata">

### Author: ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)
#### Post date: [April 14, 2025, 4:30pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/7 "2025-04-14T16:30:07Z")

</div>

> [@kellertuer](#):
>
> One possible feature could be to consider integrating it with REPL similar to `?`, `]`, or `;` (help, pkg, shell mode) and have an “AI mode”

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

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 14, 2025, 4:36pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/8 "2025-04-14T16:36:09Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)
#### Post date: [April 14, 2025, 6:09pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/9 "2025-04-14T18:09:29Z")

</div>

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

```julia
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](https://github.com/AIBioLab/AskAI/issues/1)

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [April 14, 2025, 6:57pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/10 "2025-04-14T18:57:52Z")

</div>

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

> [@What's your AI programming tool stack?](https://discourse.julialang.org/t/whats-your-ai-programming-tool-stack/113455/8):
>
> @svilupp first off, thank you so much for the great work you’ve been doing with the LLM-related packages heart I would use PromptingTools.jl more often if it had a CHAT REPL mode where users could type a special character like / and start chatting without the ai"message" boilerplate: / # typing / as the first character in the line activates CHAT REPL mode chat\> What is the capital of Brazil?robot: Brasília is the capital You can create custom REPL modes in Julia with packages like ReplMaker.jl.…

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

---

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 14, 2025, 7:04pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/11 "2025-04-14T19:04:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 14, 2025, 7:22pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/12 "2025-04-14T19:22:42Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)
#### Post date: [April 14, 2025, 7:37pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/13 "2025-04-14T19:37:28Z")

</div>

> [@Noah.Ark](#):
>
> In your case the api string would contain extra \n in the end, try to strip it would work?

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)

> <https://github.com/AIBioLab/AskAI/pull/2>
>
> \- Moved some of the initialization code into \`\_\_init\_\_()\`
> (This ensures that… the initialization code is run only when the module is loaded and not when it is pre-compiled)
> - Added Brain reinitialization to \`setapi()\` (I think that this is what fixes #1 )
> - Improved the message that asks for the API key to be set
> (It had a bug and a typo)

---

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 14, 2025, 10:14pm UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/14 "2025-04-14T22:14:40Z")

</div>

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!!

---

<div class="post-metadata">

### Author: ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)
#### Post date: [April 15, 2025, 2:54am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/15 "2025-04-15T02:54:20Z")

</div>

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:

```julia
atreplinit(_ -> eval(Meta.parse("using AskAI")))

```

---

<div class="post-metadata">

### Author: ![Noah.Ark](https://avatars.discourse-cdn.com/v4/letter/n/d6d6ee/32.png) [@Noah.Ark](https://discourse.julialang.org/u/Noah.Ark)
#### Post date: [April 20, 2025, 3:37am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/16 "2025-04-20T03:37:15Z")

</div>

Thanks for all of your suggestions and great help!!!  
NOW AskAI also support the ollama.

a bit change in the configure method, it now need to set the provider and model in config, seperated by `|`. such as `"provider|model|api"`

```julia
ENV["AskAI_config"] = "provider|model|api"

# or set it through REPL
# For Ollama
AskAI.setapi("ollama|glm4:latest|http://localhost:11434")

# For Gemini 
AskAI.setapi("Gemini|modelnames|api_key")

# Streaming response mode is now the default, but can be disable by
AskAI.Brain.stream = false

```

## the idea

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/8/a83bcb58bbb65b1d6797e838ea4f1e5a33dbdc89.png)

## streaming response:

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [April 20, 2025, 3:54am UTC](https://discourse.julialang.org/t/ann-askai-your-direct-ai-support-in-repl/128042/17 "2025-04-20T03:54:58Z")

</div>

For configuration the Scratch.jl or Preferences.jl packages can be useful, e.g. to make `setapi` persistent by storing the provider information in the package’s scratch space.
