From 2d047937764f6dfbfcd77537c85ea1158039c7f2 Mon Sep 17 00:00:00 2001 From: Rui Azevedo Date: Wed, 31 Jul 2024 10:46:49 +0100 Subject: [PATCH] refactor, Move the model's meta information structures from the provider to the model package, since it is model related Part of #296 --- model/model.go | 23 +++++++++++++++++++++++ provider/openrouter/openrouter.go | 25 +------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/model/model.go b/model/model.go index 5d002ffa..8d43f3b4 100644 --- a/model/model.go +++ b/model/model.go @@ -11,6 +11,29 @@ type Model interface { ID() (id string) } +// MetaInformation holds a model. +type MetaInformation struct { + // ID holds the model id. + ID string `json:"id"` + // Name holds the model name. + Name string `json:"name"` + + // Pricing holds the pricing information of a model. + Pricing Pricing `json:"pricing"` +} + +// Pricing holds the pricing information of a model. +type Pricing struct { + // Prompt holds the price for a prompt in dollars per token. + Prompt float64 `json:"prompt,string"` + // Completion holds the price for a completion in dollars per token. + Completion float64 `json:"completion,string"` + // Request holds the price for a request in dollars per request. + Request float64 `json:"request,string"` + // Image holds the price for an image in dollars per token. + Image float64 `json:"image,string"` +} + // Context holds the data needed by a model for running a task. type Context struct { // Language holds the language for which the task should be evaluated. diff --git a/provider/openrouter/openrouter.go b/provider/openrouter/openrouter.go index c9c99a0b..a6ed0e9e 100644 --- a/provider/openrouter/openrouter.go +++ b/provider/openrouter/openrouter.go @@ -53,30 +53,7 @@ func (p *Provider) ID() (id string) { // ModelsList holds a list of models. type ModelsList struct { - Models []Model `json:"data"` -} - -// Model holds a model. -type Model struct { - // ID holds the model id. - ID string `json:"id"` - // Name holds the model name. - Name string `json:"name"` - - // Pricing holds the pricing information of a model. - Pricing Pricing `json:"pricing"` -} - -// Pricing holds the pricing information of a model. -type Pricing struct { - // Prompt holds the price for a prompt in dollars per token. - Prompt float64 `json:"prompt,string"` - // Completion holds the price for a completion in dollars per token. - Completion float64 `json:"completion,string"` - // Request holds the price for a request in dollars per request. - Request float64 `json:"request,string"` - // Image holds the price for an image in dollars per token. - Image float64 `json:"image,string"` + Models []model.MetaInformation `json:"data"` } // Models returns which models are available to be queried via this provider.