-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.ts
More file actions
25 lines (24 loc) · 960 Bytes
/
Copy pathbackend.ts
File metadata and controls
25 lines (24 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type { JSONSchema7Object } from "json-schema"
import type { OpenAIOutput } from "./types"
/**
* Provider-agnostic LLM backend interface used by the summarizer and
* location parser. Implementations include {@link createOpenAiBackend} and
* {@link createAnthropicBackend}; consumers can also supply their own (e.g.
* an Azure OpenAI gateway, a Bedrock adapter, a deterministic fake for
* tests) as long as they satisfy this shape.
*
* Instances are produced by factory functions so API keys and model choices
* live in consumer code, never in module-level state.
*/
export interface LlmBackend {
readonly model: string
readonly tokenLimit: number
countTokens(text: string): number
chatCompletion(content: string): Promise<OpenAIOutput<string>>
chatFunctionJson<T>(
systemMessage: string,
userMessage: string,
schema: JSONSchema7Object,
functionName: string,
): Promise<OpenAIOutput<T>>
}