fix(app): use callable fetch adapter type (#535)

This commit is contained in:
Danila Poyarkov 2026-08-16 13:40:44 +03:00 committed by GitHub
parent 780221b006
commit 97bc86fa70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View file

@ -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
}

View file

@ -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
View file

@ -0,0 +1 @@
export type FetchFunction = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>

View file

@ -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)
}