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

update default models gpt4o #470

Merged
merged 3 commits into from
Oct 18, 2024
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
2 changes: 1 addition & 1 deletion packages/grafana-llm-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const MyComponent = (): JSX.Element => {
// Stream the completions. Each element is the next stream chunk.
const stream = llms.openai
.streamChatCompletions({
model: 'gpt-3.5-turbo',
model: llms.openai.Model.BASE,
messages: [
{ role: 'system', content: 'You are a cynical assistant.' },
{ role: 'user', content: message },
Expand Down
4 changes: 2 additions & 2 deletions packages/grafana-llm-app/llmclient/llmclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const (
type Model string

const (
// ModelBase is the base model, for efficient and high-throughput tasks. OpenAI default: gpt-3.5-turbo
// ModelBase is the base model, for efficient and high-throughput tasks. OpenAI default: gpt-4o-mini
ModelBase = "base"
// ModelLarge is the large model, for more advanced tasks with longer context windows. OpenAI default: gpt-4-turbo
// ModelLarge is the large model, for more advanced tasks with longer context windows. OpenAI default: gpt-4o
ModelLarge = "large"
)

Expand Down
8 changes: 4 additions & 4 deletions packages/grafana-llm-app/pkg/plugin/llm_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (
// compatability, or the new abstract model names.
func ModelFromString(m string) (Model, error) {
switch {
case m == ModelLarge || strings.HasPrefix(m, "gpt-4"):
case m == ModelLarge || (strings.HasPrefix(m, "gpt-4") && !strings.Contains(m, "-mini")):
return ModelLarge, nil
case m == ModelBase || strings.HasPrefix(m, "gpt-3.5"):
case m == ModelBase || strings.HasPrefix(m, "gpt-3.5") || strings.Contains(m, "-mini"):
return ModelBase, nil
}
// TODO: Give users the ability to specify a default model abstraction in settings, and use that here.
Expand All @@ -54,9 +54,9 @@ func (m Model) toOpenAI(modelSettings *ModelSettings) string {
if modelSettings == nil || len(modelSettings.Mapping) == 0 {
switch m {
case ModelBase:
return "gpt-3.5-turbo"
return "gpt-4o-mini"
case ModelLarge:
return "gpt-4-turbo"
return "gpt-4o"
}
panic(fmt.Sprintf("unrecognized model: %s", m))
}
Expand Down
15 changes: 15 additions & 0 deletions packages/grafana-llm-app/pkg/plugin/llm_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func TestModelFromString(t *testing.T) {
expected: ModelBase,
wantErr: false,
},
{
input: "gpt-4o-mini",
expected: ModelBase,
wantErr: false,
},
{
input: "gpt-4o-mini-2024-07-18",
expected: ModelBase,
wantErr: false,
},
{
input: "gpt-4-turbo",
expected: ModelLarge,
Expand All @@ -64,6 +74,11 @@ func TestModelFromString(t *testing.T) {
expected: ModelLarge,
wantErr: false,
},
{
input: "gpt-4o",
expected: ModelLarge,
wantErr: false,
},
{
input: "gpt-4-32k-0613",
expected: ModelLarge,
Expand Down
4 changes: 2 additions & 2 deletions packages/grafana-llm-app/pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func (c ModelSettings) getModel(model Model) string {
var DEFAULT_MODEL_SETTINGS = &ModelSettings{
Default: ModelBase,
Mapping: map[Model]string{
ModelBase: "gpt-3.5-turbo",
ModelLarge: "gpt-4-turbo",
ModelBase: "gpt-4o-mini",
ModelLarge: "gpt-4o",
},
}

Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-llm-app/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const MyComponent = (): JSX.Element => {
// Stream the completions. Each element is the next stream chunk.
const stream = llms.openai
.streamChatCompletions({
model: 'gpt-3.5-turbo',
model: llms.openai.Model.BASE
messages: [
{ role: 'system', content: 'You are a cynical assistant.' },
{ role: 'user', content: message },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const DEFAULT_MODEL_ID = openai.Model.BASE;
const MODEL_MAPPING_CONFIG: ModelMappingConfig[] = [
{
id: openai.Model.BASE,
name: 'gpt-3.5-turbo',
name: 'gpt-4o-mini',
label: 'Base',
description: 'A fast and cost-effective model for efficient, high-throughput tasks.',
},
{
id: openai.Model.LARGE,
name: 'gpt-4-turbo',
name: 'gpt-4o',
label: 'Large',
description: 'A larger, higher cost model for more advanced tasks with longer context windows.',
},
Expand Down
Loading