feat(hooks): add useAgentClient hook for agent API client initialization
This commit is contained in:
15
src/renderer/src/hooks/agents/useAgentClient.ts
Normal file
15
src/renderer/src/hooks/agents/useAgentClient.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { AgentApiClient } from '@renderer/api/agent'
|
||||
|
||||
import { useSettings } from '../useSettings'
|
||||
|
||||
export const useAgentClient = () => {
|
||||
const { apiServer } = useSettings()
|
||||
const { host, port, apiKey } = apiServer
|
||||
const client = new AgentApiClient({
|
||||
baseURL: `${host}:${port}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`
|
||||
}
|
||||
})
|
||||
return client
|
||||
}
|
||||
Reference in New Issue
Block a user