deepseek-agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +23 -0
- package/dist/index.js +42 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface AgentConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Message {
|
|
7
|
+
role: 'user' | 'assistant' | 'system';
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentResponse {
|
|
11
|
+
content: string;
|
|
12
|
+
usage?: {
|
|
13
|
+
promptTokens: number;
|
|
14
|
+
completionTokens: number;
|
|
15
|
+
totalTokens: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare class DeepSeekAgent {
|
|
19
|
+
private config;
|
|
20
|
+
constructor(config: AgentConfig);
|
|
21
|
+
chat(messages: Message[]): Promise<AgentResponse>;
|
|
22
|
+
}
|
|
23
|
+
export default DeepSeekAgent;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeepSeekAgent = void 0;
|
|
4
|
+
class DeepSeekAgent {
|
|
5
|
+
config;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = {
|
|
8
|
+
apiKey: config.apiKey,
|
|
9
|
+
baseUrl: config.baseUrl ?? 'https://api.deepseek.com',
|
|
10
|
+
model: config.model ?? 'deepseek-chat',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async chat(messages) {
|
|
14
|
+
const response = await fetch(`${this.config.baseUrl}/v1/chat/completions`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
model: this.config.model,
|
|
22
|
+
messages,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`DeepSeek API error: ${response.status} ${response.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
const data = (await response.json());
|
|
29
|
+
return {
|
|
30
|
+
content: data.choices[0].message.content,
|
|
31
|
+
usage: data.usage
|
|
32
|
+
? {
|
|
33
|
+
promptTokens: data.usage.prompt_tokens,
|
|
34
|
+
completionTokens: data.usage.completion_tokens,
|
|
35
|
+
totalTokens: data.usage.total_tokens,
|
|
36
|
+
}
|
|
37
|
+
: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.DeepSeekAgent = DeepSeekAgent;
|
|
42
|
+
exports.default = DeepSeekAgent;
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepseek-agent",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "DeepSeek Agent SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"deepseek",
|
|
16
|
+
"agent",
|
|
17
|
+
"sdk",
|
|
18
|
+
"ai"
|
|
19
|
+
],
|
|
20
|
+
"author": "bb-boy680",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^25.9.3",
|
|
24
|
+
"typescript": "^6.0.3"
|
|
25
|
+
}
|
|
26
|
+
}
|