Skip to content
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

[Breaking] Renamed MISTRALAI to MISTRAL everywhere #231

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
svilupp marked this conversation as resolved.
Show resolved Hide resolved
- Improved AICode parsing and error handling (eg, capture more REPL prompts, detect parsing errors earlier, parse more code fence types), including the option to remove unsafe code (eg, `Pkg.add("SomePkg")`) with `AICode(msg; skip_unsafe=true, vebose=true)`
- Added new prompt templates: `JuliaRecapTask`, `JuliaRecapCoTTask`, `JuliaExpertTestCode` and updated `JuliaExpertCoTTask` to be more robust against early stopping for smaller OSS models
- Added support for MistralAI API via the MistralOpenAISchema(). All their standard models have been registered, so you should be able to just use `model="mistral-tiny` in your `aigenerate` calls without any further changes. Remember to either provide `api_kwargs.api_key` or ensure you have ENV variable `MISTRALAI_API_KEY` set.
- Added support for MistralAI API via the MistralOpenAISchema(). All their standard models have been registered, so you should be able to just use `model="mistral-tiny` in your `aigenerate` calls without any further changes. Remember to either provide `api_kwargs.api_key` or ensure you have ENV variable `MISTRAL_API_KEY` set.
- Added support for any OpenAI-compatible API via `schema=CustomOpenAISchema()`. All you have to do is to provide your `api_key` and `url` (base URL of the API) in the `api_kwargs` keyword argument. This option is useful if you use [Perplexity.ai](https://docs.perplexity.ai/), [Fireworks.ai](https://app.fireworks.ai/), or any other similar services.

## [0.3.0]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ Under the hood, we use a dedicated schema `MistralOpenAISchema` that leverages m

```julia
const PT = PromptingTools
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRALAI_API_KEY"])
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRAL_API_KEY"])
```
As you can see, we can load your API key either from the ENV or via the Preferences.jl mechanism (see `?PREFERENCES` for more information).

Expand Down Expand Up @@ -750,7 +750,7 @@ Resources:

### Configuring the Environment Variable for API Key

This is a guide for OpenAI's API key, but it works for any other API key you might need (eg, `MISTRALAI_API_KEY` for MistralAI API).
This is a guide for OpenAI's API key, but it works for any other API key you might need (eg, `MISTRAL_API_KEY` for MistralAI API).

To use the OpenAI API with PromptingTools.jl, set your API key as an environment variable:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/readme_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ Under the hood, we use a dedicated schema `MistralOpenAISchema` that leverages m

```julia
const PT = PromptingTools
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRALAI_API_KEY"])
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRAL_API_KEY"])
```
As you can see, we can load your API key either from the ENV or via the Preferences.jl mechanism (see `?PREFERENCES` for more information).

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/working_with_custom_apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Under the hood, we use a dedicated schema `MistralOpenAISchema` that leverages m

```julia
const PT = PromptingTools
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRALAI_API_KEY"])
msg = aigenerate(PT.MistralOpenAISchema(), "Say Hi!"; model="mistral-tiny", api_key=ENV["MISTRAL_API_KEY"])
```
As you can see, we can load your API key either from the ENV or via the Preferences.jl mechanism (see `?PREFERENCES` for more information).

Expand Down
2 changes: 1 addition & 1 deletion docs/src/frequently_asked_questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ msg = aigenerate("What is the meaning of life?"; model="oro1m", no_system_messag

## Configuring the Environment Variable for API Key

This is a guide for OpenAI's API key, but it works for any other API key you might need (eg, `MISTRALAI_API_KEY` for MistralAI API).
This is a guide for OpenAI's API key, but it works for any other API key you might need (eg, `MISTRAL_API_KEY` for MistralAI API).

To use the OpenAI API with PromptingTools.jl, set your API key as an environment variable:

Expand Down
6 changes: 3 additions & 3 deletions src/llm_openai_schema_defs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

Dispatch to the OpenAI.create_chat function, but with the MistralAI API parameters.

It tries to access the `MISTRALAI_API_KEY` ENV variable, but you can also provide it via the `api_key` keyword argument.
It tries to access the `MISTRAL_API_KEY` ENV variable, but you can also provide it via the `api_key` keyword argument.
"""
function OpenAI.create_chat(schema::MistralOpenAISchema,
api_key::AbstractString,
Expand All @@ -138,7 +138,7 @@
url::String = "https://api.mistral.ai/v1",
kwargs...)
# try to override provided api_key because the default is OpenAI key
api_key = isempty(MISTRALAI_API_KEY) ? api_key : MISTRALAI_API_KEY
api_key = isempty(MISTRAL_API_KEY) ? api_key : MISTRAL_API_KEY

Check warning on line 141 in src/llm_openai_schema_defs.jl

View check run for this annotation

Codecov / codecov/patch

src/llm_openai_schema_defs.jl#L141

Added line #L141 was not covered by tests
OpenAI.create_chat(CustomOpenAISchema(), api_key, model, conversation; url, kwargs...)
end
function OpenAI.create_chat(schema::FireworksOpenAISchema,
Expand Down Expand Up @@ -329,7 +329,7 @@
# Build the corresponding provider object
# try to override provided api_key because the default is OpenAI key
provider = CustomProvider(;
api_key = isempty(MISTRALAI_API_KEY) ? api_key : MISTRALAI_API_KEY,
api_key = isempty(MISTRAL_API_KEY) ? api_key : MISTRAL_API_KEY,
base_url = url)
OpenAI.create_embeddings(provider, docs, model; kwargs...)
end
Expand Down
18 changes: 11 additions & 7 deletions src/user_preferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `OPENAI_API_KEY`: The API key for the OpenAI API. See [OpenAI's documentation](https://platform.openai.com/docs/quickstart?context=python) for more information.
- `AZURE_OPENAI_API_KEY`: The API key for the Azure OpenAI API. See [Azure OpenAI's documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) for more information.
- `AZURE_OPENAI_HOST`: The host for the Azure OpenAI API. See [Azure OpenAI's documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) for more information.
- `MISTRALAI_API_KEY`: The API key for the Mistral AI API. See [Mistral AI's documentation](https://docs.mistral.ai/) for more information.
- `MISTRAL_API_KEY`: The API key for the Mistral AI API. See [Mistral AI's documentation](https://docs.mistral.ai/) for more information.
- `COHERE_API_KEY`: The API key for the Cohere API. See [Cohere's documentation](https://docs.cohere.com/docs/the-cohere-platform) for more information.
- `DATABRICKS_API_KEY`: The API key for the Databricks Foundation Model API. See [Databricks' documentation](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html) for more information.
- `DATABRICKS_HOST`: The host for the Databricks API. See [Databricks' documentation](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html) for more information.
Expand Down Expand Up @@ -46,7 +46,7 @@
- `OPENAI_API_KEY`: The API key for the OpenAI API.
- `AZURE_OPENAI_API_KEY`: The API key for the Azure OpenAI API.
- `AZURE_OPENAI_HOST`: The host for the Azure OpenAI API. This is the URL built as `https://<resource-name>.openai.azure.com`.
- `MISTRALAI_API_KEY`: The API key for the Mistral AI API.
- `MISTRAL_API_KEY`: The API key for the Mistral AI API.
- `COHERE_API_KEY`: The API key for the Cohere API.
- `LOCAL_SERVER`: The URL of the local server to use for `ai*` calls. Defaults to `http://localhost:10897/v1`. This server is called when you call `model="local"`
- `DATABRICKS_API_KEY`: The API key for the Databricks Foundation Model API.
Expand All @@ -70,7 +70,7 @@
const PREFERENCES = nothing

"Keys that are allowed to be set via `set_preferences!`"
const ALLOWED_PREFERENCES = ["MISTRALAI_API_KEY",
const ALLOWED_PREFERENCES = ["MISTRAL_API_KEY",
"OPENAI_API_KEY",
"AZURE_OPENAI_API_KEY",
"AZURE_OPENAI_HOST",
Expand Down Expand Up @@ -155,7 +155,7 @@
global OPENAI_API_KEY::String = ""
global AZURE_OPENAI_API_KEY::String = ""
global AZURE_OPENAI_HOST::String = ""
global MISTRALAI_API_KEY::String = ""
global MISTRAL_API_KEY::String = ""
global COHERE_API_KEY::String = ""
global DATABRICKS_API_KEY::String = ""
global DATABRICKS_HOST::String = ""
Expand Down Expand Up @@ -189,9 +189,13 @@
global AZURE_OPENAI_HOST
AZURE_OPENAI_HOST = @load_preference("AZURE_OPENAI_HOST",
default=get(ENV, "AZURE_OPENAI_HOST", ""))
global MISTRALAI_API_KEY
MISTRALAI_API_KEY = @load_preference("MISTRALAI_API_KEY",
default=get(ENV, "MISTRALAI_API_KEY", ""))
global MISTRAL_API_KEY
MISTRAL_API_KEY = @load_preference("MISTRAL_API_KEY",
default=get(ENV, "MISTRAL_API_KEY",
get(ENV, "MISTRALAI_API_KEY", "")))
if !isempty(get(ENV, "MISTRALAI_API_KEY", ""))
@warn "The MISTRALAI_API_KEY environment variable is deprecated. Use MISTRAL_API_KEY instead."

Check warning on line 197 in src/user_preferences.jl

View check run for this annotation

Codecov / codecov/patch

src/user_preferences.jl#L197

Added line #L197 was not covered by tests
end
global COHERE_API_KEY
COHERE_API_KEY = @load_preference("COHERE_API_KEY",
default=get(ENV, "COHERE_API_KEY", ""))
Expand Down
Loading