-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create model references with dynamic config
- Loading branch information
1 parent
e52a0d7
commit 45be528
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package genkit | ||
|
||
type ModelStage int | ||
|
||
/** At which stage of development the model is. | ||
* - `featured` models are recommended for general use. | ||
* - `stable` models are well-tested and reliable. | ||
* - `unstable` models are experimental and may change. | ||
* - `legacy` models are no longer recommended for new projects. | ||
* - `deprecated` models are deprecated by the provider and may be removed in future versions. | ||
*/ | ||
const ( | ||
FEATURED ModelStage = iota | ||
STABLE | ||
UNSTABLE | ||
LEGACY | ||
DEPRECATED | ||
) | ||
|
||
type ModelCapabilities struct { | ||
/** Model can output this type of data. */ | ||
Output []string | ||
/** Model supports output in these content types. */ | ||
ContentType []string | ||
/** Model can process historical messages passed with a prompt. */ | ||
Multiturn bool | ||
/** Model can process media as part of the prompt (multimodal input). */ | ||
Media bool | ||
/** Model can perform tool calls. */ | ||
Tools bool | ||
/** Model can accept messages with role "system". */ | ||
SystemRole bool | ||
/** Model can natively support document-based context grounding. */ | ||
Context bool | ||
} | ||
|
||
type ModelInfo struct { | ||
Versions []string | ||
Label string | ||
Supports ModelCapabilities | ||
// TODO: is Stage needed? | ||
Stage ModelStage | ||
} | ||
|
||
type ModelReference struct { | ||
Name string | ||
Version string | ||
Info ModelInfo | ||
// TODO: configSchema and config should be something | ||
} | ||
|
||
type WithConfig func(*ModelReference) | ||
|
||
func WithVersion(version string) WithConfig { | ||
return func(m *ModelReference) { | ||
m.Version = version | ||
} | ||
} | ||
|
||
func ModelRef(opts ...WithConfig) *ModelReference { | ||
m := &ModelReference{} | ||
for _, opt := range opts { | ||
opt(m) | ||
} | ||
|
||
return m | ||
} |