Julia Community 🟣

Cover image for AIHelpMe.jl: AI-Enhanced Coding Assistance for Julia
Jan Siml
Jan Siml

Posted on • Originally published at siml.earth

AIHelpMe.jl: AI-Enhanced Coding Assistance for Julia

TL;DR

AIHelpMe, a new Julia package, transforms your existing docstrings into an interactive AI-powered guide, offering personalized insights directly from your code's documentation. It's in the early stages and seeks community feedback, promising a unique, low-cost way to interact with your documentation.

Announcing AIHelpMe Pre-Release

Welcome to AIHelpMe, a new Julia package that transforms your detailed docstrings into a rich source of insights. It's not about writing code for you; rather, it's about shining a light on the valuable documentation you and others have already created. Think of it as having a chat with your code's documentation, enhanced by AI's clever touch.

Motivation and Value

Why write great docstrings? AIHelpMe gives you a compelling reason, turning them into an interactive, insightful guide. It's a subtle, yet powerful way to connect your queries with tailored, documentation-driven answers.

There are a few things that set this package apart from generic chatbots:

Direct Access to Your Work: AIHelpMe uniquely utilizes the latest information and modules directly from your laptop, ensuring up-to-date and relevant assistance.

Full Control Over Searches: Tailor your search scope and methods with AIHelpMe, aligning AI insights precisely with your needs.

Contextual Understanding: Go beyond typical chatbot responses; AIHelpMe offers deep insights, revealing the sources behind each answer, so you can continue your research πŸ§ πŸ“š

Getting Started

Simply add AIHelpMe to your Julia environment (not registered yet) and get ready to interact with your code's documentation in a whole new way. Remember, API keys from Cohere and OpenAI are required, but the cost per query is just a tiny fraction of a cent.

using Pkg
Pkg.add("https://github.com/svilupp/AIHelpMe.jl")

using AIHelpMe # automatically some downloads pre-processed documentation

# alias gpt3t sends the query to the latest GPT-3.5 Turbo
aihelp"In Julia, how to create a named tuple from a dictionary? Give me an example"gpt3t
Enter fullscreen mode Exit fullscreen mode
[ Info: Done generating response. Total cost: $0.002
AIMessage("You can use the splatting operator to create a named tuple from a dictionary in Julia. Here's an example:

d = Dict(:a => 1, :b => 2)
nt = (; d...)

Enter fullscreen mode Exit fullscreen mode

You can also ask GPT-4 Turbo to weigh in on your question (notice the "!" in aihelp!"...") when you need deeper insights. For example, you can ask GPT-4 Turbo to explain the constructors for NamedTuple:

aihelp!"What other constructors does NamedTuple have?"gpt4t
Enter fullscreen mode Exit fullscreen mode
[ Info: Tokens: 1023 @ Cost: \$0.0154 in 30.7 seconds
AIMessage("Aside from creating named tuples from pairs or a dictionary, `NamedTuple` offers other constructors as well:

1. **Tuple literal with keys**:

   nt = (a=1, b=2)


2. **Tuple literal with semicolon**:

   nt = (; a=1, b=2)


3. **Using `NamedTuple` type as constructor**:

   nt = NamedTuple{(:a, :b)}((1, 2))


4. **With specified types**:

   nt = NamedTuple{(:a, :b), Tuple{Int, Int}}((1, 2))


5. **From another named tuple or iterable**:
   You can create a new named tuple by splatting an existing named tuple or any iterable of pairs:

   existing_nt = (a=1, b=2)
   nt = NamedTuple((:c => 3, :d => 4, existing_nt...))

   <Author: this example is incorrect. See the next section>


These constructors allow for flexibility in creating `NamedTuple`s programmatically or from existing data structures in Julia.")
Enter fullscreen mode Exit fullscreen mode

Note: Nested Julia code fences had been manually deleted to enable correct parsing on Forem.

LLMs will make mistakes...

... and it's okay! It's usually easy to check & iterate, so the overall solution still ends up being faster / easier.

The original example used the default chat model and had a mistake as pointed out by @oxinabox. We changed to "gpt3t" model for better performance. There was also a change in the prefix and suffix, but that was not required - it's just a habit of how I write prompts/questions to LLMs.

Similarly, the last constructor in the examples from GPT4 Turbo throws an error. We can ask the LLM to fix it:

aihelp"How to fix `nt = NamedTuple((:c => 3, :d => 4, existing_nt...))`. I get error $err"gpt4t
Enter fullscreen mode Exit fullscreen mode
[ Info: Done generating response. Total cost: $0.002
AIMessage("You can fix the code snippet by using the `merge` function properly, to merge the `NamedTuple` with the key-value pairs:

existing_nt = (a=1, b=2)
nt = merge(existing_nt, (c=3,), (d=4,))


This code merges the existing named tuple `existing_nt` with two additional key-value pairs, `(c=3,)` and `(d=4,)`. The result `nt` will be a named tuple including all four key-value pairs.")
Enter fullscreen mode Exit fullscreen mode

Pre-Release Testing

As AIHelpMe is in its early stages, we're eager for community involvement to test and refine its capabilities.

Is it valuable? What are its limitations?

Your feedback is invaluable in shaping this tool’s future, so join us in this innovative journey!


Credit for the title image goes to DALL-E 3.

Thanks to @oxinabox for pointing out that the original example had an error in it!

Top comments (0)