mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 10:08:27 +00:00
fix: delete log needs no body
This commit is contained in:
parent
5150fab210
commit
59620151f2
@ -24,20 +24,16 @@ const loader = createHybridLoaderApiRoute(
|
|||||||
corsStrategy: "all",
|
corsStrategy: "all",
|
||||||
allowJWT: true,
|
allowJWT: true,
|
||||||
},
|
},
|
||||||
async ({ params, authentication }) => {
|
async ({ params }) => {
|
||||||
const formattedLog = await getIngestionQueueForFrontend(params.logId);
|
const formattedLog = await getIngestionQueueForFrontend(params.logId);
|
||||||
|
|
||||||
return json({ log: formattedLog });
|
return json({ log: formattedLog });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export const DeleteEpisodeBodyRequest = z.object({
|
|
||||||
id: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const { action } = createHybridActionApiRoute(
|
const { action } = createHybridActionApiRoute(
|
||||||
{
|
{
|
||||||
body: DeleteEpisodeBodyRequest,
|
params: LogParamsSchema,
|
||||||
allowJWT: true,
|
allowJWT: true,
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
authorization: {
|
authorization: {
|
||||||
@ -45,9 +41,9 @@ const { action } = createHybridActionApiRoute(
|
|||||||
},
|
},
|
||||||
corsStrategy: "all",
|
corsStrategy: "all",
|
||||||
},
|
},
|
||||||
async ({ body, authentication }) => {
|
async ({ params, authentication }) => {
|
||||||
try {
|
try {
|
||||||
const ingestionQueue = await getIngestionQueue(body.id);
|
const ingestionQueue = await getIngestionQueue(params.logId);
|
||||||
|
|
||||||
if (!ingestionQueue) {
|
if (!ingestionQueue) {
|
||||||
return json(
|
return json(
|
||||||
|
|||||||
@ -8,9 +8,10 @@ import type { CoreMessage } from "ai";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { triggerSpacePattern } from "./space-pattern";
|
import { triggerSpacePattern } from "./space-pattern";
|
||||||
import { getSpace, updateSpace } from "../utils/space-utils";
|
import { getSpace, updateSpace } from "../utils/space-utils";
|
||||||
import { addToQueue } from "~/lib/ingest.server";
|
|
||||||
import { EpisodeType } from "@core/types";
|
import { EpisodeType } from "@core/types";
|
||||||
import { getSpaceStatementCount } from "~/services/graphModels/space";
|
import { getSpaceStatementCount } from "~/services/graphModels/space";
|
||||||
|
import { addToQueue } from "../utils/queue";
|
||||||
|
|
||||||
interface SpaceSummaryPayload {
|
interface SpaceSummaryPayload {
|
||||||
userId: string;
|
userId: string;
|
||||||
@ -144,7 +145,9 @@ export const spaceSummaryTask = task({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info(`No summary generated for space ${spaceId} - insufficient or no new episodes`);
|
logger.info(
|
||||||
|
`No summary generated for space ${spaceId} - insufficient or no new episodes`,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
spaceId,
|
spaceId,
|
||||||
@ -231,11 +234,7 @@ async function generateSpaceSummary(
|
|||||||
|
|
||||||
// Process in batches, each building on previous result
|
// Process in batches, each building on previous result
|
||||||
const batches: SpaceEpisodeData[][] = [];
|
const batches: SpaceEpisodeData[][] = [];
|
||||||
for (
|
for (let i = 0; i < episodes.length; i += CONFIG.maxEpisodesForSummary) {
|
||||||
let i = 0;
|
|
||||||
i < episodes.length;
|
|
||||||
i += CONFIG.maxEpisodesForSummary
|
|
||||||
) {
|
|
||||||
batches.push(episodes.slice(i, i + CONFIG.maxEpisodesForSummary));
|
batches.push(episodes.slice(i, i + CONFIG.maxEpisodesForSummary));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,16 +373,16 @@ function createUnifiedSummaryPrompt(
|
|||||||
const episodesText = episodes
|
const episodesText = episodes
|
||||||
.map(
|
.map(
|
||||||
(episode) =>
|
(episode) =>
|
||||||
`- ${episode.content} (Source: ${episode.source}, Session: ${episode.sessionId || 'N/A'})`,
|
`- ${episode.content} (Source: ${episode.source}, Session: ${episode.sessionId || "N/A"})`,
|
||||||
)
|
)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
// Extract key entities and themes from episode content
|
// Extract key entities and themes from episode content
|
||||||
const contentWords = episodes
|
const contentWords = episodes
|
||||||
.map(ep => ep.content.toLowerCase())
|
.map((ep) => ep.content.toLowerCase())
|
||||||
.join(' ')
|
.join(" ")
|
||||||
.split(/\s+/)
|
.split(/\s+/)
|
||||||
.filter(word => word.length > 3);
|
.filter((word) => word.length > 3);
|
||||||
|
|
||||||
const wordFrequency = new Map<string, number>();
|
const wordFrequency = new Map<string, number>();
|
||||||
contentWords.forEach((word) => {
|
contentWords.forEach((word) => {
|
||||||
@ -423,7 +422,7 @@ ${
|
|||||||
3. Create a coherent summary that captures the essence of this knowledge domain
|
3. Create a coherent summary that captures the essence of this knowledge domain
|
||||||
4. Generate a well-structured markdown summary organized by the identified themes`
|
4. Generate a well-structured markdown summary organized by the identified themes`
|
||||||
}
|
}
|
||||||
${isUpdate ? '7' : '6'}. Assess your confidence in the ${isUpdate ? "updated" : ""} summary quality (0.0-1.0)
|
${isUpdate ? "7" : "6"}. Assess your confidence in the ${isUpdate ? "updated" : ""} summary quality (0.0-1.0)
|
||||||
|
|
||||||
THEME IDENTIFICATION RULES:
|
THEME IDENTIFICATION RULES:
|
||||||
- A theme must be supported by AT LEAST 3 related episodes to be considered valid
|
- A theme must be supported by AT LEAST 3 related episodes to be considered valid
|
||||||
@ -564,7 +563,7 @@ async function getSpaceEpisodes(
|
|||||||
WHERE ${whereClause}
|
WHERE ${whereClause}
|
||||||
OPTIONAL MATCH (e:Episode{userId: $userId})-[:HAS_PROVENANCE]->(s)
|
OPTIONAL MATCH (e:Episode{userId: $userId})-[:HAS_PROVENANCE]->(s)
|
||||||
WITH e
|
WITH e
|
||||||
WHERE e IS NOT NULL ${dateCondition ? `AND ${dateCondition}` : ''}
|
WHERE e IS NOT NULL ${dateCondition ? `AND ${dateCondition}` : ""}
|
||||||
RETURN DISTINCT e
|
RETURN DISTINCT e
|
||||||
ORDER BY e.createdAt DESC
|
ORDER BY e.createdAt DESC
|
||||||
`;
|
`;
|
||||||
@ -709,14 +708,11 @@ async function processSpaceSummarySequentially({
|
|||||||
| "ingestion_complete";
|
| "ingestion_complete";
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
// Step 1: Ingest summary as document synchronously
|
// Step 1: Ingest summary as document synchronously
|
||||||
await ingestSpaceSummaryDocument(
|
await ingestSpaceSummaryDocument(spaceId, userId, spaceName, summaryContent);
|
||||||
spaceId,
|
|
||||||
userId,
|
|
||||||
spaceName,
|
|
||||||
summaryContent
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info(`Successfully ingested space summary document for space ${spaceId}`);
|
logger.info(
|
||||||
|
`Successfully ingested space summary document for space ${spaceId}`,
|
||||||
|
);
|
||||||
|
|
||||||
// Step 2: Now trigger space patterns (patterns will have access to the ingested summary)
|
// Step 2: Now trigger space patterns (patterns will have access to the ingested summary)
|
||||||
await triggerSpacePattern({
|
await triggerSpacePattern({
|
||||||
@ -726,7 +722,9 @@ async function processSpaceSummarySequentially({
|
|||||||
triggerSource,
|
triggerSource,
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info(`Sequential processing completed for space ${spaceId}: summary ingested → patterns triggered`);
|
logger.info(
|
||||||
|
`Sequential processing completed for space ${spaceId}: summary ingested → patterns triggered`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -736,7 +734,7 @@ async function ingestSpaceSummaryDocument(
|
|||||||
spaceId: string,
|
spaceId: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
spaceName: string,
|
spaceName: string,
|
||||||
summaryContent: string
|
summaryContent: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Create the ingest body
|
// Create the ingest body
|
||||||
const ingestBody = {
|
const ingestBody = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user