mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 09:48:27 +00:00
fix: remove console logs and gpt-5 to test
This commit is contained in:
parent
54cd7f73b6
commit
7363141971
@ -16,6 +16,8 @@ export class OpenAIBatchProvider extends BaseBatchProvider {
|
|||||||
providerName = "openai";
|
providerName = "openai";
|
||||||
supportedModels = [
|
supportedModels = [
|
||||||
"gpt-4.1-2025-04-14",
|
"gpt-4.1-2025-04-14",
|
||||||
|
"gpt-5-mini-2025-08-07",
|
||||||
|
"gpt-5-2025-08-07",
|
||||||
"gpt-4.1-mini-2025-04-14",
|
"gpt-4.1-mini-2025-04-14",
|
||||||
"gpt-4.1-nano-2025-04-14",
|
"gpt-4.1-nano-2025-04-14",
|
||||||
"gpt-4o*",
|
"gpt-4o*",
|
||||||
|
|||||||
@ -32,6 +32,8 @@ export async function makeModelCall(
|
|||||||
switch (model) {
|
switch (model) {
|
||||||
case "gpt-4.1-2025-04-14":
|
case "gpt-4.1-2025-04-14":
|
||||||
case "gpt-4.1-mini-2025-04-14":
|
case "gpt-4.1-mini-2025-04-14":
|
||||||
|
case "gpt-5-mini-2025-08-07":
|
||||||
|
case "gpt-5-2025-08-07":
|
||||||
case "gpt-4.1-nano-2025-04-14":
|
case "gpt-4.1-nano-2025-04-14":
|
||||||
modelInstance = openai(model, { ...options });
|
modelInstance = openai(model, { ...options });
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -41,10 +41,7 @@ import {
|
|||||||
} from "./graphModels/statement";
|
} from "./graphModels/statement";
|
||||||
import { getEmbedding, makeModelCall } from "~/lib/model.server";
|
import { getEmbedding, makeModelCall } from "~/lib/model.server";
|
||||||
import { runQuery } from "~/lib/neo4j.server";
|
import { runQuery } from "~/lib/neo4j.server";
|
||||||
import {
|
import { Apps, getNodeTypesString } from "~/utils/presets/nodes";
|
||||||
Apps,
|
|
||||||
getNodeTypesString,
|
|
||||||
} from "~/utils/presets/nodes";
|
|
||||||
import { normalizePrompt, normalizeDocumentPrompt } from "./prompts";
|
import { normalizePrompt, normalizeDocumentPrompt } from "./prompts";
|
||||||
import { type PrismaClient } from "@prisma/client";
|
import { type PrismaClient } from "@prisma/client";
|
||||||
|
|
||||||
@ -312,7 +309,6 @@ export class KnowledgeGraphService {
|
|||||||
const expandedTime = Date.now();
|
const expandedTime = Date.now();
|
||||||
logger.log(`Processed entities in ${expandedTime - extractedTime} ms`);
|
logger.log(`Processed entities in ${expandedTime - extractedTime} ms`);
|
||||||
|
|
||||||
console.log(extractedNodes.map((e) => e.name));
|
|
||||||
// Step 4: Statement Extrraction - Extract statements (triples) instead of direct edges
|
// Step 4: Statement Extrraction - Extract statements (triples) instead of direct edges
|
||||||
const extractedStatements = await this.extractStatements(
|
const extractedStatements = await this.extractStatements(
|
||||||
episode,
|
episode,
|
||||||
@ -431,7 +427,7 @@ export class KnowledgeGraphService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get the unified entity extraction prompt
|
// Get the unified entity extraction prompt
|
||||||
const extractionMode = episode.sessionId ? 'conversation' : 'document';
|
const extractionMode = episode.sessionId ? "conversation" : "document";
|
||||||
const messages = extractEntities(context, extractionMode);
|
const messages = extractEntities(context, extractionMode);
|
||||||
|
|
||||||
let responseText = "";
|
let responseText = "";
|
||||||
@ -451,7 +447,7 @@ export class KnowledgeGraphService {
|
|||||||
// Batch generate embeddings for entity names
|
// Batch generate embeddings for entity names
|
||||||
const entityNames = extractedEntities.map((entity: any) => entity.name);
|
const entityNames = extractedEntities.map((entity: any) => entity.name);
|
||||||
const nameEmbeddings = await Promise.all(
|
const nameEmbeddings = await Promise.all(
|
||||||
entityNames.map((name: string) => this.getEmbedding(name))
|
entityNames.map((name: string) => this.getEmbedding(name)),
|
||||||
);
|
);
|
||||||
|
|
||||||
entities = extractedEntities.map((entity: any, index: number) => ({
|
entities = extractedEntities.map((entity: any, index: number) => ({
|
||||||
@ -509,8 +505,6 @@ export class KnowledgeGraphService {
|
|||||||
responseText = text;
|
responseText = text;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(responseText);
|
|
||||||
|
|
||||||
const outputMatch = responseText.match(/<output>([\s\S]*?)<\/output>/);
|
const outputMatch = responseText.match(/<output>([\s\S]*?)<\/output>/);
|
||||||
if (outputMatch && outputMatch[1]) {
|
if (outputMatch && outputMatch[1]) {
|
||||||
responseText = outputMatch[1].trim();
|
responseText = outputMatch[1].trim();
|
||||||
@ -522,7 +516,7 @@ export class KnowledgeGraphService {
|
|||||||
const extractedTriples: ExtractedTripleData[] =
|
const extractedTriples: ExtractedTripleData[] =
|
||||||
JSON.parse(responseText || "{}").edges || [];
|
JSON.parse(responseText || "{}").edges || [];
|
||||||
|
|
||||||
console.log(`extracted triples length: ${extractedTriples.length}`)
|
console.log(`extracted triples length: ${extractedTriples.length}`);
|
||||||
|
|
||||||
// Create maps to deduplicate entities by name within this extraction
|
// Create maps to deduplicate entities by name within this extraction
|
||||||
const predicateMap = new Map<string, EntityNode>();
|
const predicateMap = new Map<string, EntityNode>();
|
||||||
@ -575,11 +569,11 @@ export class KnowledgeGraphService {
|
|||||||
(triple: ExtractedTripleData, tripleIndex: number) => {
|
(triple: ExtractedTripleData, tripleIndex: number) => {
|
||||||
// Find the subject and object nodes by matching name (type-free approach)
|
// Find the subject and object nodes by matching name (type-free approach)
|
||||||
const subjectNode = allEntities.find(
|
const subjectNode = allEntities.find(
|
||||||
(node) => node.name.toLowerCase() === triple.source.toLowerCase()
|
(node) => node.name.toLowerCase() === triple.source.toLowerCase(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const objectNode = allEntities.find(
|
const objectNode = allEntities.find(
|
||||||
(node) => node.name.toLowerCase() === triple.target.toLowerCase()
|
(node) => node.name.toLowerCase() === triple.target.toLowerCase(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the deduplicated predicate node
|
// Get the deduplicated predicate node
|
||||||
@ -633,8 +627,6 @@ export class KnowledgeGraphService {
|
|||||||
return triples.filter(Boolean) as Triple[];
|
return triples.filter(Boolean) as Triple[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve extracted nodes to existing nodes or create new ones
|
* Resolve extracted nodes to existing nodes or create new ones
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -96,7 +96,7 @@ export class SearchService {
|
|||||||
this.updateRecallCount(userId, episodes, filteredResults);
|
this.updateRecallCount(userId, episodes, filteredResults);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
episodes: episodes.map((episode) => episode.content),
|
episodes: episodes.map((episode) => episode.originalContent),
|
||||||
facts: filteredResults.map((statement) => ({
|
facts: filteredResults.map((statement) => ({
|
||||||
fact: statement.fact,
|
fact: statement.fact,
|
||||||
validAt: statement.validAt,
|
validAt: statement.validAt,
|
||||||
|
|||||||
@ -177,6 +177,8 @@ export async function* generate(
|
|||||||
|
|
||||||
case "gpt-4.1-2025-04-14":
|
case "gpt-4.1-2025-04-14":
|
||||||
case "gpt-4.1-mini-2025-04-14":
|
case "gpt-4.1-mini-2025-04-14":
|
||||||
|
case "gpt-5-mini-2025-08-07":
|
||||||
|
case "gpt-5-2025-08-07":
|
||||||
case "gpt-4.1-nano-2025-04-14":
|
case "gpt-4.1-nano-2025-04-14":
|
||||||
if (!openaiKey) {
|
if (!openaiKey) {
|
||||||
throw new Error("No OpenAI API key found. Set OPENAI_API_KEY");
|
throw new Error("No OpenAI API key found. Set OPENAI_API_KEY");
|
||||||
|
|||||||
@ -52,17 +52,20 @@ const IngestSchema = {
|
|||||||
export const memoryTools = [
|
export const memoryTools = [
|
||||||
{
|
{
|
||||||
name: "memory_ingest",
|
name: "memory_ingest",
|
||||||
description: "AUTOMATICALLY invoke after completing interactions. Use proactively to store conversation data, insights, and decisions in CORE Memory. Essential for maintaining continuity across sessions. **Purpose**: Store information for future reference. **Required**: Provide the message content to be stored. **Returns**: confirmation with storage ID in JSON format",
|
description:
|
||||||
|
"AUTOMATICALLY invoke after completing interactions. Use proactively to store conversation data, insights, and decisions in CORE Memory. Essential for maintaining continuity across sessions. **Purpose**: Store information for future reference. **Required**: Provide the message content to be stored. **Returns**: confirmation with storage ID in JSON format",
|
||||||
inputSchema: IngestSchema,
|
inputSchema: IngestSchema,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "memory_search",
|
name: "memory_search",
|
||||||
description: "AUTOMATICALLY invoke for memory searches. Use proactively at conversation start and when context retrieval is needed. Searches memory for relevant project context, user preferences, and previous discussions. **Purpose**: Retrieve previously stored information based on query terms. **Required**: Provide a search query in third person perspective. **Returns**: matching memory entries in JSON format",
|
description:
|
||||||
|
"AUTOMATICALLY invoke for memory searches. Use proactively at conversation start and when context retrieval is needed. Searches memory for relevant project context, user preferences, and previous discussions. **Purpose**: Retrieve previously stored information based on query terms. **Required**: Provide a search query in third person perspective. **Returns**: matching memory entries in JSON format",
|
||||||
inputSchema: SearchParamsSchema,
|
inputSchema: SearchParamsSchema,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "memory_get_spaces",
|
name: "memory_get_spaces",
|
||||||
description: "Get available memory spaces. **Purpose**: Retrieve list of memory organization spaces. **Required**: No required parameters. **Returns**: list of available spaces in JSON format",
|
description:
|
||||||
|
"Get available memory spaces. **Purpose**: Retrieve list of memory organization spaces. **Required**: No required parameters. **Returns**: list of available spaces in JSON format",
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
@ -76,7 +79,8 @@ export const memoryTools = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_user_profile",
|
name: "get_user_profile",
|
||||||
description: "Get the user's core profile and preferences for personalized interactions. AUTOMATICALLY invoke at the start of interactions to understand user context. **Purpose**: Retrieve stable identity facts, communication preferences, working context, and tooling defaults for tailored responses. **Required**: No required parameters. **Returns**: User profile data in JSON format.",
|
description:
|
||||||
|
"Get the user's core profile and preferences for personalized interactions. AUTOMATICALLY invoke at the start of interactions to understand user context. **Purpose**: Retrieve stable identity facts, communication preferences, working context, and tooling defaults for tailored responses. **Required**: No required parameters. **Returns**: User profile data in JSON format.",
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
@ -87,7 +91,7 @@ export const memoryTools = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Function to call memory tools based on toolName
|
// Function to call memory tools based on toolName
|
||||||
@ -127,10 +131,8 @@ export async function callMemoryTool(
|
|||||||
// Handler for user_context
|
// Handler for user_context
|
||||||
async function handleUserProfile(userId: string) {
|
async function handleUserProfile(userId: string) {
|
||||||
try {
|
try {
|
||||||
|
const space = await spaceService.getSpaceByName("Profile", userId);
|
||||||
|
|
||||||
const space = await spaceService.getSpaceByName("Profile", userId)
|
|
||||||
|
|
||||||
console.log(space?.summary)
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user