fix: remove system role from Shakespeare AI calls, embed prompt in user message instead
Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
parent
4aebbc8798
commit
ba8b65b6d9
1 changed files with 13 additions and 10 deletions
|
|
@ -225,13 +225,19 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) {
|
|||
let accumulated = '';
|
||||
|
||||
// First pass: get AI response which may include a TOOL: call
|
||||
// Inject system prompt as first user message if system role unsupported
|
||||
const messagesWithSystem = [
|
||||
{ role: 'system' as const, content: SYSTEM_PROMPT },
|
||||
...history,
|
||||
];
|
||||
// Prefix the system prompt into the first user message for compatibility
|
||||
const historyWithContext = history.length > 0
|
||||
? [
|
||||
{
|
||||
role: 'user' as const,
|
||||
content: `${SYSTEM_PROMPT}\n\n---\n\nUser question: ${history[0].content}`,
|
||||
},
|
||||
...history.slice(1),
|
||||
]
|
||||
: [{ role: 'user' as const, content: SYSTEM_PROMPT }];
|
||||
|
||||
const firstResponse = await shakespeare.sendChatMessage(
|
||||
messagesWithSystem,
|
||||
historyWithContext,
|
||||
'shakespeare'
|
||||
);
|
||||
|
||||
|
|
@ -278,12 +284,9 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) {
|
|||
setStreamingText('');
|
||||
const toolResultStr = JSON.stringify(toolResult, null, 2);
|
||||
const secondResponse = await shakespeare.sendChatMessage([
|
||||
{ role: 'system' as const, content: SYSTEM_PROMPT },
|
||||
...history,
|
||||
{ role: 'assistant' as const, content: aiText },
|
||||
{
|
||||
role: 'user' as const,
|
||||
content: `Tool result from ${toolName}:\n${toolResultStr}\n\nNow answer the user's question naturally based on this live data. Be concise and skater-friendly.`,
|
||||
content: `${SYSTEM_PROMPT}\n\n---\n\nUser asked: ${question}\n\nTool result from ${toolName}:\n${toolResultStr}\n\nNow answer the user's question naturally based on this live data. Be concise and skater-friendly.`,
|
||||
},
|
||||
], 'shakespeare');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue