Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

984 B
Raw Blame
import { prisma } from "@langfuse/shared/src/db";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import {
  GetSkillFileContentsQuerySchema,
  GetSkillFileContentsResponseSchema,
} from "@/src/features/public-api/types/skills";
import { SkillService } from "@/src/features/skills/server/skill-service";

export default withMiddlewares({
  GET: createAuthedProjectAPIRoute({
    name: "Get Skill File Contents",
    action: "skills:read",
    querySchema: GetSkillFileContentsQuerySchema,
    responseSchema: GetSkillFileContentsResponseSchema,
    rateLimitResource: "public-api",
    fn: async ({ query, auth, res }) => {
      res.setHeader("Cache-Control", "no-store");
      return new SkillService(prisma).getFileContents({
        projectId: auth.scope.projectId,
        sha256Hashes: query.sha256Hashes,
      });
    },
  }),
});