mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { getGlobalModelOptions } from '@/hermes'
|
|
|
|
import { requestModelOptions } from './model-options'
|
|
|
|
const globalOptions = { model: 'hermes-4', provider: 'nous', providers: [] }
|
|
|
|
vi.mock('@/hermes', () => ({
|
|
getGlobalModelOptions: vi.fn(() => Promise.resolve(globalOptions))
|
|
}))
|
|
|
|
describe('requestModelOptions', () => {
|
|
afterEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('uses the connected gateway even before a session exists', async () => {
|
|
const gatewayPayload = { model: 'BeastMode', provider: 'moa', providers: [] }
|
|
|
|
const gateway = {
|
|
request: vi.fn(() => Promise.resolve(gatewayPayload))
|
|
}
|
|
|
|
await expect(requestModelOptions({ gateway: gateway as never, sessionId: null })).resolves.toBe(gatewayPayload)
|
|
|
|
expect(gateway.request).toHaveBeenCalledWith('model.options', { explicit_only: true })
|
|
expect(getGlobalModelOptions).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('passes the active session id and refresh flag through the gateway', async () => {
|
|
const gateway = {
|
|
request: vi.fn(() => Promise.resolve(globalOptions))
|
|
}
|
|
|
|
await requestModelOptions({ gateway: gateway as never, refresh: true, sessionId: 'session-1' })
|
|
|
|
expect(gateway.request).toHaveBeenCalledWith('model.options', {
|
|
explicit_only: true,
|
|
refresh: true,
|
|
session_id: 'session-1'
|
|
})
|
|
})
|
|
|
|
it('falls back to REST when no gateway is connected', async () => {
|
|
await requestModelOptions({ refresh: true })
|
|
|
|
expect(getGlobalModelOptions).toHaveBeenCalledWith({ explicitOnly: true, refresh: true })
|
|
})
|
|
})
|