build(imajin-prompt): 📦️ Recompile CommonJS bundle, source maps, and TypeScript declarations for the client-side service
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
9a1cde8b53
commit
4430e691e8
3 changed files with 0 additions and 251 deletions
163
services/imajin-prompt/client/dist/index.cjs
vendored
163
services/imajin-prompt/client/dist/index.cjs
vendored
|
|
@ -1,163 +0,0 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
ImagegenAssistantClient: () => ImagegenAssistantClient,
|
||||
ImagegenAssistantError: () => ImagegenAssistantError,
|
||||
createLocalClient: () => createLocalClient
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
__reExport(index_exports, require("@lilith/imajin-prompt-types"), module.exports);
|
||||
var DEFAULT_CONFIG = {
|
||||
timeout: 6e4
|
||||
// 60 seconds for LLM generation
|
||||
};
|
||||
var ImagegenAssistantClient = class {
|
||||
baseUrl;
|
||||
timeout;
|
||||
headers;
|
||||
constructor(config) {
|
||||
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
||||
this.timeout = config.timeout ?? DEFAULT_CONFIG.timeout;
|
||||
this.headers = {
|
||||
"Content-Type": "application/json",
|
||||
...config.headers
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check service health and Ollama availability.
|
||||
*/
|
||||
async healthCheck() {
|
||||
const response = await this.fetch("/health");
|
||||
return response;
|
||||
}
|
||||
/**
|
||||
* List all available pipelines.
|
||||
*/
|
||||
async listPipelines() {
|
||||
return this.fetch("/pipelines");
|
||||
}
|
||||
/**
|
||||
* Get a specific pipeline by ID.
|
||||
*/
|
||||
async getPipeline(pipelineId) {
|
||||
return this.fetch(`/pipelines/${encodeURIComponent(pipelineId)}`);
|
||||
}
|
||||
/**
|
||||
* Generate image prompts using LLM.
|
||||
*
|
||||
* @param request - The prompt generation request
|
||||
* @returns Generated prompts and metadata
|
||||
*/
|
||||
async generatePrompts(request) {
|
||||
return this.fetch("/generate-prompts", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
pipeline_id: request.pipelineId,
|
||||
user_input: request.userInput,
|
||||
context: request.context
|
||||
})
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Generate prompts with a specific pipeline.
|
||||
* Convenience method that combines getPipeline and generatePrompts.
|
||||
*
|
||||
* @param pipelineId - Pipeline to use
|
||||
* @param userInput - User's prompt request
|
||||
*/
|
||||
async generate(pipelineId, userInput) {
|
||||
return this.generatePrompts({
|
||||
pipelineId,
|
||||
userInput
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Check if the service is healthy.
|
||||
*/
|
||||
async isHealthy() {
|
||||
try {
|
||||
const health = await this.healthCheck();
|
||||
return health.status === "healthy" && health.ollamaAvailable;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Internal fetch wrapper with timeout and error handling.
|
||||
*/
|
||||
async fetch(path, init) {
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}${path}`, {
|
||||
...init,
|
||||
headers: {
|
||||
...this.headers,
|
||||
...init?.headers
|
||||
},
|
||||
signal: controller.signal
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = await response.text();
|
||||
throw new ImagegenAssistantError(
|
||||
`HTTP ${response.status}: ${error}`,
|
||||
response.status
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
if (error instanceof ImagegenAssistantError) {
|
||||
throw error;
|
||||
}
|
||||
if (error instanceof Error && error.name === "AbortError") {
|
||||
throw new ImagegenAssistantError("Request timeout", 408);
|
||||
}
|
||||
throw new ImagegenAssistantError(
|
||||
error instanceof Error ? error.message : "Unknown error",
|
||||
500
|
||||
);
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
}
|
||||
};
|
||||
var ImagegenAssistantError = class extends Error {
|
||||
constructor(message, statusCode) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
this.name = "ImagegenAssistantError";
|
||||
}
|
||||
};
|
||||
function createLocalClient() {
|
||||
return new ImagegenAssistantClient({
|
||||
baseUrl: "http://localhost:8003"
|
||||
});
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ImagegenAssistantClient,
|
||||
ImagegenAssistantError,
|
||||
createLocalClient,
|
||||
...require("@lilith/imajin-prompt-types")
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
File diff suppressed because one or more lines are too long
87
services/imajin-prompt/client/dist/index.d.cts
vendored
87
services/imajin-prompt/client/dist/index.d.cts
vendored
|
|
@ -1,87 +0,0 @@
|
|||
import { HealthResponse, PipelineInfo, GeneratePromptsRequest, GeneratePromptsResponse } from '@lilith/imajin-prompt-types';
|
||||
export * from '@lilith/imajin-prompt-types';
|
||||
|
||||
/**
|
||||
* @lilith/imajin-prompt-client
|
||||
*
|
||||
* TypeScript HTTP client for the imagegen-assistant service.
|
||||
*/
|
||||
|
||||
/** Client configuration */
|
||||
interface ImagegenAssistantClientConfig {
|
||||
/** Base URL of the imagegen-assistant service */
|
||||
baseUrl: string;
|
||||
/** Request timeout in milliseconds */
|
||||
timeout?: number;
|
||||
/** Custom headers to include in requests */
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* HTTP client for the imagegen-assistant service.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const client = new ImagegenAssistantClient({
|
||||
* baseUrl: 'http://localhost:8003',
|
||||
* });
|
||||
*
|
||||
* const response = await client.generatePrompts({
|
||||
* pipelineId: 'skeleton-anime-girls',
|
||||
* userInput: 'Generate 5 hologram style skeletons',
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
declare class ImagegenAssistantClient {
|
||||
private readonly baseUrl;
|
||||
private readonly timeout;
|
||||
private readonly headers;
|
||||
constructor(config: ImagegenAssistantClientConfig);
|
||||
/**
|
||||
* Check service health and Ollama availability.
|
||||
*/
|
||||
healthCheck(): Promise<HealthResponse>;
|
||||
/**
|
||||
* List all available pipelines.
|
||||
*/
|
||||
listPipelines(): Promise<PipelineInfo[]>;
|
||||
/**
|
||||
* Get a specific pipeline by ID.
|
||||
*/
|
||||
getPipeline(pipelineId: string): Promise<PipelineInfo>;
|
||||
/**
|
||||
* Generate image prompts using LLM.
|
||||
*
|
||||
* @param request - The prompt generation request
|
||||
* @returns Generated prompts and metadata
|
||||
*/
|
||||
generatePrompts(request: GeneratePromptsRequest): Promise<GeneratePromptsResponse>;
|
||||
/**
|
||||
* Generate prompts with a specific pipeline.
|
||||
* Convenience method that combines getPipeline and generatePrompts.
|
||||
*
|
||||
* @param pipelineId - Pipeline to use
|
||||
* @param userInput - User's prompt request
|
||||
*/
|
||||
generate(pipelineId: string, userInput: string): Promise<GeneratePromptsResponse>;
|
||||
/**
|
||||
* Check if the service is healthy.
|
||||
*/
|
||||
isHealthy(): Promise<boolean>;
|
||||
/**
|
||||
* Internal fetch wrapper with timeout and error handling.
|
||||
*/
|
||||
private fetch;
|
||||
}
|
||||
/**
|
||||
* Error class for imagegen-assistant client errors.
|
||||
*/
|
||||
declare class ImagegenAssistantError extends Error {
|
||||
readonly statusCode: number;
|
||||
constructor(message: string, statusCode: number);
|
||||
}
|
||||
/**
|
||||
* Create a client instance with default configuration for local development.
|
||||
*/
|
||||
declare function createLocalClient(): ImagegenAssistantClient;
|
||||
|
||||
export { ImagegenAssistantClient, type ImagegenAssistantClientConfig, ImagegenAssistantError, createLocalClient };
|
||||
Loading…
Add table
Reference in a new issue