3.6.4 • Published 5 months ago

@celljs/ai-deepseek v3.6.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Cell - AI DeepSeek Component

概览

AI DeepSeek 模块是一个用于与 DeepSeek API 交互的库,提供了生成聊天响应和嵌入向量的功能。通过简单易用的 API 接口,支持消息的创建、请求的发送和响应的处理。是 @celljs/ai-core 模块中所有模型服务接口抽象的一种实现。

特性

  • 生成聊天响应
  • 生成嵌入向量
  • 支持流式响应
  • 支持多种模型参数配置

安装

使用 npm 安装 AI DeepSeek 模块:

npm install @celljs/ai-deepseek

或者使用 yarn:

yarn add @celljs/ai-deepseek

快速开始

以下是一个简单的示例,展示如何使用 AI DeepSeek 模块生成聊天响应和嵌入向量:

import { AssistantMessage, PromptTemplate } from '@celljs/ai-core';
import { DeepSeekChatModel, DeepSeekModel, } from '@celljs/ai-deepseek';
import { Component Autowired } from '@celljs/core';

@Component()
export class DeepSeekDemo {
    @Autowired(DeepSeekChatModel)
    private deepSeekChatModel: DeepSeekChatModel;

    @Autowired(DeepSeekEmbeddingModel)
    private deepSeekEmbeddingModel: DeepSeekEmbeddingModel;

    @Autowired(PromptTemplate)
    private promptTemplate: PromptTemplate;

    /**
     * Chat with DeepSeek
     */
    async chat() {
        const prompt = await this.promptTemplate.create(
            'Hello {name}',
            { 
                chatOptions: { model: DeepSeekModel.DEEPSEEK_CHAT },
                variables: { name: 'DeepSeek' }
            }
        );
        const response = await this.deepSeekChatModel.call(prompt);
        console.log(response.result.output);
    }

    /**
     * Stream chat response
     */
    async stream() {
        const prompt = await this.promptTemplate.create(
            'Hello {name}',
            { 
                chatOptions: { model: DeepSeekModel.DEEPSEEK_CHAT },
                variables: { name: 'DeepSeek' }
            }
        );
        const response$ = await this.deepSeekChatModel.stream(prompt);
        response$.subscribe({
            next: response => console.log(response.result.output),
            complete: () => console.log('Chat completed!')
        });
    }

    /**
     * Embed text to vector
     */
    async embed() {
        const response = await this.deepSeekEmbeddingModel.call({
            inputs: ['text to embed'],
            options: { model: DeepSeekModel.XXX }
        });
        console.log(response.result.embeddings);
    }
}

许可证

本项目采用 MIT 许可证。

3.6.4

5 months ago

3.6.3

6 months ago

3.6.2

6 months ago

3.6.1

6 months ago

3.6.0

6 months ago

3.5.14

6 months ago

3.5.13

6 months ago

3.5.12

6 months ago

3.5.11

6 months ago

3.5.10

6 months ago

3.5.9

6 months ago

3.5.8

7 months ago

3.5.7

7 months ago

3.5.6

7 months ago

3.5.5

7 months ago

3.5.4

7 months ago

3.5.3

7 months ago

3.5.2

7 months ago

3.5.1

7 months ago