aiwrapper
Version:
A Universal AI Wrapper for JavaScript & TypeScript
38 lines (37 loc) • 1.27 kB
JavaScript
import { OpenAIChatCompletionsLang } from "../openai/openai-chat-completions-lang.js";
import { models } from "aimodels";
class DeepSeekLang extends OpenAIChatCompletionsLang {
constructor(options) {
const modelName = options.model || "deepseek-chat";
super({
apiKey: options.apiKey,
model: modelName,
systemPrompt: options.systemPrompt || "",
maxTokens: options.maxTokens,
baseURL: "https://api.deepseek.com/v1"
});
}
supportsReasoning() {
const modelInfo = models.id(this._config.model);
if (modelInfo == null ? void 0 : modelInfo.can("reason")) return true;
const isReasonerModel = this._config.model.toLowerCase().includes("reasoner");
return isReasonerModel;
}
handleStreamData(data, result, onResult) {
if (data.finished) {
result.finished = true;
const last = result.length > 0 ? result[result.length - 1] : void 0;
if (last) onResult == null ? void 0 : onResult(last);
return;
}
if (data.choices && data.choices[0].delta.reasoning_content) {
const reasoningContent = data.choices[0].delta.reasoning_content;
return;
}
super.handleStreamData(data, result, onResult);
}
}
export {
DeepSeekLang
};
//# sourceMappingURL=deepseek-lang.js.map