import type { CompletionRequest } from '../types/messages.js'; /** An entity in a knowledge graph. */ export interface KnowledgeGraphNode { /** Id edges refer to. */ id: string; /** Name used when stating facts. */ label: string; /** Kind of entity, such as `person`. */ type?: string; /** Application data. */ properties?: Record; } /** A relationship between two entities. */ export interface KnowledgeGraphEdge { /** Id of the subject node. */ from: string; /** Id of the object node. */ to: string; /** The relationship, such as `works_at`. */ relation: string; /** Text supporting the relationship, quoted in the fact. */ evidence?: string; /** Where it came from, cited in the fact. */ source?: string; /** Application data. */ properties?: Record; } /** Entities and the relationships between them. */ export interface KnowledgeGraph { /** The entities. */ nodes: KnowledgeGraphNode[]; /** The relationships. */ edges: KnowledgeGraphEdge[]; } /** Options for `withKnowledgeGraphContext()`. */ export interface KnowledgeGraphOptions { /** The graph facts come from. */ graph: KnowledgeGraph; /** Text facts are ranked against. Defaults to the latest user message. */ query?: string; /** Most facts included. Defaults to 20. */ maxEdges?: number; /** * Includes facts that share no terms with the query, when there are too few that do. Off by * default. */ includeFallbackFacts?: boolean; /** * What the model should answer when the graph does not support one. Defaults to `I don't know * based on the provided graph.` */ unknownAnswer?: string; } export interface SelectGraphFactsOptions { includeFallbackFacts?: boolean; } /** * Adds the graph facts most relevant to the request as a system message, telling the model not to * infer relationships the graph lacks. Temperature and top-p default low. */ export declare function withKnowledgeGraphContext(request: CompletionRequest, options: KnowledgeGraphOptions): CompletionRequest; /** * Ranks a graph's relationships by how many terms they share with the query and states the best as * fact lines. */ export declare function selectGraphFacts(graph: KnowledgeGraph, query: string, maxEdges?: number, options?: SelectGraphFactsOptions): string[];