From 18d0f1ce7c56928bdb73ca820d29fe0e3fcc65e5 Mon Sep 17 00:00:00 2001 From: mutugiii Date: Fri, 24 Jan 2025 16:44:18 +0300 Subject: [PATCH 1/2] add deepseek support --- chatapi/README.md | 8 +++++--- chatapi/src/config/ai-providers.config.ts | 5 +++++ chatapi/src/index.ts | 1 + chatapi/src/models/ai-providers.model.ts | 1 + chatapi/src/utils/chat-helpers.utils.ts | 4 ++-- src/app/chat/chat.model.ts | 3 ++- src/app/configuration/configuration.component.ts | 2 ++ src/app/shared/chat.service.ts | 2 +- 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/chatapi/README.md b/chatapi/README.md index e179b40ee6..7bdc4876d5 100644 --- a/chatapi/README.md +++ b/chatapi/README.md @@ -5,6 +5,7 @@ Ensure you have set the chatapi configs via the manager -> AI Configurations or For model choices view: Openai: https://platform.openai.com/docs/models Perplexity: https://docs.perplexity.ai/guides/model-cards + deepseek: https://api-docs.deepseek.com/quick_start/pricing Gemini: https://deepmind.google/technologies/gemini/ @@ -68,7 +69,7 @@ In the production environment these configs are set in the `planet.yml` file. - **assistant**: boolean(required) -> Set to true if you want to use the assistants endpoint - **context**: string(optional) -> The text context you would like to pre-load the AI Assistant with - **aiProvider**: Object(required) - - **name**: string(required) -> Name of the API provider to choose from i.e openai, perplexity or gemini. + - **name**: string(required) -> Name of the API provider to choose from i.e openai, perplexity, deepseek or gemini. - **model**: string(optional) -> Name of the specific provider model to use. - **_id**: couchdb document id - **_rev**: couchdb revision id @@ -99,7 +100,8 @@ In the production environment these configs are set in the `planet.yml` file. ``` { "openai": true, - "perplexity": false, + "perplexity": true, + "deepseek": true, "gemini": true } ``` @@ -110,7 +112,7 @@ In the production environment these configs are set in the `planet.yml` file. **Description**: Establishes a WebSocket connection for real-time chat. **Usage**: Connect via WebSocket and send JSON messages containing chat data. Responses will be provided through the WebSocket connection. -aiProviders supported: openai, perplexity, and gemini. +aiProviders supported: openai, perplexity, deepseek and gemini. any provider model supported by the provider can be used. - Request json sample diff --git a/chatapi/src/config/ai-providers.config.ts b/chatapi/src/config/ai-providers.config.ts index d1c4d3a032..34efbbfb54 100644 --- a/chatapi/src/config/ai-providers.config.ts +++ b/chatapi/src/config/ai-providers.config.ts @@ -38,12 +38,17 @@ const initialize = async () => { 'apiKey': doc?.keys.perplexity || '', 'baseURL': 'https://api.perplexity.ai', }), + 'deepseek': new OpenAI({ + 'apiKey': doc?.keys.deepseek || '', + 'baseURL': 'https://api.deepseek.com', + }), 'gemini': new GoogleGenerativeAI(doc?.keys.gemini || '') }; models = { 'openai': { 'ai': keys.openai, 'defaultModel': doc?.models.openai || '' }, 'perplexity': { 'ai': keys.perplexity, 'defaultModel': doc?.models.perplexity || '' }, + 'deepseek': { 'ai': keys.deepseek, 'defaultModel': doc?.models.deepseek || '' }, 'gemini': { 'ai': keys.gemini, 'defaultModel': doc?.models.gemini || '' }, }; diff --git a/chatapi/src/index.ts b/chatapi/src/index.ts index 84f6603df3..28e8e838a8 100644 --- a/chatapi/src/index.ts +++ b/chatapi/src/index.ts @@ -88,6 +88,7 @@ app.get('/checkproviders', async (req: any, res: any) => { res.status(200).json({ 'openai': keys.openai.apiKey ? true : false, 'perplexity': keys.perplexity.apiKey ? true : false, + 'deepseek': keys.deepseek.apiKey ? true : false, 'gemini': keys.gemini.apiKey ? true : false }); }); diff --git a/chatapi/src/models/ai-providers.model.ts b/chatapi/src/models/ai-providers.model.ts index 059563ea26..b5242594bf 100644 --- a/chatapi/src/models/ai-providers.model.ts +++ b/chatapi/src/models/ai-providers.model.ts @@ -13,6 +13,7 @@ interface Assistant { interface Providers { openai?: string; perplexity?: string; + deepseek?: string; gemini?: string; } diff --git a/chatapi/src/utils/chat-helpers.utils.ts b/chatapi/src/utils/chat-helpers.utils.ts index 97a2dc3407..87ae0f4f0f 100644 --- a/chatapi/src/utils/chat-helpers.utils.ts +++ b/chatapi/src/utils/chat-helpers.utils.ts @@ -54,7 +54,7 @@ async function handleGemini( /** * Uses openai's completions endpoint to generate chat completions with streaming enabled * @param messages - Array of chat messages - * @param aiProvider - AI provider option(openai, perplexity, gemini) + * @param aiProvider - AI provider option * @returns Completion text */ export async function aiChatStream( @@ -115,7 +115,7 @@ export async function aiChatStream( /** * Uses openai's completions endpoint to generate chat completions with streaming disabled * @param messages - Array of chat messages - * @param aiProvider - AI provider option(openai, perplexity, gemini) + * @param aiProvider - AI provider option * @returns Completion text */ export async function aiChatNonStream( diff --git a/src/app/chat/chat.model.ts b/src/app/chat/chat.model.ts index f4566fcbc6..295d7fc38a 100644 --- a/src/app/chat/chat.model.ts +++ b/src/app/chat/chat.model.ts @@ -24,7 +24,7 @@ export interface Message { response: string; } -export type ProviderName = 'openai' | 'perplexity' | 'gemini'; +export type ProviderName = 'openai' | 'perplexity' | 'deepseek' | 'gemini'; export interface AIProvider { name: string; @@ -34,5 +34,6 @@ export interface AIProvider { export interface AIServices { openai: boolean; perplexity: boolean; + deepseek: boolean; gemini: boolean; } diff --git a/src/app/configuration/configuration.component.ts b/src/app/configuration/configuration.component.ts index fbd11c2e19..8ab159e3fa 100644 --- a/src/app/configuration/configuration.component.ts +++ b/src/app/configuration/configuration.component.ts @@ -233,11 +233,13 @@ export class ConfigurationComponent implements OnInit { keys: { openai: '', perplexity: '', + deepseek: '', gemini: '' }, models: { openai: '', perplexity: '', + deepseek: '', gemini: '' }, assistant: { diff --git a/src/app/shared/chat.service.ts b/src/app/shared/chat.service.ts index fa95048284..9696bab5c2 100644 --- a/src/app/shared/chat.service.ts +++ b/src/app/shared/chat.service.ts @@ -57,7 +57,7 @@ import { AIServices, AIProvider } from '../chat/chat.model'; .pipe( catchError((err) => { console.error(err); - return of({ openai: false, perplexity: false, gemini: false }); + return of({ openai: false, perplexity: false, deepseek: false, gemini: false }); }), map((services: AIServices) => { if (services) { From e24cdca3441363e7e5ad86ef885b0fe5fc8c83d3 Mon Sep 17 00:00:00 2001 From: dogi Date: Tue, 28 Jan 2025 16:01:51 -0500 Subject: [PATCH 2/2] Update package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 237c6a96b4..bafd567d98 100755 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "planet", "license": "AGPL-3.0", - "version": "0.16.76", + "version": "0.16.82", "myplanet": { - "latest": "v0.22.33", - "min": "v0.21.33" + "latest": "v0.22.51", + "min": "v0.21.51" }, "scripts": { "ng": "ng",