Skip to content

Commit

Permalink
chat: add deepseek support (fixes #8140) (#8141)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
Mutugiii and dogi authored Jan 28, 2025
1 parent 6a8226f commit 538b844
Showing 9 changed files with 22 additions and 10 deletions.
8 changes: 5 additions & 3 deletions chatapi/README.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions chatapi/src/config/ai-providers.config.ts
Original file line number Diff line number Diff line change
@@ -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 || '' },
};

1 change: 1 addition & 0 deletions chatapi/src/index.ts
Original file line number Diff line number Diff line change
@@ -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
});
});
1 change: 1 addition & 0 deletions chatapi/src/models/ai-providers.model.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ interface Assistant {
interface Providers {
openai?: string;
perplexity?: string;
deepseek?: string;
gemini?: string;
}

4 changes: 2 additions & 2 deletions chatapi/src/utils/chat-helpers.utils.ts
Original file line number Diff line number Diff line change
@@ -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(
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.16.81",
"version": "0.16.82",
"myplanet": {
"latest": "v0.22.45",
"min": "v0.21.45"
"latest": "v0.22.51",
"min": "v0.21.51"
},
"scripts": {
"ng": "ng",
3 changes: 2 additions & 1 deletion src/app/chat/chat.model.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions src/app/configuration/configuration.component.ts
Original file line number Diff line number Diff line change
@@ -233,11 +233,13 @@ export class ConfigurationComponent implements OnInit {
keys: {
openai: '',
perplexity: '',
deepseek: '',
gemini: ''
},
models: {
openai: '',
perplexity: '',
deepseek: '',
gemini: ''
},
assistant: {
2 changes: 1 addition & 1 deletion src/app/shared/chat.service.ts
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit 538b844

Please sign in to comment.