Skip to content

Improve parser support #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ac751a9
Revert "update deps"
svilupp Feb 26, 2024
423faef
remove GoogleGenAI (#83)
svilupp Feb 26, 2024
320b9b7
fix docs
svilupp Feb 27, 2024
18e1b71
Templating utilities (#84)
svilupp Feb 28, 2024
5200985
update docs + version (#85)
svilupp Feb 29, 2024
846aa37
Add image generation with DALL-E 3 (#86)
svilupp Mar 1, 2024
37fa1f4
update changelog (#87)
svilupp Mar 1, 2024
b8e888d
Update docs to Vitepress (#88)
svilupp Mar 1, 2024
4d26a4f
update docs/make.jl
svilupp Mar 1, 2024
a581d55
fix CI
svilupp Mar 1, 2024
83cefd9
Fix CI nr2
svilupp Mar 1, 2024
db91e60
Fix CI nr3
svilupp Mar 1, 2024
2d45b8e
Fix CI nr4
svilupp Mar 1, 2024
a84f230
Fix CI nr5
svilupp Mar 1, 2024
81198f5
Fix CI nr.6
svilupp Mar 1, 2024
0d6954e
Fix CI nr7
svilupp Mar 1, 2024
37603a4
Fix CI nr8
svilupp Mar 1, 2024
e97f571
Update README.md
svilupp Mar 2, 2024
cd681c8
Add support annotations (#90)
svilupp Mar 7, 2024
b3756b2
Update Documentation (#91)
svilupp Mar 9, 2024
94911cf
Add Prompt Templates to the Docs (#92)
svilupp Mar 9, 2024
846d069
fix typo on set_preferences! examples, fixes #93 (#94)
ceferisbarov Mar 17, 2024
3b30d66
RAG Interface Rewrite (#95)
svilupp Mar 20, 2024
2509e0b
Update Google AI tutorial (#103)
svilupp Mar 21, 2024
e347081
Allow HTMLStyler in node annotations (#105)
svilupp Mar 21, 2024
96357ce
update diagram in the docs (#108)
svilupp Mar 22, 2024
ce4a2ed
A little README.md correction (#107)
Muhammad-saad-2000 Mar 24, 2024
7cab975
Add support for Claude API (#109)
svilupp Mar 25, 2024
5146a95
Enable GoogleGenAI extension (#111)
svilupp Mar 26, 2024
4925b70
Update CHANGELOG.md (#104)
svilupp Mar 26, 2024
5d9d132
Add ShareGPT template (#113)
svilupp Mar 26, 2024
82d87db
Increase compat for GoogleGenAI v0.3
svilupp Mar 26, 2024
069b6f6
Update html printing (#115)
svilupp Mar 27, 2024
7eb32b1
Fix bug in `print_html` (#116)
svilupp Mar 27, 2024
ee3459d
Add Binary embeddings to RAGTools (#117)
svilupp Apr 3, 2024
024562d
Add data extraction for Anthropic models (#122)
svilupp Apr 5, 2024
fc0073e
Register mistral tiny (#123)
svilupp Apr 6, 2024
84f68cc
Add new GPT-4 Turbo (#124)
svilupp Apr 10, 2024
5054f4c
Update code fences in the hero cards in the docs
cpfiffer Apr 11, 2024
49f3f5b
Update Docs Hero page
svilupp Apr 11, 2024
eb94d1a
Add TraceMessage for observability (#133)
svilupp Apr 15, 2024
5f61eac
[FR] Add support for structured extraction with Ollama models
cpfiffer May 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,30 @@ jobs:
permissions:
contents: write
statuses: write
pages: write
id-token: write
actions: write
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node # This is still useful because it caches the node_modules so we don't constantly re-install. You don't technically need this, though.
uses: actions/setup-node@v3
with:
version: '1'
- name: Configure doc environment
run: |
julia --project=docs/ -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
node-version: 20
cache: npm # or pnpm / yarn
cache-dependency-path: 'docs/package-lock.json' # this should be a package-lock.json file
- name: Setup Julia
uses: julia-actions/setup-julia@v1
- name: Pull Julia cache
uses: julia-actions/cache@v1
- name: Install documentation dependencies
run: julia --project=docs -e 'using Pkg; pkg"dev ."; Pkg.instantiate(); Pkg.precompile(); Pkg.status()'
- name: Instantiate NPM
run: cd docs/; npm i; cd ..
#- name: Creating new mds from src
- name: Build and deploy docs
uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using PromptingTools
DocMeta.setdocmeta!(PromptingTools, :DocTestSetup, :(using PromptingTools); recursive=true)
doctest(PromptingTools)'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
GKSwstype: "100" # for Plots.jl plots (if you have them)
JULIA_DEBUG: "Documenter"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
/docs/build/

**/.DS_Store
**/.vscode
**/.vscode

# exclude scratch files
**/_*
75 changes: 73 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,84 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Added a few new open-weights models hosted by Fireworks.ai to the registry (DBRX Instruct, Mixtral 8x22b Instruct, Qwen 72b). If you're curious about how well they work, try them!
- Added basic support for observability downstream. Created custom callback infrastructure with `initialize_tracer` and `finalize_tracer` and dedicated types are `TracerMessage` and `TracerMessageLike`. See `?TracerMessage` for more information and the corresponding `aigenerate` docstring.

### Updated
- Changed default model for `RAGTools.CohereReranker` to "cohere-rerank-english-v3.0".

### Fixed

## [0.19.0]

### Added
- [BREAKING CHANGE] The default GPT-4 Turbo model alias ("gpt4t") now points to the official GPT-4 Turbo endpoint ("gpt-4-turbo").
- Adds references to `mistral-tiny` (7bn parameter model from MistralAI) to the model registry for completeness.
- Adds the new GPT-4 Turbo model (`"gpt-4-turbo-2024-04-09"`), but you can simply use alias `"gpt4t"` to access it.

## [0.18.0]

### Added
- Adds support for binary embeddings in RAGTools (dispatch type for `find_closest` is `finder=BinaryCosineSimilarity()`), but you can also just convert the embeddings to binary yourself (always choose `Matrix{Bool}` for speed, not `BitMatrix`) and use without any changes (very little performance difference at the moment).
- Added Ollama embedding models to the model registry ("nomic-embed-text", "mxbai-embed-large") and versioned MistralAI models.
- Added template for data extraction with Chain-of-thought reasoning: `:ExtractDataCoTXML`.
- Added data extraction support for Anthropic models (Claude 3) with `aiextract`. Try it with Claude-3 Haiku (`model="claudeh"`) and Chain-of-though template (`:ExtractDataCoTXML`). See `?aiextract` for more information and check Anthropic's [recommended practices](https://docs.anthropic.com/claude/docs/tool-use).

## [0.17.1]

### Fixed
- Fixed a bug in `print_html` where the custom kwargs were not being passed to the `HTML` constructor.

## [0.17.0]

### Added
- Added support for `aigenerate` with Anthropic API. Preset model aliases are `claudeo`, `claudes`, and `claudeh`, for Claude 3 Opus, Sonnet, and Haiku, respectively.
- Enabled the GoogleGenAI extension since `GoogleGenAI.jl` is now officially registered. You can use `aigenerate` by setting the model to `gemini` and providing the `GOOGLE_API_KEY` environment variable.
- Added utilities to make preparation of finetuning datasets easier. You can now export your conversations in JSONL format with ShareGPT formatting (eg, for Axolotl). See `?PT.save_conversations` for more information.
- Added `print_html` utility for RAGTools module to print HTML-styled RAG answer annotations for web applications (eg, Genie.jl). See `?PromptingTools.Experimental.RAGTools.print_html` for more information and examples.

## [0.16.1]

### Fixed
- Fixed a bug where `set_node_style!` was not accepting any Stylers except for the vanilla `Styler`.

## [0.16.0]

### Added
- Added pretty-printing via `PT.pprint` that does NOT depend on Markdown and splits text to adjust to the width of the output terminal.
It is useful in notebooks to add new lines.
- Added support annotations for RAGTools (see `?RAGTools.Experimental.annotate_support` for more information) to highlight which parts of the generated answer come from the provided context versus the model's knowledge base. It's useful for transparency and debugging, especially in the context of AI-generated content. You can experience it if you run the output of `airag` through pretty printing (`PT.pprint`).
- Added utility `distance_longest_common_subsequence` to find the normalized distance between two strings (or a vector of strings). Always returns a number between 0-1, where 0 means the strings are identical and 1 means they are completely different. It's useful for comparing the similarity between the context provided to the model and the generated answer.
- Added a new documentation section "Extra Tools" to highlight key functionality in various modules, eg, the available text utilities, which were previously hard to discover.
- Extended documentation FAQ with tips on tackling rate limits and other common issues with OpenAI API.
- Extended documentation with all available prompt templates. See section "Prompt Templates" in the documentation.
- Added new RAG interface underneath `airag` in `PromptingTools.RAGTools.Experimental`. Each step now has a dedicated function and a type that can be customized to achieve arbitrary logic (via defining methods for your own types). `airag` is split into two main steps: `retrieve` and `generate!`. You can use them separately or together. See `?airag` for more information.

### Updated
- Renamed `split_by_length` text splitter to `recursive_splitter` to make it easier to discover and understand its purpose. `split_by_length` is still available as a deprecated alias.

### Fixed
- Fixed a bug where `LOCAL_SERVER` default value was not getting picked up. Now, it defaults to `http://localhost:10897/v1` if not set in the preferences, which is the address of the OpenAI-compatible server started by Llama.jl.
- Fixed a bug in multi-line code annotation, which was assigning too optimistic scores to the generated code. Now the score of the chunk is the length-weighted score of the "top" source chunk divided by the full length of score tokens (much more robust and demanding).

## [0.15.0]

### Added
- Added experimental support for image generation with OpenAI DALL-E models, eg, `msg = aiimage("A white cat on a car")`. See `?aiimage` for more details.

## [0.14.0]

### Added
- Added a new documentation section "How it works" to explain the inner workings of the package. It's a work in progress, but it should give you a good idea of what's happening under the hood.
- Improved template loading, so if you load your custom templates once with `load_templates!("my/template/folder)`, it will remember your folder for all future re-loads.
- Added convenience function `create_template` to create templates on the fly without having to deal with `PT.UserMessage` etc. If you specify the keyword argument `load_as = "MyName"`, the template will be immediately loaded to the template registry. See `?create_template` for more information and examples.

### Fixed

## [0.13.0]

### Added
- Added initial support for Google Gemini models for `aigenerate` (requires environment variable `GOOGLE_API_KEY` and package [GoogleGenAI.jl](https://github.com/tylerjthomas9/GoogleGenAI.jl) to be loaded). It must be imported explicitly because it's not registered yet.
- Added initial support for Google Gemini models for `aigenerate` (requires environment variable `GOOGLE_API_KEY` and package [GoogleGenAI.jl](https://github.com/tylerjthomas9/GoogleGenAI.jl) to be loaded). It must be added explicitly as it is not yet registered.
- Added a utility to compare any two string sequences (and other iterators)`length_longest_common_subsequence`. It can be used to fuzzy match strings (eg, detecting context/sources in an AI-generated response or fuzzy matching AI response to some preset categories). See the docstring for more information `?length_longest_common_subsequence`.
- Rewrite of `aiclassify` to classify into an arbitrary list of categories (including with descriptions). It's a quick and easy option for "routing" and similar use cases, as it exploits the logit bias trick and outputs only 1 token. Currently, only `OpenAISchema` is supported. See `?aiclassify` for more information.
- Initial support for multiple completions in one request for OpenAI-compatible API servers. Set via API kwarg `n=5` and it will request 5 completions in one request, saving the network communication time and paying the prompt tokens only once. It's useful for majority voting, diversity, or challenging agentic workflows.
Expand Down Expand Up @@ -156,4 +227,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `aiextract` function to extract structured information from text quickly and easily. See `?aiextract` for more information.
- Add `aiscan` for image scanning (ie, image comprehension tasks). You can transcribe screenshots or reason over images as if they were text. Images can be provided either as a local file (`image_path`) or as an url (`image_url`). See `?aiscan` for more information.
- Add support for [Ollama.ai](https://ollama.ai/)'s local models. Only `aigenerate` and `aiembed` functions are supported at the moment.
- Add a few non-coding templates, eg, verbatim analysis (see `aitemplates("survey")`) and meeting summarization (see `aitemplates("meeting")`), and supporting utilities (non-exported): `split_by_length` and `replace_words` to make it easy to work with smaller open source models.
- Add a few non-coding templates, eg, verbatim analysis (see `aitemplates("survey")`) and meeting summarization (see `aitemplates("meeting")`), and supporting utilities (non-exported): `split_by_length` and `replace_words` to make it easy to work with smaller open source models.
7 changes: 6 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name = "PromptingTools"
uuid = "670122d1-24a8-4d70-bfce-740807c42192"
authors = ["J S @svilupp and contributors"]
version = "0.13.0"
version = "0.19.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand All @@ -17,18 +18,22 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[weakdeps]
GoogleGenAI = "903d41d1-eaca-47dd-943b-fee3930375ab"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[extensions]
GoogleGenAIPromptingToolsExt = ["GoogleGenAI"]
MarkdownPromptingToolsExt = ["Markdown"]
RAGToolsExperimentalExt = ["SparseArrays", "LinearAlgebra"]

[compat]
AbstractTrees = "0.4"
Aqua = "0.7"
Base64 = "<0.0.1, 1"
Dates = "<0.0.1, 1"
GoogleGenAI = "0.3"
HTTP = "1"
JSON3 = "1"
LinearAlgebra = "<0.0.1, 1"
Expand Down
Loading