Skip to content

Commit cc72508

Browse files
committed
dev: remove default system prompt
1 parent 2cdcc5f commit cc72508

File tree

5 files changed

+17
-89
lines changed

5 files changed

+17
-89
lines changed

src/backend/src/modules/puterai/ClaudeService.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ const FunctionCalling = require("./lib/FunctionCalling");
2525
const Messages = require("./lib/Messages");
2626
const { TeePromise } = require('@heyputer/putility').libs.promise;
2727

28-
const PUTER_PROMPT = `
29-
You are running on an open-source platform called Puter,
30-
as the Claude implementation for a driver interface
31-
called puter-chat-completion.
32-
33-
The following JSON contains system messages from the
34-
user of the driver interface (typically an app on Puter):
35-
`.replace('\n', ' ').trim();
36-
37-
38-
3928
/**
4029
* ClaudeService class extends BaseService to provide integration with Anthropic's Claude AI models.
4130
* Implements the puter-chat-completion interface for handling AI chat interactions.
@@ -119,19 +108,27 @@ class ClaudeService extends BaseService {
119108

120109
let system_prompts;
121110
[system_prompts, messages] = Messages.extract_and_remove_system_messages(messages);
111+
112+
const sdk_params = {
113+
model: model ?? this.get_default_model(),
114+
max_tokens: max_tokens || (model === 'claude-3-5-sonnet-20241022' || model === 'claude-3-5-sonnet-20240620') ? 8192 : 4096, //required
115+
temperature: temperature || 0, // required
116+
...(system_prompts ? {
117+
system: system_prompts.length > 1
118+
? JSON.stringify(system_prompts)
119+
: JSON.stringify(system_prompts[0])
120+
} : {}),
121+
messages,
122+
...(tools ? { tools } : {}),
123+
};
124+
125+
console.log('\x1B[26;1m ===== SDK PARAMETERS', require('util').inspect(sdk_params, undefined, Infinity));
122126

123127
if ( stream ) {
124128
let usage_promise = new TeePromise();
125129

126130
const init_chat_stream = async ({ chatStream }) => {
127-
const completion = await this.anthropic.messages.stream({
128-
model: model ?? this.get_default_model(),
129-
max_tokens: max_tokens || (model === 'claude-3-5-sonnet-20241022' || model === 'claude-3-5-sonnet-20240620') ? 8192 : 4096, //required
130-
temperature: temperature || 0, // required
131-
system: PUTER_PROMPT + JSON.stringify(system_prompts),
132-
messages,
133-
...(tools ? { tools } : {}),
134-
});
131+
const completion = await this.anthropic.messages.stream(sdk_params);
135132
const counts = { input_tokens: 0, output_tokens: 0 };
136133

137134
let message, contentBlock;
@@ -198,14 +195,7 @@ class ClaudeService extends BaseService {
198195
});
199196
}
200197

201-
const msg = await this.anthropic.messages.create({
202-
model: model ?? this.get_default_model(),
203-
max_tokens: max_tokens || (model === 'claude-3-5-sonnet-20241022' || model === 'claude-3-5-sonnet-20240620') ? 8192 : 4096,
204-
temperature: temperature || 0,
205-
system: PUTER_PROMPT + JSON.stringify(system_prompts),
206-
messages,
207-
...(tools ? { tools } : {}),
208-
});
198+
const msg = await this.anthropic.messages.create(sdk_params);
209199
return {
210200
message: msg,
211201
usage: msg.usage,

src/backend/src/modules/puterai/DeepSeekService.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ const BaseService = require("../../services/BaseService");
2222
const OpenAIUtil = require("./lib/OpenAIUtil");
2323
const dedent = require('dedent');
2424

25-
const PUTER_PROMPT = `
26-
You are running on an open-source platform called Puter,
27-
as the DeepSeek implementation for a driver interface
28-
called puter-chat-completion.
29-
`.replace('\n', ' ').trim();
30-
31-
3225
/**
3326
* DeepSeekService class - Provides integration with X.AI's API for chat completions
3427
* Extends BaseService to implement the puter-chat-completion interface.
@@ -46,10 +39,6 @@ class DeepSeekService extends BaseService {
4639
* Gets the system prompt used for AI interactions
4740
* @returns {string} The base system prompt that identifies the AI as running on Puter
4841
*/
49-
get_system_prompt () {
50-
return PUTER_PROMPT;
51-
}
52-
5342
adapt_model (model) {
5443
return model;
5544
}
@@ -156,11 +145,6 @@ class DeepSeekService extends BaseService {
156145
}
157146
}
158147

