Add common endpoint support and system prompt injection, v1.1.0

- Add common endpoint type for GLM-4.6 model
- Implement automatic system prompt injection for all requests
- Simplify README documentation for better user focus
- Update version to 1.1.0
- Add *.txt to .gitignore

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
1e0n
2025-10-07 21:06:28 +08:00
parent 5fc2df4cd7
commit 43803ca9da
9 changed files with 260 additions and 363 deletions

View File

@@ -1,4 +1,5 @@
import { logDebug } from '../logger.js';
import { getSystemPrompt } from '../config.js';
export function transformToAnthropic(openaiRequest) {
logDebug('Transforming OpenAI request to Anthropic format');
@@ -77,9 +78,19 @@ export function transformToAnthropic(openaiRequest) {
}
}
// Add system parameter if system content exists
if (systemContent.length > 0) {
anthropicRequest.system = systemContent;
// Add system parameter with system prompt prepended
const systemPrompt = getSystemPrompt();
if (systemPrompt || systemContent.length > 0) {
anthropicRequest.system = [];
// Prepend system prompt as first element if it exists
if (systemPrompt) {
anthropicRequest.system.push({
type: 'text',
text: systemPrompt
});
}
// Add user-provided system content
anthropicRequest.system.push(...systemContent);
}
// Transform tools if present
@@ -125,11 +136,11 @@ export function getAnthropicHeaders(authHeader, clientHeaders = {}, isStreaming
'anthropic-beta': 'interleaved-thinking-2025-05-14',
'x-api-key': 'placeholder',
'authorization': authHeader || '',
'x-model-provider': 'anthropic',
'x-api-provider': 'anthropic',
'x-factory-client': 'cli',
'x-session-id': sessionId,
'x-assistant-message-id': messageId,
'user-agent': 'a$/JS 0.57.0',
'user-agent': 'uX/JS 0.57.0',
'x-stainless-timeout': '600',
'connection': 'keep-alive'
};