feat: make FactExtractor extracts multiple facts per input
This commit is contained in:
@@ -23,29 +23,31 @@ describe("IdentityDB ingestion", () => {
|
||||
it("ingests a statement using a provided extractor", async () => {
|
||||
const extractor: FactExtractor = {
|
||||
async extract(input) {
|
||||
return {
|
||||
statement: input,
|
||||
topics: [
|
||||
{
|
||||
name: "I",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "subject",
|
||||
},
|
||||
{
|
||||
name: "TypeScript",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "2025",
|
||||
category: "temporal",
|
||||
granularity: "concrete",
|
||||
role: "time",
|
||||
},
|
||||
],
|
||||
};
|
||||
return [
|
||||
{
|
||||
statement: input,
|
||||
topics: [
|
||||
{
|
||||
name: "I",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "subject",
|
||||
},
|
||||
{
|
||||
name: "TypeScript",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "2025",
|
||||
category: "temporal",
|
||||
granularity: "concrete",
|
||||
role: "time",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
@@ -95,39 +97,41 @@ describe("IdentityDB ingestion", () => {
|
||||
async generateText(input) {
|
||||
prompt = input;
|
||||
|
||||
return {
|
||||
statement: "I have worked with Bun and TypeScript since 2025.",
|
||||
summary: "The speaker has Bun and TypeScript experience.",
|
||||
source: "chat",
|
||||
confidence: 0.91,
|
||||
metadata: { channel: "telegram" },
|
||||
topics: [
|
||||
{
|
||||
name: "I",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "subject",
|
||||
},
|
||||
{
|
||||
name: "Bun",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "TypeScript",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "2025",
|
||||
category: "temporal",
|
||||
granularity: "concrete",
|
||||
role: "time",
|
||||
},
|
||||
],
|
||||
};
|
||||
return [
|
||||
{
|
||||
statement: "I have worked with Bun and TypeScript since 2025.",
|
||||
summary: "The speaker has Bun and TypeScript experience.",
|
||||
source: "chat",
|
||||
confidence: 0.91,
|
||||
metadata: { channel: "telegram" },
|
||||
topics: [
|
||||
{
|
||||
name: "I",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "subject",
|
||||
},
|
||||
{
|
||||
name: "Bun",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "TypeScript",
|
||||
category: "entity",
|
||||
granularity: "concrete",
|
||||
role: "object",
|
||||
},
|
||||
{
|
||||
name: "2025",
|
||||
category: "temporal",
|
||||
granularity: "concrete",
|
||||
role: "time",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
additionalInstructions: "Prefer technology and time topics.",
|
||||
@@ -141,7 +145,7 @@ describe("IdentityDB ingestion", () => {
|
||||
);
|
||||
|
||||
expect(prompt).toEqual({
|
||||
instruction: expect.stringContaining("Extract one structured fact from the user input."),
|
||||
instruction: expect.stringContaining("Extract structured facts from the user input."),
|
||||
input: "I have worked with Bun and TypeScript since 2025.",
|
||||
additionalInstruction: "Prefer technology and time topics.",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user