fix(app): use callable fetch adapter type (#535)
This commit is contained in:
parent
780221b006
commit
97bc86fa70
|
|
@ -2,6 +2,7 @@ import type { LanguageModel } from 'ai'
|
|||
|
||||
import { modelProviderAdapter } from '@/app/ai/providers/registry'
|
||||
import type { ModelConfig } from '@/app/ai/providers/types'
|
||||
import type { FetchFunction } from '@/app/http/types'
|
||||
import { isTauri } from '@/app/tauri/env'
|
||||
import { tauriFetch } from '@/app/tauri/http'
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ export function resolveLanguageModelID(
|
|||
return config.modelID
|
||||
}
|
||||
|
||||
function desktopFetch(): typeof fetch | undefined {
|
||||
function desktopFetch(): FetchFunction | undefined {
|
||||
return isTauri() ? tauriFetch : undefined
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import type { LanguageModel } from 'ai'
|
|||
|
||||
import type { AIProviderID } from '@open-pencil/core/constants'
|
||||
|
||||
import type { FetchFunction } from '@/app/http/types'
|
||||
|
||||
export type ModelConfig = {
|
||||
providerID: AIProviderID
|
||||
apiKey: string
|
||||
|
|
@ -12,7 +14,7 @@ export type ModelConfig = {
|
|||
}
|
||||
|
||||
export type ModelProviderRuntime = {
|
||||
fetch?: typeof fetch
|
||||
fetch?: FetchFunction
|
||||
}
|
||||
|
||||
export interface ModelProviderAdapter {
|
||||
|
|
|
|||
1
src/app/http/types.ts
Normal file
1
src/app/http/types.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import type { FetchFunction } from '@/app/http/types'
|
||||
|
||||
export interface ProxyHttpHeader {
|
||||
name: string
|
||||
value: string
|
||||
|
|
@ -72,7 +74,7 @@ export interface TauriFetchOptions {
|
|||
maxResponseBytes?: number
|
||||
}
|
||||
|
||||
export function createTauriFetch(options: TauriFetchOptions = {}): typeof fetch {
|
||||
export function createTauriFetch(options: TauriFetchOptions = {}): FetchFunction {
|
||||
return (input, init) => tauriFetch(input, init, options.maxResponseBytes, options.timeoutMs)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue