language-models 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/.releaserc.js +129 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/aliases.d.ts +1 -0
- package/dist/aliases.js +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/models.d.ts +170 -0
- package/dist/models.js +69803 -0
- package/dist/parser.d.ts +86 -0
- package/dist/parser.js +390 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +76 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.js +1 -0
- package/eslint.config.js +3 -0
- package/generate/build-models.ts +150 -0
- package/generate/overwrites.ts +12 -0
- package/package.json +32 -0
- package/publish.js +32 -0
- package/roadmap.md +54 -0
- package/src/aliases.ts +5 -0
- package/src/index.ts +10 -0
- package/src/models.d.ts +170 -0
- package/src/models.js +70434 -0
- package/src/parser.ts +485 -0
- package/src/providers.ts +79 -0
- package/src/types.ts +135 -0
- package/tests/parser.test.ts +11 -0
- package/tests/regex.test.ts +42 -0
- package/tests/selector.test.ts +53 -0
- package/tests/setup.ts +0 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +21 -0
package/.editorconfig
ADDED
package/.gitattributes
ADDED
package/.releaserc.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
branches: [
|
|
4
|
+
{name: 'next', prerelease: 'next', channel: 'next'}
|
|
5
|
+
],
|
|
6
|
+
repositoryUrl: 'https://github.com/drivly/ai.git',
|
|
7
|
+
tagFormat: '${name}@${version}',
|
|
8
|
+
initialVersion: '0.1.0',
|
|
9
|
+
npmPublish: true,
|
|
10
|
+
pkgRoot: '.',
|
|
11
|
+
plugins: [
|
|
12
|
+
{
|
|
13
|
+
verifyConditions: (pluginConfig, context) => {
|
|
14
|
+
console.log('Verifying conditions for semantic-release...');
|
|
15
|
+
|
|
16
|
+
if (context.nextRelease && context.nextRelease.version) {
|
|
17
|
+
if (!context.nextRelease.version.startsWith('0.')) {
|
|
18
|
+
console.log(`Forcing version to start with 0: ${context.nextRelease.version} -> 0.${context.nextRelease.version}`);
|
|
19
|
+
context.nextRelease.version = '0.' + context.nextRelease.version;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
24
|
+
if (fs.existsSync(pkgPath)) {
|
|
25
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
26
|
+
if (!pkg.version.startsWith('0.')) {
|
|
27
|
+
console.log(`Fixing package.json version: ${pkg.version} -> 0.1.0`);
|
|
28
|
+
pkg.version = '0.1.0';
|
|
29
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
analyzeCommits: (pluginConfig, context) => {
|
|
34
|
+
if (!context.lastRelease.version) {
|
|
35
|
+
console.log('No previous version found, starting at 0.1.0-next.1');
|
|
36
|
+
return '0.1.0-next.1'; // Start new packages at 0.1.0-next.1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log('Forcing patch release regardless of commit types');
|
|
40
|
+
return 'patch';
|
|
41
|
+
},
|
|
42
|
+
prepare: (pluginConfig, context) => {
|
|
43
|
+
console.log('Preparing for release...');
|
|
44
|
+
|
|
45
|
+
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
46
|
+
if (fs.existsSync(pkgPath)) {
|
|
47
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
48
|
+
let modified = false;
|
|
49
|
+
|
|
50
|
+
const packageVersions = {};
|
|
51
|
+
for (const pkgDir of ["/home/runner/work/ai/ai/sdks/actions.do","/home/runner/work/ai/ai/sdks/agents.do","/home/runner/work/ai/ai/sdks/analytics.do","/home/runner/work/ai/ai/sdks/apis.do","/home/runner/work/ai/ai/sdks/database.do","/home/runner/work/ai/ai/sdks/evals.do","/home/runner/work/ai/ai/sdks/experiments.do","/home/runner/work/ai/ai/sdks/functions.do","/home/runner/work/ai/ai/sdks/goals.do","/home/runner/work/ai/ai/sdks/gpt.do","/home/runner/work/ai/ai/sdks/integrations.do","/home/runner/work/ai/ai/sdks/llm.do","/home/runner/work/ai/ai/sdks/mcp.do","/home/runner/work/ai/ai/sdks/models.do","/home/runner/work/ai/ai/sdks/plans.do","/home/runner/work/ai/ai/sdks/projects.do","/home/runner/work/ai/ai/sdks/sdk.do","/home/runner/work/ai/ai/sdks/searches.do","/home/runner/work/ai/ai/sdks/tasks.do","/home/runner/work/ai/ai/sdks/triggers.do","/home/runner/work/ai/ai/sdks/workflows.do","/home/runner/work/ai/ai/pkgs/ai-business","/home/runner/work/ai/ai/pkgs/ai-database","/home/runner/work/ai/ai/pkgs/ai-functions","/home/runner/work/ai/ai/pkgs/ai-models","/home/runner/work/ai/ai/pkgs/ai-providers","/home/runner/work/ai/ai/pkgs/ai-workflows","/home/runner/work/ai/ai/pkgs/apis-do-searches","/home/runner/work/ai/ai/pkgs/apis-do-zapier","/home/runner/work/ai/ai/pkgs/business-as-code","/home/runner/work/ai/ai/pkgs/clickable-apis","/home/runner/work/ai/ai/pkgs/deploy-worker","/home/runner/work/ai/ai/pkgs/durable-objects-cron","/home/runner/work/ai/ai/pkgs/durable-objects-nosql","/home/runner/work/ai/ai/pkgs/eslint-config","/home/runner/work/ai/ai/pkgs/exec-symbols","/home/runner/work/ai/ai/pkgs/language-models","/home/runner/work/ai/ai/pkgs/mdxdb","/home/runner/work/ai/ai/pkgs/mdxld","/home/runner/work/ai/ai/pkgs/motion.md","/home/runner/work/ai/ai/pkgs/payload-agent","/home/runner/work/ai/ai/pkgs/payload-commandbar","/home/runner/work/ai/ai/pkgs/payload-hooks-queue","/home/runner/work/ai/ai/pkgs/payload-theme","/home/runner/work/ai/ai/pkgs/payload-utils","/home/runner/work/ai/ai/pkgs/payload-vscode","/home/runner/work/ai/ai/pkgs/payload-workos","/home/runner/work/ai/ai/pkgs/payload-zapier-apps","/home/runner/work/ai/ai/pkgs/services-as-software","/home/runner/work/ai/ai/pkgs/simple-payload","/home/runner/work/ai/ai/pkgs/tsconfig","/home/runner/work/ai/ai/pkgs/zapier-apis-do"]) {
|
|
52
|
+
const pkgJsonPath = path.join(pkgDir, 'package.json');
|
|
53
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
54
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
|
55
|
+
packageVersions[pkgJson.name] = pkgJson.version || '0.1.0';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (pkg.dependencies) {
|
|
60
|
+
for (const [dep, version] of Object.entries(pkg.dependencies)) {
|
|
61
|
+
if (version.startsWith('workspace:')) {
|
|
62
|
+
if (packageVersions[dep]) {
|
|
63
|
+
console.log(`Converting workspace dependency ${dep} from ${version} to ${packageVersions[dep]}`);
|
|
64
|
+
pkg.dependencies[dep] = packageVersions[dep];
|
|
65
|
+
modified = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (pkg.devDependencies) {
|
|
72
|
+
for (const [dep, version] of Object.entries(pkg.devDependencies)) {
|
|
73
|
+
if (version.startsWith('workspace:')) {
|
|
74
|
+
if (packageVersions[dep]) {
|
|
75
|
+
console.log(`Converting workspace devDependency ${dep} from ${version} to ${packageVersions[dep]}`);
|
|
76
|
+
pkg.devDependencies[dep] = packageVersions[dep];
|
|
77
|
+
modified = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (pkg.peerDependencies) {
|
|
84
|
+
for (const [dep, version] of Object.entries(pkg.peerDependencies)) {
|
|
85
|
+
if (version.startsWith('workspace:')) {
|
|
86
|
+
if (packageVersions[dep]) {
|
|
87
|
+
console.log(`Converting workspace peerDependency ${dep} from ${version} to ${packageVersions[dep]}`);
|
|
88
|
+
pkg.peerDependencies[dep] = packageVersions[dep];
|
|
89
|
+
modified = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (modified) {
|
|
96
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
97
|
+
console.log('Updated package.json with converted workspace dependencies before publishing');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
['@semantic-release/commit-analyzer', {
|
|
103
|
+
preset: 'angular',
|
|
104
|
+
releaseRules: [
|
|
105
|
+
{type: 'feat', release: 'patch'},
|
|
106
|
+
{type: 'fix', release: 'patch'},
|
|
107
|
+
{type: 'docs', release: 'patch'},
|
|
108
|
+
{type: 'style', release: 'patch'},
|
|
109
|
+
{type: 'refactor', release: 'patch'},
|
|
110
|
+
{type: 'perf', release: 'patch'},
|
|
111
|
+
{type: 'test', release: 'patch'},
|
|
112
|
+
{type: 'build', release: 'patch'},
|
|
113
|
+
{type: 'ci', release: 'patch'},
|
|
114
|
+
{type: 'chore', release: 'patch'}
|
|
115
|
+
]
|
|
116
|
+
}],
|
|
117
|
+
['@semantic-release/release-notes-generator', {
|
|
118
|
+
writerOpts: {
|
|
119
|
+
commitLimit: 100,
|
|
120
|
+
}
|
|
121
|
+
}],
|
|
122
|
+
['@semantic-release/npm', {
|
|
123
|
+
npmPublish: true,
|
|
124
|
+
pkgRoot: '.',
|
|
125
|
+
npmTag: 'next'
|
|
126
|
+
}],
|
|
127
|
+
'@semantic-release/github'
|
|
128
|
+
]
|
|
129
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Driv.ly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# ai-models
|
|
2
|
+
|
|
3
|
+
Utilities and Tools for the AI SDK, Functions, Workflows, Observability, and Evals
|
|
4
|
+
|
|
5
|
+
open questions:
|
|
6
|
+
|
|
7
|
+
We need to support provider/creator/model
|
|
8
|
+
Do we need or want a @ sign?
|
|
9
|
+
Do we also support a creator/model syntax without provider? I think probably
|
|
10
|
+
I think we should follow/embrace openrouter's syntax wherever possible - extending it though to add our requirements
|
|
11
|
+
Do we also have our own version of openrouter/auto, openrouter/auto:online
|
|
12
|
+
Can we tie the routing into the contents of the message and/or priority? (like performance, latency, throughput, cost, etc?)
|
|
13
|
+
How do we handle reasoning? Follow the :reasoning flag from openrouter?
|
|
14
|
+
Many new open models do not initially support tools or structured output, as that requires a lot of work by the hosting provider to make that function ... do we want a composite type tool that could use a fast/cheap model like gemini-2-flash-lite or 4o-mini to transform the output of the first model into the specified structured output?
|
|
15
|
+
How do we want to handle other capabilities/tools?
|
|
16
|
+
Should we route :online to native search models like gemini, perplexity, or the new 4o-search? or do we just follow the OpenRouter convention of injecting the Search results into the context window before calling?
|
|
17
|
+
Do we want to support more general purpose tools? (like https://agentic.so/intro)
|
|
18
|
+
How can we also support our own secure code execution tool (JS not python like Google / OAI)
|
|
19
|
+
|
|
20
|
+
Clearly we will need to phase and iterate ... but we have to think very carefully because once we start using the API across multiple projects, it's going to be hard to change
|
|
21
|
+
|
|
22
|
+
@{provider}/{creator}/{model}:{config,capabilities,tools,priorities}
|
|
23
|
+
|
|
24
|
+
{creator}/{model}:{config,capabilities,tools,priorities}
|
|
25
|
+
?model=deepseek-ai/deepseek-r1-distill-qwen-32b
|
|
26
|
+
|
|
27
|
+
?model=@openai/openai/gpt-4o-search-preview
|
|
28
|
+
|
|
29
|
+
?model=openai/gpt-4o:code,online
|
|
30
|
+
|
|
31
|
+
@openrouter/deepseek-ai/deepseek-r1-distill-qwen-32b
|
|
32
|
+
@cloudflare/deepseek-ai/deepseek-r1-distill-qwen-32b
|
|
33
|
+
@google-vertex/deepseek-ai/deepseek-r1-distill-qwen-32b
|
|
34
|
+
@google-ai-studio/anthropic/claude-3.7-sonnet:thinking
|
|
35
|
+
@google-vertex/anthropic/claude-3.7-sonnet:thinking
|
|
36
|
+
@open-router/anthropic/claude-3.7-sonnet:thinking-low,online,nitro
|
|
37
|
+
|
|
38
|
+
Use Cases:
|
|
39
|
+
|
|
40
|
+
Evals - we need to easily and dynamically/programmatically change models, settings, tools, configuration, and mode
|
|
41
|
+
(for example - we need to test if something does better with or without reasoning ... and within reasoning, we need low, medium, and high models ... We also in some cases must force structured outputs to be structured outputs, because if tool use is required, say by an anthropic model, that supports structured outputs via tools, then that is incompatible ... but also, there are essentially 4 different ways to get Objects that match a certain schema:
|
|
42
|
+
structured_output: the best by far, but very limited support ... I think only 3 providers support this today
|
|
43
|
+
tool_use: There is support for many more providers with tool use, but only a subset actually enforces guaranteed schema ... but also has limitations on number of tools and forced tool to use
|
|
44
|
+
response_format: Supported on a majority of providers and models - but not universal - this guarantees valid JSON responses, but not any guarantee about the schema. This JSON mode can also be used without a schema to just force the model to respond in a structured data form vs normal text/markdown
|
|
45
|
+
system prompt: If the model/provider does not support any of the first 3, then you can just ask nicely ... but depending on the model, this will fail 10-50% of the time
|
|
46
|
+
Experimentation - Humans or LLM-as-Judge can pick the preferred response from 2 or more models (ie. compare 4o, o2, 3.7, 3.7:reasoning, flash 2, flash 2.0 reasoning
|
|
47
|
+
Specify best model - no cost/price requirements ... 4.5, o1-high, o3-mini-high, r1, 3.7, 3.7:reasoning-high, Flash 2 Pro, Flash 2 Reasoning
|
|
48
|
+
Specify only reasoning:
|
|
49
|
+
at runtime, be able to tweak provider/model/settings/tools via a simple query param for example ... ?model=*:reasoning+code would route that to any and all models with reasoning and a code execution tool ... currently adding tool, changing config, etc requires code changes ... we need all of these variables to be tweaked/edited/stored/evaluated at runtime without code changes
|
|
50
|
+
also we need to opt in/out of caching (and maybe even logging req/res bodies in sensitive PII situations)
|
|
51
|
+
also probably seed ...
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// The name of the exported function should be changed, I just wanted to get the ball rolling
|
|
59
|
+
import { getSupportedModel } from '@drivly/ai-utils'
|
|
60
|
+
|
|
61
|
+
const model = getSupportedModel('@openai/openai/gpt-4o:code,online')
|
|
62
|
+
const model = getSupportedModel('@anthropic/anthropic/claude-3.7-sonnet:thinking,code,online')
|
|
63
|
+
const model = getSupportedModel([
|
|
64
|
+
// Fallback support if a certain model is down / doesnt have the full capabilities supported
|
|
65
|
+
req.args.model, // Attempt to use the model from the request, otherwise fallback to the next one
|
|
66
|
+
'@openai/openai/gpt-4o:code,online,thinking',
|
|
67
|
+
'@anthropic/anthropic/claude-3.7-sonnet:thinking,code,online',
|
|
68
|
+
])
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Meta-model Manager
|
|
72
|
+
|
|
73
|
+
To support complex busines requirements, we need a system that can automatically determine the best model for each task.
|
|
74
|
+
|
|
75
|
+
### Classification of content
|
|
76
|
+
|
|
77
|
+
A classification layer will be used to attach weights based on the prompt. The weights indicate the relative importance of each type of content in the prompt:
|
|
78
|
+
|
|
79
|
+
`'Generate a business plan to sell water to a fish.'` -> `[ 'businessLogic:0.5', 'marketing:0.4', 'legal:0.21' ]`
|
|
80
|
+
|
|
81
|
+
Each model in our system will maintain a unique set of performance weights, calculated from multiple feedback sources including the Arena as well as direct user-provided Eval Feedback. The classification layer's primary responsibility is to identify and tag content types within prompts.
|
|
82
|
+
|
|
83
|
+
When users indicate their satisfaction with a model's response through positive feedback (such as giving a `👍`), our system automatically increases that model's score for the identified content tags. This scoring mechanism creates a self-improving selection algorithm that learns which models excel at specific content types over time, leading to increasingly accurate model selection for future similar prompts without requiring manual intervention.
|
|
84
|
+
|
|
85
|
+
The key difference between this and systems such as NotDiamond is that we can offer multiple meta-models, each with their own focuses and strengths. Another benefit that we offer is that our weights are changing daily as we receive more feedback.
|
|
86
|
+
|
|
87
|
+
### Ideas and thoughts
|
|
88
|
+
|
|
89
|
+
- One idea could be to slowly remove weights over time, marking models with less usage as less important. This would allow for newer models to quickly bubble up to the top without needing a vast evaluation dataset. For example, if Gemini 3 releases and people start using it more, the weights for Gemini 2 will slowly decrease, making it less and less likely to be chosen as we can more confident in the newer model.
|
|
90
|
+
- Tags could be generated from the prompt, making it fully dynamic. Works best if we force the classification model to try its best to match an existing tag, but create a new one if it cant.
|
|
91
|
+
- Version pinning.
|
|
92
|
+
|
|
93
|
+
### Examples
|
|
94
|
+
|
|
95
|
+
#### Meta model: frontier()
|
|
96
|
+
|
|
97
|
+
#### Prompt: Generate a business plan to sell water to a fish.
|
|
98
|
+
|
|
99
|
+
#### Weights: `[ 'businessLogic:0.75', 'marketing:0.4', 'legal:0.21' ]`
|
|
100
|
+
|
|
101
|
+
#### Models
|
|
102
|
+
|
|
103
|
+
Using the above information, we can now sort our models using the weights to find the best model within a certain "meta-model". In this example, we're using the `frontier-reasoning` group of models that are best at reasoning and logic.
|
|
104
|
+
|
|
105
|
+
Thanks to our classification layer, its extremely easy to route the prompt to `claude-3.7-sonnet`, which best matches the `businessLogic` tag (among others).
|
|
106
|
+
|
|
107
|
+
## Sequence diagram
|
|
108
|
+
|
|
109
|
+
```mermaid
|
|
110
|
+
sequenceDiagram
|
|
111
|
+
participant User
|
|
112
|
+
participant Classification as Classification Layer
|
|
113
|
+
participant MetaManager as Meta-model Manager
|
|
114
|
+
participant ModelRegistry as Model Registry
|
|
115
|
+
participant SelectedModel as Selected Model
|
|
116
|
+
participant Feedback as Feedback System
|
|
117
|
+
|
|
118
|
+
User->>Classification: Send prompt "Generate business plan for fish water"
|
|
119
|
+
Note over Classification: Analyzes content types in prompt
|
|
120
|
+
Classification->>MetaManager: Provides weights [businessLogic:0.75, marketing:0.4, legal:0.21]
|
|
121
|
+
|
|
122
|
+
MetaManager->>ModelRegistry: Request models matching meta-model type (e.g., "frontier-reasoning")
|
|
123
|
+
ModelRegistry->>MetaManager: Return candidate models with performance weights
|
|
124
|
+
|
|
125
|
+
Note over MetaManager: Ranks models based on content weights<br/>and historical performance
|
|
126
|
+
MetaManager->>SelectedModel: Route prompt to best model (e.g., claude-3.7-sonnet)
|
|
127
|
+
SelectedModel->>User: Return response
|
|
128
|
+
|
|
129
|
+
User->>Feedback: Provides feedback (👍)
|
|
130
|
+
Feedback->>ModelRegistry: Update model scores for identified content tags
|
|
131
|
+
Note over ModelRegistry: Increases claude-3.7-sonnet's<br/>score for businessLogic tag
|
|
132
|
+
|
|
133
|
+
Note over MetaManager: Future similar prompts more likely<br/>to select same high-performing model
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`*:reasoning(sort:pricing,latency)`
|
|
137
|
+
|
|
138
|
+
## Examples
|
|
139
|
+
|
|
140
|
+
- Best PDF model thats the cheapest (gemini-2.0-flash) -> `*:pdf(sort:pricing)`
|
|
141
|
+
- PDF with reasoning (claude-3.7-sonnet) -> `*:pdf,reasoning`
|
|
142
|
+
- Creative writing (gpt-4.5) -> `creative`
|
|
143
|
+
- Extremely complex code debugging (o1-pro)
|
|
144
|
+
- Cheap blog post writer (gemini-2.0-flash)
|
|
145
|
+
- Better blog post writer (gpt-4o || claude-3.7-sonnet)
|
|
146
|
+
- Best blog post writer (gpt-4.5)
|
|
147
|
+
- Deal review (o3-mini || claude-3.7-sonnet || gemini-2.5-pro)
|
|
148
|
+
|
|
149
|
+
#### Example business requirements
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Requirements: Must be good at creative writing, but cost less than $15 per million tokens
|
|
153
|
+
Constraints: Must be able to handle complex code
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
We need to transform the above business requirements into a meta-model:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
[
|
|
160
|
+
"gemini-2.0-flash",
|
|
161
|
+
...
|
|
162
|
+
]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
From the list, we can then sort by pricing, latency, and other constraints at completion time depending on the users goals.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const aliases: Record<string, string>;
|
package/dist/aliases.js
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './parser';
|
|
2
|
+
export * from './aliases';
|
|
3
|
+
export * from './providers';
|
|
4
|
+
import allModels from './models';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export const models = allModels.models;
|
|
7
|
+
export const modelPattern = /^(?:[\w-]+\/)?[\w\.-]+(?:@[\w-]+(?::[\w-]+)?)?(?<!@)\([^()]*(?:\([^()]*\)[^()]*)*\)$/;
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// --- Reusable Base Interfaces ---
|
|
2
|
+
|
|
3
|
+
interface Icon {
|
|
4
|
+
url: string
|
|
5
|
+
invertRequired?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface DataPolicy {
|
|
9
|
+
termsOfServiceUrl?: string // Optional based on examples
|
|
10
|
+
privacyPolicyUrl?: string // Optional based on examples
|
|
11
|
+
training: boolean
|
|
12
|
+
loggingRetentionDays?: number // Optional based on examples
|
|
13
|
+
requiresUserIds?: boolean // Optional based on examples
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Base pricing structure, allowing for optional cache fields
|
|
17
|
+
interface Pricing {
|
|
18
|
+
prompt: string
|
|
19
|
+
completion: string
|
|
20
|
+
image: string
|
|
21
|
+
request: string
|
|
22
|
+
webSearch: string
|
|
23
|
+
internalReasoning: string
|
|
24
|
+
discount: number
|
|
25
|
+
inputCacheRead?: string // Optional based on examples
|
|
26
|
+
inputCacheWrite?: string // Optional based on examples
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ReasoningConfig {
|
|
30
|
+
startToken: string
|
|
31
|
+
endToken: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Sorting {
|
|
35
|
+
topWeekly: number
|
|
36
|
+
newest: number
|
|
37
|
+
throughputHighToLow: number
|
|
38
|
+
latencyLowToHigh: number
|
|
39
|
+
pricingLowToHigh: number
|
|
40
|
+
pricingHighToLow: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface ProviderInfo {
|
|
44
|
+
name: string
|
|
45
|
+
displayName: string
|
|
46
|
+
baseUrl: string
|
|
47
|
+
dataPolicy: DataPolicy
|
|
48
|
+
headquarters?: string // Optional based on examples
|
|
49
|
+
hasChatCompletions: boolean
|
|
50
|
+
hasCompletions: boolean
|
|
51
|
+
isAbortable: boolean
|
|
52
|
+
moderationRequired: boolean
|
|
53
|
+
group: string
|
|
54
|
+
editors: never[] // Assuming these are always empty based on examples
|
|
55
|
+
owners: never[] // Assuming these are always empty based on examples
|
|
56
|
+
isMultipartSupported: boolean
|
|
57
|
+
statusPageUrl: string | null
|
|
58
|
+
byokEnabled: boolean
|
|
59
|
+
isPrimaryProvider: boolean
|
|
60
|
+
icon: Icon
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Represents an entry in the 'providers' array within a Model
|
|
64
|
+
interface ModelProvider {
|
|
65
|
+
name: string
|
|
66
|
+
slug: string
|
|
67
|
+
quantization: string | null
|
|
68
|
+
context: number
|
|
69
|
+
maxCompletionTokens: number | null // Can be null in examples
|
|
70
|
+
pricing: Pricing // Use the common Pricing type
|
|
71
|
+
supportedParameters: string[]
|
|
72
|
+
inputCost: number
|
|
73
|
+
outputCost: number
|
|
74
|
+
throughput?: number // Optional based on examples
|
|
75
|
+
latency?: number // Optional based on examples
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Represents the nested 'features.supportedParameters' object
|
|
79
|
+
interface SupportedParametersFeatures {
|
|
80
|
+
responseFormat?: boolean
|
|
81
|
+
structuredOutputs?: boolean
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Base Model structure (common fields without nested endpoint/providers)
|
|
85
|
+
// This helps avoid circular type definitions initially
|
|
86
|
+
interface ModelBase {
|
|
87
|
+
slug: string
|
|
88
|
+
hfSlug: string | null
|
|
89
|
+
updatedAt: string
|
|
90
|
+
createdAt: string
|
|
91
|
+
hfUpdatedAt: string | null // Assuming string like others, though only null seen
|
|
92
|
+
name: string
|
|
93
|
+
shortName: string
|
|
94
|
+
author: string
|
|
95
|
+
description: string
|
|
96
|
+
modelVersionGroupId: string | null
|
|
97
|
+
contextLength: number
|
|
98
|
+
inputModalities: string[]
|
|
99
|
+
outputModalities: string[]
|
|
100
|
+
hasTextOutput: boolean
|
|
101
|
+
group: string
|
|
102
|
+
instructType: string | null
|
|
103
|
+
defaultSystem: string | null // Assuming string, though only null seen
|
|
104
|
+
defaultStops: string[] // Use string[] as it can contain values
|
|
105
|
+
hidden: boolean
|
|
106
|
+
router: string | null // Assuming string, though only null seen
|
|
107
|
+
warningMessage: string | null
|
|
108
|
+
permaslug: string
|
|
109
|
+
reasoningConfig: ReasoningConfig | null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Define Endpoint structure, referencing ModelBase for its 'model' property
|
|
113
|
+
interface Endpoint {
|
|
114
|
+
id: string
|
|
115
|
+
name: string
|
|
116
|
+
contextLength: number
|
|
117
|
+
model: ModelBase // Reference the base model structure
|
|
118
|
+
modelVariantSlug: string
|
|
119
|
+
modelVariantPermaslug: string
|
|
120
|
+
providerName: string
|
|
121
|
+
providerInfo: ProviderInfo
|
|
122
|
+
providerDisplayName: string
|
|
123
|
+
providerModelId: string
|
|
124
|
+
providerGroup: string
|
|
125
|
+
isCloaked: boolean
|
|
126
|
+
quantization: string | null
|
|
127
|
+
variant: string
|
|
128
|
+
isSelfHosted: boolean
|
|
129
|
+
canAbort: boolean
|
|
130
|
+
maxPromptTokens: number | null
|
|
131
|
+
maxCompletionTokens: number | null // Endpoint might have different limits
|
|
132
|
+
maxPromptImages: number | null
|
|
133
|
+
maxTokensPerImage: number | null
|
|
134
|
+
supportedParameters: string[]
|
|
135
|
+
isByok: boolean
|
|
136
|
+
moderationRequired: boolean
|
|
137
|
+
dataPolicy: DataPolicy // Data policy specific to the endpoint variant
|
|
138
|
+
pricing: Pricing // Pricing specific to the endpoint variant
|
|
139
|
+
isHidden: boolean
|
|
140
|
+
isDeranked: boolean
|
|
141
|
+
isDisabled: boolean
|
|
142
|
+
supportsToolParameters: boolean
|
|
143
|
+
supportsReasoning: boolean
|
|
144
|
+
supportsMultipart: boolean
|
|
145
|
+
limitRpm: number | null
|
|
146
|
+
limitRpd: number | null
|
|
147
|
+
hasCompletions: boolean
|
|
148
|
+
hasChatCompletions: boolean
|
|
149
|
+
features: {
|
|
150
|
+
supportedParameters?: SupportedParametersFeatures
|
|
151
|
+
}
|
|
152
|
+
providerRegion: string | null // Assuming string, though only null seen
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// --- Final Composed Model Interface ---
|
|
156
|
+
|
|
157
|
+
// Extend ModelBase and add the nested structures
|
|
158
|
+
interface Model extends ModelBase {
|
|
159
|
+
endpoint: Endpoint | null // Endpoint can be null
|
|
160
|
+
sorting: Sorting
|
|
161
|
+
providers: ModelProvider[] // Array can be empty
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// --- The Default Export ---
|
|
165
|
+
|
|
166
|
+
declare const _default: {
|
|
167
|
+
models: Model[]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default _default
|