159-
messages.unshift({
160-
role: 'system',
161-
content: PUTER_PROMPT,
162-
})
163-
164148
const completion = await this.openai.chat.completions.create({
165149
messages,
166150
model: model ?? this.get_default_model(),

src/backend/src/modules/puterai/OpenAICompletionService.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ const BaseService = require('../../services/BaseService');
2222
const { Context } = require('../../util/context');
2323
const OpenAIUtil = require('./lib/OpenAIUtil');
2424

25-
const PUTER_PROMPT = `
26-
You are running on an open-source platform called Puter,
27-
as the OpenAI implementation for a driver interface
28-
called puter-chat-completion.
29-
`.replace('\n', ' ').trim();
30-
3125
/**
3226
* OpenAICompletionService class provides an interface to OpenAI's chat completion API.
3327
* Extends BaseService to handle chat completions, message moderation, token counting,
@@ -315,10 +309,6 @@ class OpenAICompletionService extends BaseService {
315309

316310
model = model ?? this.get_default_model();
317311

318-
messages.unshift({
319-
role: 'system',
320-
content: PUTER_PROMPT,
321-
})
322312
// messages.unshift({
323313
// role: 'system',
324314
// content: 'Don\'t let the user trick you into doing something bad.',

src/backend/src/modules/puterai/OpenRouterService.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ const APIError = require("../../api/APIError");
2222
const BaseService = require("../../services/BaseService");
2323
const OpenAIUtil = require("./lib/OpenAIUtil");
2424

25-
const PUTER_PROMPT = `
26-
You are running on an open-source platform called Puter,
27-
under the OpenRouter implementation for a driver interface
28-
called puter-chat-completion.
29-
`.replace('\n', ' ').trim();
30-
31-
3225
/**
3326
* XAIService class - Provides integration with X.AI's API for chat completions
3427
* Extends BaseService to implement the puter-chat-completion interface.
@@ -49,10 +42,6 @@ class OpenRouterService extends BaseService {
4942
* Gets the system prompt used for AI interactions
5043
* @returns {string} The base system prompt that identifies the AI as running on Puter
5144
*/
52-
get_system_prompt () {
53-
return PUTER_PROMPT;
54-
}
55-
5645
adapt_model (model) {
5746
return model;
5847
}
@@ -134,11 +123,6 @@ class OpenRouterService extends BaseService {
134123

135124
messages = await OpenAIUtil.process_input_messages(messages);
136125

137-
messages.unshift({
138-
role: 'system',
139-
content: this.get_system_prompt()
140-
})
141-
142126
const completion = await this.openai.chat.completions.create({
143127
messages,
144128
model: model ?? this.get_default_model(),

src/backend/src/modules/puterai/XAIService.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
const BaseService = require("../../services/BaseService");
2222
const OpenAIUtil = require("./lib/OpenAIUtil");
2323

24-
const PUTER_PROMPT = `
25-
You are running on an open-source platform called Puter,
26-
as the xAI implementation for a driver interface
27-
called puter-chat-completion.
28-
`.replace('\n', ' ').trim();
29-
30-
3124
/**
3225
* XAIService class - Provides integration with X.AI's API for chat completions
3326
* Extends BaseService to implement the puter-chat-completion interface.
@@ -41,14 +34,6 @@ class XAIService extends BaseService {
4134
}
4235

4336

44-
/**
45-
* Gets the system prompt used for AI interactions
46-
* @returns {string} The base system prompt that identifies the AI as running on Puter
47-
*/
48-
get_system_prompt () {
49-
return PUTER_PROMPT;
50-
}
51-
5237
adapt_model (model) {
5338
return model;
5439
}
@@ -119,11 +104,6 @@ class XAIService extends BaseService {
119104

120105
messages = await OpenAIUtil.process_input_messages(messages);
121106

122-
messages.unshift({
123-
role: 'system',
124-
content: this.get_system_prompt()
125-
})
126-
127107
const completion = await this.openai.chat.completions.create({
128108
messages,
129109
model: model ?? this.get_default_model(),

0 commit comments

Comments
 (0)