Skip to content

Commit

Permalink
Let the LLM models have meta information such as pricing and human-re…
Browse files Browse the repository at this point in the history
…adable names

Part of #296
  • Loading branch information
ruiAzevedo19 committed Aug 6, 2024
1 parent a4dfe3e commit 88d69f0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
20 changes: 20 additions & 0 deletions model/llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type Model struct {

// queryAttempts holds the number of query attempts to perform when a model request errors in the process of solving a task.
queryAttempts uint

// metaInformation holds a model meta information.
metaInformation *model.MetaInformation
}

// NewModel returns an LLM model corresponding to the given identifier which is queried via the given provider.
Expand All @@ -43,6 +46,23 @@ func NewModel(provider provider.Query, modelIdentifier string) *Model {
}
}

// NewModelWithMetaInformation returns a LLM model with meta information corresponding to the given identifier which is queried via the given provider.
func NewModelWithMetaInformation(provider provider.Query, modelIdentifier string, metaInformation *model.MetaInformation) *Model {
return &Model{
provider: provider,
model: modelIdentifier,

queryAttempts: 1,

metaInformation: metaInformation,
}
}

// MetaInformation returns the meta information of a model.
func (m *Model) MetaInformation() (metaInformation *model.MetaInformation) {
return m.metaInformation
}

// llmSourceFilePromptContext is the context for template for generating an LLM test generation prompt.
type llmSourceFilePromptContext struct {
// Language holds the programming language name.
Expand Down
3 changes: 3 additions & 0 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
type Model interface {
// ID returns the unique ID of this model.
ID() (id string)

// MetaInformation returns the meta information of a model.
MetaInformation() *MetaInformation
}

// MetaInformation holds a model.
Expand Down
5 changes: 5 additions & 0 deletions model/symflower/symflower.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (m *Model) ID() (id string) {
return "symflower" + provider.ProviderModelSeparator + "symbolic-execution"
}

// MetaInformation returns the meta information of a model.
func (m *Model) MetaInformation() (metaInformation *model.MetaInformation) {
return nil
}

var _ model.CapabilityWriteTests = (*Model)(nil)

// generateTestsForFile generates test files for the given implementation file in a repository.
Expand Down
25 changes: 24 additions & 1 deletion model/testing/Model_mock_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions provider/openrouter/openrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *Provider) ID() (id string) {

// ModelsList holds a list of models.
type ModelsList struct {
Models []model.MetaInformation `json:"data"`
Models []*model.MetaInformation `json:"data"`
}

// Models returns which models are available to be queried via this provider.
Expand All @@ -69,7 +69,8 @@ func (p *Provider) Models() (models []model.Model, err error) {

models = make([]model.Model, len(responseModels.Models))
for i, model := range responseModels.Models {
models[i] = llm.NewModel(p, p.ID()+provider.ProviderModelSeparator+model.ID)
model.ID = p.ID() + provider.ProviderModelSeparator + model.ID
models[i] = llm.NewModelWithMetaInformation(p, p.ID()+provider.ProviderModelSeparator+model.ID, model)
}

return models, nil
Expand Down

0 comments on commit 88d69f0

Please sign in to comment.