Skip to content
Snippets Groups Projects
Unverified Commit 086b9403 authored by Erik's avatar Erik Committed by GitHub
Browse files

feat: add DeepSeek LLM class and documentation (#1071)

parent 5d5716b3
No related branches found
No related tags found
No related merge requests found
---
"llamaindex": minor
"docs": minor
---
add DeepSeek LLM class and documentation
---
"llamaindex": minor
"docs": minor
---
Add deepseek llm class
# DeepSeek LLM
## Usage
```ts
import { DeepSeekLLM, Settings } from "llamaindex";
Settings.llm = new DeepSeekLLM({
apiKey: "<YOUR_API_KEY>",
model: "deepseek-coder", // or "deepseek-chat"
});
```
## Example
```ts
import { DeepSeekLLM, Document, VectorStoreIndex, Settings } from "llamaindex";
const deepseekLlm = new DeepSeekLLM({
apiKey: "<YOUR_API_KEY>",
model: "deepseek-coder", // or "deepseek-chat"
});
async function main() {
const response = await llm.deepseekLlm.chat({
messages: [
{
role: "system",
content: "You are an AI assistant",
},
{
role: "user",
content: "Tell me about San Francisco",
},
],
stream: false,
});
console.log(response);
}
```
# Limitations
Currently does not support function calling.
[Currently does not support json-output param while still is very good at json generating.](https://platform.deepseek.com/api-docs/faq#does-your-api-support-json-output)
## API platform
- [DeepSeek platform](https://platform.deepseek.com/)
import { getEnv } from "@llamaindex/env";
import { OpenAI } from "./openai.js";
export const DEEPSEEK_MODELS = {
"deepseek-coder": { contextWindow: 128000 },
"deepseek-chat": { contextWindow: 128000 },
};
type DeepSeekModelName = keyof typeof DEEPSEEK_MODELS;
const DEFAULT_MODEL: DeepSeekModelName = "deepseek-coder";
export class DeepSeekLLM extends OpenAI {
constructor(init?: Partial<OpenAI> & { model?: DeepSeekModelName }) {
const {
apiKey = getEnv("DEEPSEEK_API_KEY"),
additionalSessionOptions = {},
model = DEFAULT_MODEL,
...rest
} = init ?? {};
if (!apiKey) {
throw new Error("Set DeepSeek Key in DEEPSEEK_API_KEY env variable");
}
additionalSessionOptions.baseURL =
additionalSessionOptions.baseURL ?? "https://api.deepseek.com/v1";
super({
apiKey,
additionalSessionOptions,
model,
...rest,
});
}
}
......@@ -34,5 +34,6 @@ export {
ReplicateSession,
} from "./replicate_ai.js";
export { DeepSeekLLM } from "./deepseek.js";
export { TogetherLLM } from "./together.js";
export * from "./types.js";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment