fix: jan should have a general assistant instruction (#5872)
* fix: default Jan assistant prompt * test: update tests
This commit is contained in:
parent
3afdd0fa1d
commit
af116dd7dc
@ -75,7 +75,7 @@ export default class JanAssistantExtension extends AssistantExtension {
|
||||
'Jan is a helpful desktop assistant that can reason through complex tasks and use tools to complete them on the user’s behalf.',
|
||||
model: '*',
|
||||
instructions:
|
||||
'You have access to a set of tools to help you answer the user’s question. You can use only one tool per message, and you’ll receive the result of that tool in the user’s next response. To complete a task, use tools step by step—each step should be guided by the outcome of the previous one.\nTool Usage Rules:\n1. Always provide the correct values as arguments when using tools. Do not pass variable names—use actual values instead.\n2. You may perform multiple tool steps to complete a task.\n3. Avoid repeating a tool call with exactly the same parameters to prevent infinite loops.',
|
||||
'You are a helpful AI assistant. Your primary goal is to assist users with their questions and tasks to the best of your abilities.\n\nWhen responding:\n- Answer directly from your knowledge when you can\n- Be concise, clear, and helpful\n- Admit when you’re unsure rather than making things up\n\nIf tools are available to you:\n- Only use tools when they add real value to your response\n- Use tools when the user explicitly asks (e.g., "search for...", "calculate...", "run this code")\n- Use tools for information you don’t know or that needs verification\n- Never use tools just because they’re available\n\nWhen using tools:\n- Use one tool at a time and wait for results\n- Use actual values as arguments, not variable names\n- Learn from each result before deciding next steps\n- Avoid repeating the same tool call with identical parameters\n\nRemember: Most questions can be answered without tools. Think first whether you need them.',
|
||||
tools: [
|
||||
{
|
||||
type: 'retrieval',
|
||||
|
||||
@ -22,14 +22,14 @@ describe('useAssistant', () => {
|
||||
|
||||
it('should initialize with default state', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
expect(result.current.assistants).toEqual([defaultAssistant])
|
||||
expect(result.current.currentAssistant).toEqual(defaultAssistant)
|
||||
})
|
||||
|
||||
it('should add assistant', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const newAssistant = {
|
||||
id: 'assistant-2',
|
||||
name: 'New Assistant',
|
||||
@ -37,37 +37,37 @@ describe('useAssistant', () => {
|
||||
description: 'A new assistant',
|
||||
instructions: 'Help the user',
|
||||
created_at: Date.now(),
|
||||
parameters: {}
|
||||
parameters: {},
|
||||
}
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.addAssistant(newAssistant)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants).toHaveLength(2)
|
||||
expect(result.current.assistants).toContain(newAssistant)
|
||||
})
|
||||
|
||||
it('should update assistant', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const updatedAssistant = {
|
||||
...defaultAssistant,
|
||||
name: 'Updated Jan',
|
||||
description: 'Updated description'
|
||||
description: 'Updated description',
|
||||
}
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.updateAssistant(updatedAssistant)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants[0].name).toBe('Updated Jan')
|
||||
expect(result.current.assistants[0].description).toBe('Updated description')
|
||||
})
|
||||
|
||||
it('should delete assistant', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const assistant2 = {
|
||||
id: 'assistant-2',
|
||||
name: 'Assistant 2',
|
||||
@ -75,26 +75,26 @@ describe('useAssistant', () => {
|
||||
description: 'Second assistant',
|
||||
instructions: 'Help the user',
|
||||
created_at: Date.now(),
|
||||
parameters: {}
|
||||
parameters: {},
|
||||
}
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.addAssistant(assistant2)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants).toHaveLength(2)
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.deleteAssistant('assistant-2')
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants).toHaveLength(1)
|
||||
expect(result.current.assistants[0].id).toBe('jan')
|
||||
})
|
||||
|
||||
it('should set current assistant', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const newAssistant = {
|
||||
id: 'assistant-2',
|
||||
name: 'New Current Assistant',
|
||||
@ -102,19 +102,19 @@ describe('useAssistant', () => {
|
||||
description: 'New current assistant',
|
||||
instructions: 'Help the user',
|
||||
created_at: Date.now(),
|
||||
parameters: {}
|
||||
parameters: {},
|
||||
}
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.setCurrentAssistant(newAssistant)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.currentAssistant).toEqual(newAssistant)
|
||||
})
|
||||
|
||||
it('should set assistants', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const assistants = [
|
||||
{
|
||||
id: 'assistant-1',
|
||||
@ -123,7 +123,7 @@ describe('useAssistant', () => {
|
||||
description: 'First assistant',
|
||||
instructions: 'Help the user',
|
||||
created_at: Date.now(),
|
||||
parameters: {}
|
||||
parameters: {},
|
||||
},
|
||||
{
|
||||
id: 'assistant-2',
|
||||
@ -132,52 +132,56 @@ describe('useAssistant', () => {
|
||||
description: 'Second assistant',
|
||||
instructions: 'Help with tasks',
|
||||
created_at: Date.now(),
|
||||
parameters: {}
|
||||
}
|
||||
parameters: {},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.setAssistants(assistants)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants).toEqual(assistants)
|
||||
expect(result.current.assistants).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('should maintain assistant structure', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
expect(result.current.currentAssistant.id).toBe('jan')
|
||||
expect(result.current.currentAssistant.name).toBe('Jan')
|
||||
expect(result.current.currentAssistant.avatar).toBe('👋')
|
||||
expect(result.current.currentAssistant.description).toContain('helpful desktop assistant')
|
||||
expect(result.current.currentAssistant.instructions).toContain('access to a set of tools')
|
||||
expect(result.current.currentAssistant.description).toContain(
|
||||
'helpful desktop assistant'
|
||||
)
|
||||
expect(result.current.currentAssistant.instructions).toContain(
|
||||
'Only use tools when they add real value to your response'
|
||||
)
|
||||
expect(typeof result.current.currentAssistant.created_at).toBe('number')
|
||||
expect(typeof result.current.currentAssistant.parameters).toBe('object')
|
||||
})
|
||||
|
||||
it('should handle empty assistants list', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.setAssistants([])
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.assistants).toEqual([])
|
||||
})
|
||||
|
||||
it('should update assistant in current assistant if it matches', () => {
|
||||
const { result } = renderHook(() => useAssistant())
|
||||
|
||||
|
||||
const updatedDefaultAssistant = {
|
||||
...defaultAssistant,
|
||||
name: 'Updated Jan Name'
|
||||
name: 'Updated Jan Name',
|
||||
}
|
||||
|
||||
|
||||
act(() => {
|
||||
result.current.updateAssistant(updatedDefaultAssistant)
|
||||
})
|
||||
|
||||
|
||||
expect(result.current.currentAssistant.name).toBe('Updated Jan Name')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -21,7 +21,7 @@ export const defaultAssistant: Assistant = {
|
||||
description:
|
||||
'Jan is a helpful desktop assistant that can reason through complex tasks and use tools to complete them on the user’s behalf.',
|
||||
instructions:
|
||||
'You have access to a set of tools to help you answer the user’s question. You can use only one tool per message, and you’ll receive the result of that tool in the user’s next response. To complete a task, use tools step by step—each step should be guided by the outcome of the previous one.\nTool Usage Rules:\n1. Always provide the correct values as arguments when using tools. Do not pass variable names—use actual values instead.\n2. You may perform multiple tool steps to complete a task.\n3. Avoid repeating a tool call with exactly the same parameters to prevent infinite loops.',
|
||||
'You are a helpful AI assistant. Your primary goal is to assist users with their questions and tasks to the best of your abilities.\n\nWhen responding:\n- Answer directly from your knowledge when you can\n- Be concise, clear, and helpful\n- Admit when you’re unsure rather than making things up\n\nIf tools are available to you:\n- Only use tools when they add real value to your response\n- Use tools when the user explicitly asks (e.g., "search for...", "calculate...", "run this code")\n- Use tools for information you don’t know or that needs verification\n- Never use tools just because they’re available\n\nWhen using tools:\n- Use one tool at a time and wait for results\n- Use actual values as arguments, not variable names\n- Learn from each result before deciding next steps\n- Avoid repeating the same tool call with identical parameters\n\nRemember: Most questions can be answered without tools. Think first whether you need them.',
|
||||
}
|
||||
|
||||
export const useAssistant = create<AssistantState>()((set, get) => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user