fix: client CompletionResponse matches actual gateway response fields
- Match field names: id, status, confidence, model, task_type, latency_ms, tokens, output - Default URL now https://llm-gateway.context-x.org (public endpoint) - ShieldX client uses 'shieldx' caller (not 'internal') - tokens.in/tokens.out instead of token_count.input/output
This commit is contained in:
parent
ac33476666
commit
b68d5c3fbf
@ -40,27 +40,27 @@ export interface CompletionRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CompletionResponse {
|
export interface CompletionResponse {
|
||||||
/** UUID for the request — use for tracing / support */
|
/** Request ID for tracing */
|
||||||
request_id: string;
|
id: string;
|
||||||
/** Overall status of the response */
|
/** Overall status of the response */
|
||||||
status: 'approved' | 'warning' | 'pending_review' | 'rejected';
|
status: 'approved' | 'warning' | 'pending_review' | 'rejected';
|
||||||
/** The LLM output, or null if rejected/failed */
|
/** Model confidence score 0–10 */
|
||||||
output: unknown | null;
|
|
||||||
/** Model confidence score 0–1 */
|
|
||||||
confidence: number;
|
confidence: number;
|
||||||
/** Ollama model that produced the output */
|
/** Ollama model that produced the output */
|
||||||
model_used: string;
|
model: string;
|
||||||
/** Prompt template version used */
|
/** Task type that was processed */
|
||||||
prompt_version: string;
|
task_type: string;
|
||||||
/** Token usage */
|
|
||||||
token_count: { input: number; output: number };
|
|
||||||
/** End-to-end latency in milliseconds */
|
/** End-to-end latency in milliseconds */
|
||||||
latency_ms: number;
|
latency_ms: number;
|
||||||
/** Validation details (present when return_validation_details=true or status != 'approved') */
|
/** Token usage */
|
||||||
|
tokens: { in: number; out: number };
|
||||||
|
/** The LLM output text */
|
||||||
|
output: string;
|
||||||
|
/** Validation details (present when return_validation_details=true) */
|
||||||
validation?: {
|
validation?: {
|
||||||
passed: boolean;
|
passed: boolean;
|
||||||
ban_hits: unknown[];
|
score: number;
|
||||||
warnings: string[];
|
validators: Record<string, unknown>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ export class LLMGatewayClient {
|
|||||||
}) {
|
}) {
|
||||||
this.baseUrl = config.baseUrl
|
this.baseUrl = config.baseUrl
|
||||||
?? process.env['LLM_GATEWAY_URL']
|
?? process.env['LLM_GATEWAY_URL']
|
||||||
?? 'http://localhost:3100';
|
?? 'https://llm-gateway.context-x.org';
|
||||||
this.caller = config.caller;
|
this.caller = config.caller;
|
||||||
this.timeout = config.timeout ?? 30_000;
|
this.timeout = config.timeout ?? 30_000;
|
||||||
}
|
}
|
||||||
@ -240,10 +240,10 @@ export function createNOGnetClient(baseUrl?: string): LLMGatewayClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ShieldX — LLM prompt injection defense (internal meta-use)
|
* ShieldX — LLM prompt injection defense
|
||||||
*/
|
*/
|
||||||
export function createShieldXClient(baseUrl?: string): LLMGatewayClient {
|
export function createShieldXClient(baseUrl?: string): LLMGatewayClient {
|
||||||
return new LLMGatewayClient({ caller: 'internal', baseUrl, timeout: 10_000 });
|
return new LLMGatewayClient({ caller: 'shieldx', baseUrl, timeout: 10_000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user