context_management: handle summarization in UI (#2377)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
||||
import type { GetToolsData, GetToolsResponse, ReadAllConfigData, ReadAllConfigResponse, BackupConfigData, BackupConfigResponse, GetExtensionsData, GetExtensionsResponse, AddExtensionData, AddExtensionResponse, RemoveExtensionData, RemoveExtensionResponse, InitConfigData, InitConfigResponse, UpsertPermissionsData, UpsertPermissionsResponse, ProvidersData, ProvidersResponse2, ReadConfigData, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse, ConfirmPermissionData } from './types.gen';
|
||||
import type { GetToolsData, GetToolsResponse, ReadAllConfigData, ReadAllConfigResponse, BackupConfigData, BackupConfigResponse, GetExtensionsData, GetExtensionsResponse, AddExtensionData, AddExtensionResponse, RemoveExtensionData, RemoveExtensionResponse, InitConfigData, InitConfigResponse, UpsertPermissionsData, UpsertPermissionsResponse, ProvidersData, ProvidersResponse2, ReadConfigData, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse, ConfirmPermissionData, ManageContextData, ManageContextResponse } from './types.gen';
|
||||
import { client as _heyApiClient } from './client.gen';
|
||||
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
||||
@@ -131,4 +131,15 @@ export const confirmPermission = <ThrowOnError extends boolean = false>(options:
|
||||
...options?.headers
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const manageContext = <ThrowOnError extends boolean = false>(options: Options<ManageContextData, ThrowOnError>) => {
|
||||
return (options.client ?? _heyApiClient).post<ManageContextResponse, unknown, ThrowOnError>({
|
||||
url: '/context/manage',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,11 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type Annotations = {
|
||||
audience?: Array<Role> | null;
|
||||
priority?: number | null;
|
||||
timestamp?: string;
|
||||
};
|
||||
|
||||
export type ConfigKey = {
|
||||
default?: string | null;
|
||||
name: string;
|
||||
@@ -16,6 +22,51 @@ export type ConfigResponse = {
|
||||
config: {};
|
||||
};
|
||||
|
||||
export type Content = (TextContent & {
|
||||
type: 'text';
|
||||
}) | (ImageContent & {
|
||||
type: 'image';
|
||||
}) | (EmbeddedResource & {
|
||||
type: 'resource';
|
||||
});
|
||||
|
||||
export type ContextLengthExceeded = {
|
||||
msg: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Request payload for context management operations
|
||||
*/
|
||||
export type ContextManageRequest = {
|
||||
/**
|
||||
* Operation to perform: "truncation" or "summarize"
|
||||
*/
|
||||
manageAction: string;
|
||||
/**
|
||||
* Collection of messages to be managed
|
||||
*/
|
||||
messages: Array<Message>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Response from context management operations
|
||||
*/
|
||||
export type ContextManageResponse = {
|
||||
/**
|
||||
* Processed messages after the operation
|
||||
*/
|
||||
messages: Array<Message>;
|
||||
/**
|
||||
* Token counts for each processed message
|
||||
*/
|
||||
tokenCounts: Array<number>;
|
||||
};
|
||||
|
||||
export type EmbeddedResource = {
|
||||
annotations?: Annotations | null;
|
||||
resource: ResourceContents;
|
||||
};
|
||||
|
||||
export type Envs = {
|
||||
[key: string]: string;
|
||||
};
|
||||
@@ -102,6 +153,51 @@ export type ExtensionResponse = {
|
||||
extensions: Array<ExtensionEntry>;
|
||||
};
|
||||
|
||||
export type FrontendToolRequest = {
|
||||
id: string;
|
||||
toolCall: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
export type ImageContent = {
|
||||
annotations?: Annotations | null;
|
||||
data: string;
|
||||
mimeType: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A message to or from an LLM
|
||||
*/
|
||||
export type Message = {
|
||||
content: Array<MessageContent>;
|
||||
created: number;
|
||||
role: Role;
|
||||
};
|
||||
|
||||
/**
|
||||
* Content passed inside a message, which can be both simple content and tool content
|
||||
*/
|
||||
export type MessageContent = (TextContent & {
|
||||
type: 'text';
|
||||
}) | (ImageContent & {
|
||||
type: 'image';
|
||||
}) | (ToolRequest & {
|
||||
type: 'toolRequest';
|
||||
}) | (ToolResponse & {
|
||||
type: 'toolResponse';
|
||||
}) | (ToolConfirmationRequest & {
|
||||
type: 'toolConfirmationRequest';
|
||||
}) | (FrontendToolRequest & {
|
||||
type: 'frontendToolRequest';
|
||||
}) | (ThinkingContent & {
|
||||
type: 'thinking';
|
||||
}) | (RedactedThinkingContent & {
|
||||
type: 'redactedThinking';
|
||||
}) | (ContextLengthExceeded & {
|
||||
type: 'contextLengthExceeded';
|
||||
});
|
||||
|
||||
/**
|
||||
* Information about a model's capabilities
|
||||
*/
|
||||
@@ -180,6 +276,32 @@ export type ProvidersResponse = {
|
||||
providers: Array<ProviderDetails>;
|
||||
};
|
||||
|
||||
export type RedactedThinkingContent = {
|
||||
data: string;
|
||||
};
|
||||
|
||||
export type ResourceContents = {
|
||||
mime_type?: string | null;
|
||||
text: string;
|
||||
uri: string;
|
||||
} | {
|
||||
blob: string;
|
||||
mime_type?: string | null;
|
||||
uri: string;
|
||||
};
|
||||
|
||||
export type Role = 'user' | 'assistant';
|
||||
|
||||
export type TextContent = {
|
||||
annotations?: Annotations | null;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export type ThinkingContent = {
|
||||
signature: string;
|
||||
thinking: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* A tool that can be used by a model.
|
||||
*/
|
||||
@@ -249,6 +371,13 @@ export type ToolAnnotations = {
|
||||
title?: string | null;
|
||||
};
|
||||
|
||||
export type ToolConfirmationRequest = {
|
||||
arguments: unknown;
|
||||
id: string;
|
||||
prompt?: string | null;
|
||||
toolName: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about the tool used for building prompts
|
||||
*/
|
||||
@@ -267,6 +396,28 @@ export type ToolPermission = {
|
||||
tool_name: string;
|
||||
};
|
||||
|
||||
export type ToolRequest = {
|
||||
id: string;
|
||||
toolCall: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
export type ToolResponse = {
|
||||
id: string;
|
||||
toolResult: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
export type ToolResultSchema = {
|
||||
data: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
message?: string | null;
|
||||
success: boolean;
|
||||
};
|
||||
|
||||
export type UpsertConfigQuery = {
|
||||
is_secret: boolean;
|
||||
key: string;
|
||||
@@ -593,6 +744,37 @@ export type ConfirmPermissionResponses = {
|
||||
200: unknown;
|
||||
};
|
||||
|
||||
export type ManageContextData = {
|
||||
body: ContextManageRequest;
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: '/context/manage';
|
||||
};
|
||||
|
||||
export type ManageContextErrors = {
|
||||
/**
|
||||
* Unauthorized - Invalid or missing API key
|
||||
*/
|
||||
401: unknown;
|
||||
/**
|
||||
* Precondition failed - Agent not available
|
||||
*/
|
||||
412: unknown;
|
||||
/**
|
||||
* Internal server error
|
||||
*/
|
||||
500: unknown;
|
||||
};
|
||||
|
||||
export type ManageContextResponses = {
|
||||
/**
|
||||
* Context managed successfully
|
||||
*/
|
||||
200: ContextManageResponse;
|
||||
};
|
||||
|
||||
export type ManageContextResponse = ManageContextResponses[keyof ManageContextResponses];
|
||||
|
||||
export type ClientOptions = {
|
||||
baseUrl: `${string}://${string}` | (string & {});
|
||||
};
|
||||
Reference in New Issue
Block a user