-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
947 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options | ||
style = "sciml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: ['*'] | ||
pull_request: | ||
workflow_dispatch: | ||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: only if it is a pull request build. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
jobs: | ||
test: | ||
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 60 | ||
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created | ||
actions: write | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.10' | ||
os: | ||
- ubuntu-latest | ||
arch: | ||
- x64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: ${{ matrix.version }} | ||
arch: ${{ matrix.arch }} | ||
- uses: julia-actions/cache@v1 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-runtest@v1 | ||
- uses: julia-actions/julia-processcoverage@v1 | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
files: lcov.info | ||
docs: | ||
name: Documentation | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created | ||
contents: write | ||
statuses: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: '1' | ||
- uses: julia-actions/cache@v1 | ||
- name: Configure doc environment | ||
shell: julia --project=docs --color=yes {0} | ||
run: | | ||
using Pkg | ||
Pkg.develop(PackageSpec(path=pwd())) | ||
Pkg.instantiate() | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-docdeploy@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Run doctests | ||
shell: julia --project=docs --color=yes {0} | ||
run: | | ||
using Documenter: DocMeta, doctest | ||
using AIHelpMe | ||
DocMeta.setdocmeta!(AIHelpMe, :DocTestSetup, :(using AIHelpMe); recursive=true) | ||
doctest(AIHelpMe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CompatHelper | ||
on: | ||
schedule: | ||
- cron: 0 0 1 * * | ||
workflow_dispatch: | ||
jobs: | ||
CompatHelper: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Pkg.add("CompatHelper") | ||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")' | ||
- name: CompatHelper.main() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} | ||
run: julia -e 'using CompatHelper; CompatHelper.main()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: TagBot | ||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
inputs: | ||
lookback: | ||
default: 3 | ||
permissions: | ||
actions: read | ||
checks: read | ||
contents: write | ||
deployments: read | ||
issues: read | ||
discussions: read | ||
packages: read | ||
pages: read | ||
pull-requests: read | ||
repository-projects: read | ||
security-events: read | ||
statuses: read | ||
jobs: | ||
TagBot: | ||
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: JuliaRegistries/TagBot@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ssh: ${{ secrets.DOCUMENTER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
# Files generated by invoking Julia with --code-coverage | ||
*.jl.cov | ||
*.jl.*.cov | ||
|
||
# Files generated by invoking Julia with --track-allocation | ||
*.jl.cov | ||
*.jl.mem | ||
/Manifest.toml | ||
/docs/Manifest.toml | ||
/docs/build/ | ||
|
||
# System-specific files and directories generated by the BinaryProvider and BinDeps packages | ||
# They contain absolute paths specific to the host computer, and so should not be committed | ||
deps/deps.jl | ||
deps/build.log | ||
deps/downloads/ | ||
deps/usr/ | ||
deps/src/ | ||
|
||
# Build artifacts for creating documentation generated by the Documenter package | ||
docs/build/ | ||
docs/site/ | ||
|
||
# File generated by Pkg, the package manager, based on a corresponding Project.toml | ||
# It records a fixed state of all packages used by the project. As such, it should not be | ||
# committed for packages, but should be committed for applications that require a static | ||
# environment. | ||
Manifest.toml | ||
**/.DS_Store | ||
**/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[juliaextra] | ||
git-tree-sha1 = "66e744fbf39bab71c2f63b6877a506fee8fbc9a5" | ||
lazy = true | ||
|
||
[[juliaextra.download]] | ||
sha256 = "61133afa7e06fda133f07164c57190a5b922f8f2a1aa17c3f8a628b5cf752512" | ||
url = "https://github.com/svilupp/AIHelpMeArtifacts/raw/main/artifacts/juliaextra__v1.10.0__ada1.0.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
### Fixed | ||
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
### Fixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 J S | ||
Copyright (c) 2024 J S <[email protected]> and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name = "AIHelpMe" | ||
uuid = "01402e1f-dc83-4213-a98b-42887d758baa" | ||
authors = ["J S <[email protected]> and contributors"] | ||
version = "0.0.1-DEV" | ||
|
||
[deps] | ||
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
Preferences = "21216c6a-2e73-6563-6e65-726566657250" | ||
PromptingTools = "670122d1-24a8-4d70-bfce-740807c42192" | ||
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | ||
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" | ||
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
|
||
[compat] | ||
Aqua = "0.7" | ||
HTTP = "1" | ||
JSON3 = "1" | ||
LazyArtifacts = "<0.0.1, 1" | ||
LinearAlgebra = "<0.0.1, 1" | ||
Preferences = "1" | ||
PromptingTools = "0.9" | ||
REPL = "1" | ||
SHA = "0.7" | ||
Serialization = "<0.0.1, 1" | ||
SparseArrays = "<0.0.1, 1" | ||
Test = "<0.0.1, 1" | ||
julia = "1.10" | ||
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" | ||
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Aqua", "HTTP", "JSON3", "Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,127 @@ | ||
# AIHelpers | ||
# AIHelpMe [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://svilupp.github.io/AIHelpMe.jl/stable/) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://svilupp.github.io/AIHelpMe.jl/dev/) [![Build Status](https://github.com/svilupp/AIHelpMe.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/svilupp/AIHelpMe.jl/actions/workflows/CI.yml?query=branch%3Amain) [![Coverage](https://codecov.io/gh/svilupp/AIHelpMe.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/svilupp/AIHelpMe.jl) [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) | ||
|
||
# AIHelpMe: Enhanced Coding Assistance for Julia | ||
|
||
AIHelpMe harnesses the power of Julia's extensive documentation and advanced AI models to provide tailored coding guidance. By integrating with PromptingTools.jl, it offers a unique, AI-assisted approach to answering your coding queries directly in Julia's environment. | ||
|
||
Note: This is only a proof-of-concept. If there is enough interest, we will fine-tune the RAG pipeline for better performance. | ||
|
||
## Features | ||
|
||
- **AI-Powered Assistance**: Get context-aware answers to your coding questions. | ||
- **Easy-to-Use Interface**: Simple function and macro to input your questions. | ||
- **Flexible Querying**: Use different AI models for varied insights and performance versus cost trade-offs. | ||
- **Cost-Effective**: Download pre-embedded documentation to save on API calls. | ||
|
||
## Installation | ||
|
||
To install AIHelpMe, use the Julia package manager and the address of the repository (it's not yet registered): | ||
|
||
```julia | ||
using Pkg | ||
Pkg.add("https://github.com/svilupp/AIHelpMe.jl") | ||
``` | ||
|
||
**Prerequisites:** | ||
|
||
- Julia (version 1.10 or later). | ||
- Internet connection for API access. | ||
- OpenAI and Cohere API keys (recommended for optimal performance). See [How to Obtain API Keys](#how-to-obtain-api-keys). | ||
|
||
All setup should take less than 5 minutes! | ||
|
||
## Quick Start Guide | ||
|
||
1. **Basic Usage**: | ||
```julia | ||
using AIHelpMe | ||
aihelp("How do I implement quicksort in Julia?") | ||
``` | ||
|
||
```plaintext | ||
[ Info: Done generating response. Total cost: $0.001 | ||
AIMessage("To implement quicksort in Julia, you can use the `sort` function with the `alg=QuickSort` argument.") | ||
``` | ||
|
||
2. **`aihelp` Macro**: | ||
```julia | ||
aihelp"how to implement quicksort in Julia?" | ||
``` | ||
|
||
3. **Follow-up Questions**: | ||
```julia | ||
aihelp!"Can you elaborate on the `sort` function?" | ||
``` | ||
Note: The `!` is required for follow-up questions. | ||
`aihelp!` does not add new context/more information - to do that, you need to ask a new question. | ||
|
||
4. **Pick stronger models**: | ||
Eg, "gpt4t" is an alias for GPT-4 Turbo: | ||
```julia | ||
aihelp"Elaborate on the `sort` function and quicksort algorithm"gpt4t | ||
``` | ||
```plaintext | ||
[ Info: Done generating response. Total cost: $0.002 --> | ||
AIMessage("The `sort` function in programming languages, including Julia.... continues for a while! | ||
``` | ||
|
||
## How to Obtain API Keys | ||
|
||
### OpenAI API Key: | ||
1. Visit [OpenAI's API portal](https://openai.com/api/). | ||
2. Sign up or log in. | ||
3. Follow the instructions to generate an API key. | ||
|
||
### Cohere API Key: | ||
1. Go to [Cohere's platform](https://cohere.ai/). | ||
2. Create an account. | ||
3. Navigate to the API section to get your key. | ||
|
||
## Usage | ||
|
||
**Formulating Questions**: | ||
- Be clear and specific for the best results. | ||
|
||
**Example Queries**: | ||
- Simple question: `aihelp"What is a DataFrame in Julia?"` | ||
- Using a model: `aihelp"best practices for error handling in Julia"gpt4t` | ||
- Follow-up: `aihelp!"Could you provide an example?"` | ||
- Debug errors (use `err` REPL variable): | ||
```julia | ||
## define mock function to trigger method error | ||
f(x::Int) = x^2 | ||
f(Int8(2)) | ||
# we get: ERROR: MethodError: no method matching f(::Int8) | ||
# Help is here: | ||
aihelp"What does this error mean? $err" # Note the $err to interpolate the stacktrace | ||
``` | ||
|
||
```plaintext | ||
[ Info: Done generating response. Total cost: $0.003 | ||
AIMessage("The error message "MethodError: no method matching f(::Int8)" means that there is no method defined for function `f` that accepts an argument of type `Int8`. The error message also provides the closest candidate methods that were found, which are `f(::Any, !Matched::Any)` and `f(!Matched::Int64)` in the specified file `embed_all.jl` at lines 45 and 61, respectively.") | ||
``` | ||
|
||
## How it works | ||
|
||
AIHelpMe leverages [PromptingTools.jl](https://github.com/svilupp/PromptingTools.jl) to communicate with the AI models. | ||
|
||
We apply a Retrieval Augment Generation (RAG) pattern, ie, | ||
- we pre-process all available documentation (and "embed it" to convert text snippets into numbers) | ||
- when a question is asked, we look up the most relevant documentation snippets | ||
- we feed the question and the documentation snippets to the AI model | ||
- the AI model generates the answer | ||
|
||
This ensures that the answers are not only based on general AI knowledge but are also specifically tailored to Julia's ecosystem and best practices. | ||
|
||
## FAQs | ||
|
||
**Q: How accurate are the answers?** | ||
A: Like any other Generative AI answers, ie, it depends and you should always double-check. | ||
|
||
**Q: Can I use it without the internet?** | ||
A: Not at the moment. It might be possible in the future, as PromptingTools.jl supports local LLMs. | ||
|
||
**Q: Why do we need Cohere API Key?** | ||
A: Cohere's API is used to re-rank the best matching snippets from the documentation. It's free to use in limited quantities (ie, ~thousand requests per month), which should be enough for most users. Re-ranking improves the quality and accuracy of the answers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[deps] | ||
AIHelpMe = "01402e1f-dc83-4213-a98b-42887d758baa" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using AIHelpMe | ||
using Documenter | ||
|
||
DocMeta.setdocmeta!(AIHelpMe, :DocTestSetup, :(using AIHelpMe); recursive=true) | ||
|
||
makedocs(; | ||
modules=[AIHelpMe], | ||
authors="J S <[email protected]> and contributors", | ||
sitename="AIHelpMe.jl", | ||
format=Documenter.HTML(; | ||
canonical="https://svilupp.github.io/AIHelpMe.jl", | ||
edit_link="main", | ||
assets=String[], | ||
), | ||
pages=[ | ||
"Home" => "index.md", | ||
], | ||
) | ||
|
||
deploydocs(; | ||
repo="github.com/svilupp/AIHelpMe.jl", | ||
devbranch="main", | ||
) |
Oops, something went wrong.