mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 22:03:45 +00:00
feat: custom provider support with streamSimple
- Add resetApiProviders() to clear and re-register built-in providers - Add createAssistantMessageEventStream() factory for extensions - Add streamSimple support in ProviderConfig for custom API implementations - Call resetApiProviders() on /reload to clean up extension providers - Add custom-provider.md documentation - Add custom-provider.ts example with full Anthropic implementation - Update extensions.md with streamSimple config option
This commit is contained in:
parent
c06163bc59
commit
177c694406
11 changed files with 1243 additions and 69 deletions
|
|
@ -16,10 +16,13 @@ import type {
|
|||
} from "@mariozechner/pi-agent-core";
|
||||
import type {
|
||||
Api,
|
||||
AssistantMessageEventStream,
|
||||
Context,
|
||||
ImageContent,
|
||||
Model,
|
||||
OAuthCredentials,
|
||||
OAuthLoginCallbacks,
|
||||
SimpleStreamOptions,
|
||||
TextContent,
|
||||
ToolResultMessage,
|
||||
} from "@mariozechner/pi-ai";
|
||||
|
|
@ -872,6 +875,7 @@ export interface ExtensionAPI {
|
|||
* If `models` is provided: replaces all existing models for this provider.
|
||||
* If only `baseUrl` is provided: overrides the URL for existing models.
|
||||
* If `oauth` is provided: registers OAuth provider for /login support.
|
||||
* If `streamSimple` is provided: registers a custom API stream handler.
|
||||
*
|
||||
* @example
|
||||
* // Register a new provider with custom models
|
||||
|
|
@ -930,6 +934,8 @@ export interface ProviderConfig {
|
|||
apiKey?: string;
|
||||
/** API type. Required at provider or model level when defining models. */
|
||||
api?: Api;
|
||||
/** Optional streamSimple handler for custom APIs. */
|
||||
streamSimple?: (model: Model<Api>, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStream;
|
||||
/** Custom headers to include in requests. */
|
||||
headers?: Record<string, string>;
|
||||
/** If true, adds Authorization: Bearer header with the resolved API key. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue