feat: snip a region into chat, and make links clickable (#14)
This commit was merged in pull request #14.
This commit is contained in:
@@ -219,6 +219,44 @@ export async function listModels(options: ListModelsOptions): Promise<ModelInfo[
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
export interface ModelCapabilitiesOptions {
|
||||
host: string;
|
||||
apiKey: string;
|
||||
model: string;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
/**
|
||||
* The features a model reports for itself, straight from `POST /api/show`.
|
||||
*
|
||||
* `GET /api/tags` is not enough here: it returns names, sizes and quantization
|
||||
* levels and says nothing about what the model can actually do. The capability
|
||||
* list is what turns "image input" from a guess about the model's name into a
|
||||
* fact, so it is worth the extra request.
|
||||
*/
|
||||
export async function modelCapabilities(options: ModelCapabilitiesOptions): Promise<string[]> {
|
||||
const host = normalizeHost(options.host);
|
||||
|
||||
const response = await fetch(`${host}/api/show`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", ...authHeaders(options.apiKey) },
|
||||
body: JSON.stringify({ model: options.model }),
|
||||
signal: options.signal,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw describeHttpError(response.status, await safeText(response), host);
|
||||
}
|
||||
|
||||
const payload = (await response.json()) as { capabilities?: string[] };
|
||||
return payload.capabilities ?? [];
|
||||
}
|
||||
|
||||
/** Ollama reports image input as the `vision` capability. */
|
||||
export function supportsVision(capabilities: string[]): boolean {
|
||||
return capabilities.includes("vision");
|
||||
}
|
||||
|
||||
export interface WebSearchResult {
|
||||
title: string;
|
||||
url: string;
|
||||
|
||||
Reference in New Issue
Block a user