Skip to content

Commit 4c72258

Browse files
committed
adding deepseek
1 parent 5c4b99f commit 4c72258

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

docs/src/content/docs/reference/cli/commands.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Usage: genaiscript run [options] <script> [files...]
1616
Runs a GenAIScript against files.
1717
1818
Options:
19-
-p, --provider <string> Preferred LLM provider aliases (choices: "openai", "azure", "azure_serverless", "azure_serverless_models", "anthropic", "anthropic_bedrock", "google", "huggingface", "mistral", "alibaba", "github", "transformers", "ollama", "lmstudio", "jan", "llamafile", "litellm")
19+
-p, --provider <string> Preferred LLM provider aliases (choices: "openai", "azure", "azure_serverless", "azure_serverless_models", "anthropic", "anthropic_bedrock", "google", "huggingface", "mistral", "alibaba", "github", "deepseek", "transformers", "ollama", "lmstudio", "jan", "llamafile", "litellm")
2020
-m, --model <string> 'large' model alias (default)
2121
-sm, --small-model <string> 'small' alias model
2222
-vm, --vision-model <string> 'vision' alias model
@@ -92,8 +92,8 @@ Options:
9292
"azure_serverless_models", "anthropic",
9393
"anthropic_bedrock", "google",
9494
"huggingface", "mistral", "alibaba",
95-
"github", "transformers", "ollama",
96-
"lmstudio", "jan", "llamafile",
95+
"github", "deepseek", "transformers",
96+
"ollama", "lmstudio", "jan", "llamafile",
9797
"litellm")
9898
-m, --model <string> 'large' model alias (default)
9999
-sm, --small-model <string> 'small' alias model

packages/core/src/connection.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
MODEL_PROVIDER_JAN,
3636
JAN_API_BASE,
3737
MODEL_PROVIDER_ANTHROPIC_BEDROCK,
38+
MODEL_PROVIDER_DEEPSEEK,
39+
DEEPSEEK_API_BASE,
3840
} from "./constants"
3941
import { host, runtimeHost } from "./host"
4042
import { parseModelIdentifier } from "./models"
@@ -412,6 +414,22 @@ export async function parseTokenFromEnv(
412414
} satisfies LanguageModelConfiguration
413415
}
414416

417+
if (provider === MODEL_PROVIDER_DEEPSEEK) {
418+
const base =
419+
findEnvVar(env, "DEEPSEEK", BASE_SUFFIX)?.value || DEEPSEEK_API_BASE
420+
if (!URL.canParse(base)) throw new Error(`${base} must be a valid URL`)
421+
const token = env.DEEPSEEK_API_KEY
422+
if (!token) throw new Error("DEEPSEEK_API_KEY not configured")
423+
return {
424+
provider,
425+
model,
426+
base,
427+
token,
428+
type: "openai",
429+
source: "env: DEEPSEEK_API_...",
430+
}
431+
}
432+
415433
const prefixes = [
416434
tag ? `${provider}_${model}_${tag}` : undefined,
417435
provider ? `${provider}_${model}` : undefined,
@@ -493,7 +511,7 @@ export async function parseTokenFromEnv(
493511
provider,
494512
model,
495513
base,
496-
token: "lmstudio",
514+
token: "jan",
497515
type: "openai",
498516
source: "env: JAN_API_...",
499517
}

packages/core/src/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const GOOGLE_API_BASE =
122122
export const ALIBABA_BASE =
123123
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
124124
export const MISTRAL_API_BASE = "https://api.mistral.ai/v1"
125+
export const DEEPSEEK_API_BASE = "https://api.deepseek.com/v1"
125126

126127
export const PROMPTFOO_CACHE_PATH = ".genaiscript/cache/tests"
127128
export const PROMPTFOO_CONFIG_DIR = ".genaiscript/config/tests"
@@ -156,6 +157,7 @@ export const MODEL_PROVIDER_ALIBABA = "alibaba"
156157
export const MODEL_PROVIDER_MISTRAL = "mistral"
157158
export const MODEL_PROVIDER_LMSTUDIO = "lmstudio"
158159
export const MODEL_PROVIDER_JAN = "jan"
160+
export const MODEL_PROVIDER_DEEPSEEK = "deepseek"
159161

160162
export const TRACE_FILE_PREVIEW_MAX_LENGTH = 240
161163

packages/core/src/llms.json

+16
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@
145145
"reasoning_small": "o1-mini"
146146
}
147147
},
148+
{
149+
"id": "deepseek",
150+
"detail": "DeepSeek Models",
151+
"base": "https://api.deepseek.com/v1",
152+
"bearerToken": true,
153+
"aliases": {
154+
"large": "deepseek-chat",
155+
"small": "deepseek-chat",
156+
"vision": "deepseek-chat"
157+
}
158+
},
148159
{
149160
"id": "transformers",
150161
"detail": "Hugging Face Transformers",
@@ -632,6 +643,11 @@
632643
"price_per_million_input_tokens": 0.8,
633644
"price_per_million_output_tokens": 4,
634645
"input_cache_token_rebate": 0.1
646+
},
647+
"deepseek:deepseek-chat": {
648+
"price_per_million_input_tokens": 0.14,
649+
"price_per_million_output_tokens": 0.28,
650+
"input_cache_token_rebate": 0.1
635651
}
636652
}
637653
}

packages/core/src/lm.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
MODEL_PROVIDER_ANTHROPIC,
88
MODEL_PROVIDER_ANTHROPIC_BEDROCK,
99
MODEL_PROVIDER_CLIENT,
10-
MODEL_PROVIDER_JAN,
1110
MODEL_PROVIDER_OLLAMA,
1211
MODEL_PROVIDER_TRANSFORMERS,
1312
MODEL_PROVIDERS,

packages/core/src/types/prompt_template.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ type ModelType = OptionsOrString<
175175
| "alibaba:qwen-plus"
176176
| "alibaba:qwen2-72b-instruct"
177177
| "alibaba:qwen2-57b-a14b-instruct"
178+
| "deepseek:deepseek-chat"
178179
| "transformers:onnx-community/Qwen2.5-0.5B-Instruct:q4"
179180
| "transformers:HuggingFaceTB/SmolLM2-1.7B-Instruct:q4f16"
180181
>

0 commit comments

Comments
 (0)