KO
베타 번역

@core / ai

1.0.0 ▾
인증됨MIT
GitHub

스트리밍 AI 채팅: 버전 관리 프롬프트, 도구 호출, 사용량·비용 기록, 모델은 환경 변수로 지정

코드파일 11개컨텍스트약 668토큰검사 통과

.genpmignore 적용 후 주입될 정확한 트리입니다. 고정 대상:

src/lib/ai/schema.ts읽기 전용 · 5b1e62b
// Registro de uso de la IA: una fila por respuesta del modelo (tokens y coste), para límites y facturación interna.
import { index, integer, pgTable, text } from 'drizzle-orm/pg-core';
import { primaryId, timestamps } from '../db/index.js';

export const aiUsage = pgTable(
  'ai_usage',
  {
    id: primaryId('aiu'),
    /** Usuario de la app si lo hay (sin FK: @core/ai no depende de @core/auth). */
    userId: text('user_id'),
    model: text('model').notNull(),
    prompt: text('prompt').notNull(),
    inputTokens: integer('input_tokens').notNull().default(0),
    outputTokens: integer('output_tokens').notNull().default(0),
    /** Coste en millonésimas de dólar (null si el modelo no está en prices.ts). */
    costMicroUsd: integer('cost_micro_usd'),
    ...timestamps,
  },
  (t) => [index('ai_usage_user_idx').on(t.userId, t.createdAt)],
);

export type AiUsage = typeof aiUsage.$inferSelect;

@core/ai 신고

패키지를 신고하려면 GitHub로 로그인하세요.