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

Change PROMPT SCHEMA to an Abstract Type #18

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Fixed
- Changed type of global `PROMPT_SCHEMA::AbstractPromptSchema` for an easier switch to local models as a default option

## [0.2.0]

Expand Down
30 changes: 30 additions & 0 deletions docs/src/examples/working_with_ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ model = "openhermes2.5-mistral"
"openhermes2.5-mistral"
````

## Setting Ollama as a default LLM

We need to change the global variables for PROMPT_SCHEMA and default models

```julia
using PromptingTools
const PT = PromptingTools


PT.PROMPT_SCHEMA = PT.OllamaManagedSchema()
PT.MODEL_CHAT = "openhermes2.5-mistral"
# You could do the same for PT.MODEL_EMBEDDING
```

We can also add a nicer alias for the above Mistral model

```julia
PT.MODEL_ALIASES["mistral"]= "openhermes2.5-mistral"
# potentially also yi 34bn if you want a bigger more powerful model
PT.MODEL_ALIASES["yi"]= "yi:34b-chat"
```

Now, we can use the `@ai_str` macro with Ollama models:
```julia
ai"Say hi to me!" # defaults to mistral because we set MODEL_CHAT above
ai"Say hi to me in Chinese!"yi # defaults to yi 34Bn model
```

Note: Another quite popular model is `zephyr:7b-beta`

## Text Generation with aigenerate

### Simple message
Expand Down
2 changes: 1 addition & 1 deletion src/llm_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct OllamaManagedSchema <: AbstractOllamaManagedSchema end
end

## Dispatch into default schema
const PROMPT_SCHEMA = OpenAISchema()
const PROMPT_SCHEMA::AbstractPromptSchema = OpenAISchema()

aigenerate(prompt; kwargs...) = aigenerate(PROMPT_SCHEMA, prompt; kwargs...)
function aiembed(doc_or_docs, args...; kwargs...)
Expand Down
Loading