diff --git a/docs/src/assets/makie2.png b/docs/src/assets/makie2.png new file mode 100644 index 0000000..2cdf4aa Binary files /dev/null and b/docs/src/assets/makie2.png differ diff --git a/docs/src/assets/tidier1.png b/docs/src/assets/tidier1.png new file mode 100644 index 0000000..df76f5f Binary files /dev/null and b/docs/src/assets/tidier1.png differ diff --git a/docs/src/assets/tidier2.png b/docs/src/assets/tidier2.png new file mode 100644 index 0000000..4bd4cdd Binary files /dev/null and b/docs/src/assets/tidier2.png differ diff --git a/docs/src/introduction.md b/docs/src/introduction.md index b5eb9fe..143f266 100644 --- a/docs/src/introduction.md +++ b/docs/src/introduction.md @@ -51,89 +51,100 @@ 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.015 - AIMessage("To implement quicksort in Julia, you can use the `sort` function with the `alg=QuickSort` argument.") +1) **Basic Usage**: +```julia +using AIHelpMe +aihelp("How do I implement quicksort in Julia?") ``` - Note: As a default, we load only the Julia documentation and docstrings for standard libraries. The default model used is GPT-4 Turbo. + ```plaintext +[ Info: Done generating response. Total cost: \$0.015 +AIMessage("To implement quicksort in Julia, you can use the `sort` function with the `alg=QuickSort` argument.") +``` - You can pretty-print the answer using `pprint` if you return the full RAGResult (`return_all=true`): - ```julia - using AIHelpMe: pprint +Note: As a default, we load only the Julia documentation and docstrings for standard libraries. The default model used is GPT-4 Turbo. - result = aihelp("How do I implement quicksort in Julia?", return_all=true) - pprint(result) - ``` +You can pretty-print the answer using `pprint` if you return the full RAGResult (`return_all=true`). If displayed in REPL, it will use color highlights as well (magenta color = text not from the "context"). +```julia +using AIHelpMe: pprint - ```plaintext - -------------------- - QUESTION(s) - -------------------- - - How do I implement quicksort in Julia? - - -------------------- - ANSWER - -------------------- - To implement quicksort in Julia, you can use the [5,1.0]`sort`[1,1.0] function with the [1,1.0]`alg=QuickSort`[1,1.0] argument.[2,1.0] - - -------------------- - SOURCES - -------------------- - 1. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions - 2. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions - 3. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Algorithms - 4. SortingAlgorithms::/README.md::0::SortingAlgorithms - 5. AIHelpMe::/README.md::0::AIHelpMe - ``` +result = aihelp("How do I implement quicksort in Julia?", return_all=true) +pprint(result) +``` - Note: You can see the model cheated because it can see this very documentation... +```plaintext +-------------------- +QUESTION(s) +-------------------- +- How do I implement quicksort in Julia? + +-------------------- +ANSWER +-------------------- +To implement quicksort in Julia, you can use the [5,1.0]`sort`[1,1.0] function with the [1,1.0]`alg=QuickSort`[1,1.0] argument.[2,1.0] + +-------------------- +SOURCES +-------------------- +1. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions +2. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Functions +3. https://docs.julialang.org/en/v1.10.2/base/sort/index.html::Sorting and Related Functions/Sorting Algorithms +4. SortingAlgorithms::/README.md::0::SortingAlgorithms +5. AIHelpMe::/README.md::0::AIHelpMe +``` -2. **`aihelp` Macro**: - ```julia - aihelp"how to implement quicksort in Julia?" - ``` +Note: You can see the model cheated because it can see this very documentation... -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. +Note 2: The square brackets represent the corresponding source and the strength of association (1.0 is the highest), eg, `[1,1.0]` indicates high confidence in the sentences having high overlap with the chunk in source #1. -4. **Pick faster models**: - Eg, for simple questions, GPT 3.5 might be enough, so use the alias "gpt3t": - ```julia - aihelp"Elaborate on the `sort` function and quicksort algorithm"gpt3t - ``` +2) **`aihelp` Macro**: +```julia +aihelp"how to implement quicksort in Julia?" +``` - ```plaintext - [ Info: Done generating response. Total cost: \$0.002 --> - AIMessage("The `sort` function in programming languages, including Julia.... continues for a while! - ``` +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 faster models**: +Eg, for simple questions, GPT 3.5 might be enough, so use the alias "gpt3t": +```julia +aihelp"Elaborate on the `sort` function and quicksort algorithm"gpt3t +``` + +```plaintext +[ Info: Done generating response. Total cost: \$0.002 --> +AIMessage("The `sort` function in programming languages, including Julia.... continues for a while! +``` 5. **Debugging**: - How did you come up with that answer? Check the "context" provided to the AI model (ie, the documentation snippets that were used to generate the answer): - ```julia - using AIHelpMe: pprint, last_result - pprint(last_result()) - # Output: Pretty-printed Question + Context + Answer with color highlights - ``` +How did you come up with that answer? Check the "context" provided to the AI model (ie, the documentation snippets that were used to generate the answer): +```julia +using AIHelpMe: pprint, last_result +pprint(last_result()) +# Output: Pretty-printed Question + Context + Answer with color highlights +``` - The color highlights show you which words were NOT supported by the provided context (magenta = completely new, blue = partially new). - It's an intuitive way to see which function names or variables are made up versus which ones were in the context. +Examples of the highlighted output: - You can change the kwargs of `pprint` to hide the annotations or potentially even show the underlying context (snippets from the documentation): +![Highlighted output #1](assets/tidier2.png) + +![Highlighted output #2](assets/makie2.png) + +The color highlights show you which words were NOT supported by the provided context (magenta = completely new, blue = partially new). +It's an intuitive way to see which function names or variables are made up versus which ones were in the context. + +The square brackets represent the corresponding source and the strength of association (1.0 is the highest), eg, `[1,1.0]` indicates high confidence in the sentences having high overlap with the chunk in source #1. + +You can change the kwargs of `pprint` to hide the annotations or potentially even show the underlying context (snippets from the documentation): + +```julia +pprint(last_result(); add_context = true, add_scores = false) +``` - ```julia - pprint(last_result(); add_context = true, add_scores = false) - ``` > [!TIP] > Your results will significantly improve if you enable re-ranking of the context to be provided to the model (eg, `aihelp(..., rerank=true)`) or change pipeline to `update_pipeline!(:silver)`. It requires setting up Cohere API key but it's free for community use.