mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
feat(ts): add real quality gates — Biome lint + effect-law ratchet + class inventory
- biome.json (2.4.16, linter-only) wired as "lint" in all six packages - scripts/check-effect-laws.ts: Effect-native law enforcement encoding the adapted beep-effect effect-first/schema-first laws (no native JSON/switch/ sort/fetch/timers, no process.env, no throw new, no Effect.run* outside boundaries, no Schema-suffixed constants, no node:fs/path, AST-based pure-data interface detection per law 38/39) - ratcheting baseline allowlist (95 entries / 290 findings) that must shrink to documented exemptions only; stale counts fail the gate - root lint chains turbo lint + law check + native-class inventory - fix all 163 initial Biome findings: import-type style, templates, two `any`s, ten non-null assertions (librarian getService gate, A.matchRight in atoms, ensureNode returning nodes, main.tsx mount guard) Gates: lint, check:tsgo, build, test (force, 11 tasks) all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
cf12defcd8
commit
0746d7ffd5
109 changed files with 951 additions and 611 deletions
|
|
@ -8,7 +8,8 @@
|
|||
"build": "bunx --bun tsc",
|
||||
"dev": "tsc --watch",
|
||||
"clean": "rm -rf dist",
|
||||
"test": "bunx --bun vitest run"
|
||||
"test": "bunx --bun vitest run",
|
||||
"lint": "bunx --bun biome check src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@effect/ai-anthropic": "4.0.0-beta.78",
|
||||
|
|
|
|||
|
|
@ -2,19 +2,21 @@ import { describe, expect, it } from "@effect/vitest";
|
|||
import { ConfigProvider, Effect, Fiber } from "effect";
|
||||
import * as EffectChunk from "effect/Chunk";
|
||||
import * as S from "effect/Schema";
|
||||
import type {
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
Chunk,
|
||||
CreateConsumerOptions,
|
||||
CreateProducerOptions,
|
||||
Message,
|
||||
PubSubBackend,
|
||||
TextDocument,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
MessagingRuntimeLive,
|
||||
PubSub,
|
||||
runProcessorScoped,
|
||||
topics,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type Chunk,
|
||||
type CreateConsumerOptions,
|
||||
type CreateProducerOptions,
|
||||
type Message,
|
||||
type PubSubBackend,
|
||||
type TextDocument,
|
||||
} from "@trustgraph/base";
|
||||
import { ChunkingService } from "../chunking/service.js";
|
||||
import { recursiveSplit } from "../chunking/recursive-splitter.js";
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
import { Effect } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type {
|
||||
FalkorDBClosableClient as FalkorDBQueryClient,
|
||||
FalkorDBQueryGraph,
|
||||
} from "../query/triples/falkordb.js";
|
||||
import {
|
||||
FalkorDBTriplesQueryLive,
|
||||
FalkorDBTriplesQueryService,
|
||||
type FalkorDBClosableClient as FalkorDBQueryClient,
|
||||
type FalkorDBQueryGraph,
|
||||
} from "../query/triples/falkordb.js";
|
||||
import type {
|
||||
FalkorDBClosableClient as FalkorDBStoreClient,
|
||||
FalkorDBStoreGraph,
|
||||
} from "../storage/triples/falkordb.js";
|
||||
import {
|
||||
FalkorDBTriplesStoreLive,
|
||||
FalkorDBTriplesStoreService,
|
||||
type FalkorDBClosableClient as FalkorDBStoreClient,
|
||||
type FalkorDBStoreGraph,
|
||||
} from "../storage/triples/falkordb.js";
|
||||
|
||||
class FakeFalkorDBClient implements FalkorDBStoreClient, FalkorDBQueryClient {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
import {Effect, HashMap, Option, SynchronizedRef} from "effect";
|
||||
import {describe, expect, it} from "vitest";
|
||||
import type {
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
ConfigRequest,
|
||||
ConfigResponse,
|
||||
CreateConsumerOptions,
|
||||
CreateProducerOptions,
|
||||
FlowRequest,
|
||||
FlowResponse,
|
||||
Message,
|
||||
PubSubBackend,
|
||||
RequestResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
topics,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type ConfigRequest,
|
||||
type ConfigResponse,
|
||||
type CreateConsumerOptions,
|
||||
type CreateProducerOptions,
|
||||
type FlowRequest,
|
||||
type FlowResponse,
|
||||
type Message,
|
||||
type PubSubBackend,
|
||||
type RequestResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {FlowManagerError, makeFlowManagerService} from "../flow-manager/service.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import { Effect, Exit, Scope } from "effect";
|
|||
import { HttpRouter, HttpServerResponse } from "effect/unstable/http";
|
||||
import type { DispatcherManager } from "../gateway/dispatch/manager.js";
|
||||
import type { GatewayRpcServer } from "../gateway/rpc-server.js";
|
||||
import { makeGatewayRoutes, type GatewayConfig } from "../gateway/server.js";
|
||||
import type { GatewayConfig } from "../gateway/server.js";
|
||||
import { makeGatewayRoutes, } from "../gateway/server.js";
|
||||
|
||||
interface DispatchCall {
|
||||
readonly scope: "global" | "flow";
|
||||
|
|
|
|||
|
|
@ -3,17 +3,19 @@ import {tmpdir} from "node:os";
|
|||
import {join} from "node:path";
|
||||
import {Effect, HashMap, Option, SynchronizedRef} from "effect";
|
||||
import {describe, expect, it} from "vitest";
|
||||
import type {
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
CreateConsumerOptions,
|
||||
CreateProducerOptions,
|
||||
KnowledgeRequest,
|
||||
KnowledgeResponse,
|
||||
Message,
|
||||
PubSubBackend,
|
||||
Triple,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
topics,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type CreateConsumerOptions,
|
||||
type CreateProducerOptions,
|
||||
type KnowledgeRequest,
|
||||
type KnowledgeResponse,
|
||||
type Message,
|
||||
type PubSubBackend,
|
||||
type Triple,
|
||||
} from "@trustgraph/base";
|
||||
import {makeKnowledgeCoreService} from "../cores/service.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import {tmpdir} from "node:os";
|
|||
import {join} from "node:path";
|
||||
import {Effect} from "effect";
|
||||
import {describe, expect, it} from "vitest";
|
||||
import {
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type CreateConsumerOptions,
|
||||
type CreateProducerOptions,
|
||||
type DocumentMetadata,
|
||||
type Message,
|
||||
type PubSubBackend,
|
||||
type Triple,
|
||||
import type {
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
CreateConsumerOptions,
|
||||
CreateProducerOptions,
|
||||
DocumentMetadata,
|
||||
Message,
|
||||
PubSubBackend,
|
||||
Triple,
|
||||
} from "@trustgraph/base";
|
||||
import {makeLibrarianService} from "../librarian/service.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
import { describe, expect, it } from "@effect/vitest";
|
||||
import { ConfigProvider, Effect, Fiber } from "effect";
|
||||
import * as S from "effect/Schema";
|
||||
import type {
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
CreateConsumerOptions,
|
||||
CreateProducerOptions,
|
||||
Message,
|
||||
PromptRequest,
|
||||
PromptResponse,
|
||||
PubSubBackend,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
MessagingRuntimeLive,
|
||||
PubSub,
|
||||
runProcessorScoped,
|
||||
topics,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type CreateConsumerOptions,
|
||||
type CreateProducerOptions,
|
||||
type Message,
|
||||
type PromptRequest,
|
||||
type PromptResponse,
|
||||
type PubSubBackend,
|
||||
} from "@trustgraph/base";
|
||||
import { PromptTemplateService } from "../prompt/template.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ import type {
|
|||
TriplesQueryRequest,
|
||||
TriplesQueryResponse,
|
||||
} from "@trustgraph/base";
|
||||
import { makeDocumentRagEngine, type DocumentRagClients } from "../retrieval/document-rag.js";
|
||||
import { makeGraphRagEngine, type GraphRagClients } from "../retrieval/graph-rag.js";
|
||||
import type { DocumentRagClients } from "../retrieval/document-rag.js";
|
||||
import { makeDocumentRagEngine, } from "../retrieval/document-rag.js";
|
||||
import type { GraphRagClients } from "../retrieval/graph-rag.js";
|
||||
import { makeGraphRagEngine, } from "../retrieval/graph-rag.js";
|
||||
|
||||
const requestor = <TReq, TRes>(
|
||||
handler: (request: TReq) => TRes,
|
||||
|
|
|
|||
|
|
@ -14,22 +14,23 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowContext,
|
||||
FlowProcessorRuntime,
|
||||
ToolRequest,
|
||||
ToolResponse,
|
||||
EffectConfigHandler,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
makeFlowProcessorProgram,
|
||||
errorMessage,
|
||||
type ProcessorConfig,
|
||||
type FlowContext,
|
||||
type FlowProcessorRuntime,
|
||||
type ToolRequest,
|
||||
type ToolResponse,
|
||||
type EffectConfigHandler,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { Context, Effect, Layer, Ref } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,27 @@
|
|||
import {
|
||||
NodeRuntime,
|
||||
} from "@effect/platform-node";
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowContext,
|
||||
FlowProcessorRuntime,
|
||||
AgentRequest,
|
||||
AgentResponse,
|
||||
TextCompletionRequest,
|
||||
TextCompletionResponse,
|
||||
GraphRagRequest,
|
||||
GraphRagResponse,
|
||||
DocumentRagRequest,
|
||||
DocumentRagResponse,
|
||||
TriplesQueryRequest,
|
||||
TriplesQueryResponse,
|
||||
ToolRequest,
|
||||
ToolResponse,
|
||||
EffectConfigHandler,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
|
|
@ -26,37 +47,19 @@ import {
|
|||
makeRequestResponseSpec,
|
||||
makeFlowProcessorProgram,
|
||||
errorMessage,
|
||||
type ProcessorConfig,
|
||||
type FlowContext,
|
||||
type FlowProcessorRuntime,
|
||||
type AgentRequest,
|
||||
type AgentResponse,
|
||||
type TextCompletionRequest,
|
||||
type TextCompletionResponse,
|
||||
type GraphRagRequest,
|
||||
type GraphRagResponse,
|
||||
type DocumentRagRequest,
|
||||
type DocumentRagResponse,
|
||||
type TriplesQueryRequest,
|
||||
type TriplesQueryResponse,
|
||||
type ToolRequest,
|
||||
type ToolResponse,
|
||||
type EffectConfigHandler,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {Context, Effect, Layer, Match, Ref} from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
import type {
|
||||
ExplainData,
|
||||
} from "./tools.js";
|
||||
import {
|
||||
createKnowledgeQueryTool,
|
||||
createDocumentQueryTool,
|
||||
createTriplesQueryTool,
|
||||
createMcpTool,
|
||||
type ExplainData,
|
||||
} from "./tools.js";
|
||||
import { buildReActPrompt } from "./prompt.js";
|
||||
import { filterToolsByGroupAndState } from "../tool-filter.js";
|
||||
|
|
@ -550,9 +553,9 @@ export function parseReActResponse(text: string): {
|
|||
const firstLine = trimmed.slice("Final Answer:".length).trim();
|
||||
const remainingLines = lines.slice(i + 1).join("\n").trim();
|
||||
finalAnswer =
|
||||
firstLine + (remainingLines.length > 0 ? "\n" + remainingLines : "");
|
||||
firstLine + (remainingLines.length > 0 ? `\n${remainingLines}` : "");
|
||||
break;
|
||||
} else if (trimmed.startsWith("Thought:")) {
|
||||
}if (trimmed.startsWith("Thought:")) {
|
||||
currentSection = "thought";
|
||||
const content = trimmed.slice("Thought:".length).trim();
|
||||
if (content.length > 0) {
|
||||
|
|
@ -577,14 +580,14 @@ export function parseReActResponse(text: string): {
|
|||
// Continuation line for current section
|
||||
Match.value(currentSection).pipe(
|
||||
Match.when("thought", () => {
|
||||
thought += "\n" + trimmed;
|
||||
thought += `\n${trimmed}`;
|
||||
}),
|
||||
Match.when("action", () => {
|
||||
// Action should be a single line (tool name), but handle multi-line
|
||||
action += " " + trimmed;
|
||||
action += ` ${trimmed}`;
|
||||
}),
|
||||
Match.when("action_input", () => {
|
||||
actionInput += "\n" + trimmed;
|
||||
actionInput += `\n${trimmed}`;
|
||||
}),
|
||||
Match.exhaustive,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import { Effect, Match } from "effect";
|
|||
import * as O from "effect/Option";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
import { agentToolError, type AgentTool, type ToolArg } from "./types.js";
|
||||
import type { AgentTool, ToolArg } from "./types.js";
|
||||
import { agentToolError, } from "./types.js";
|
||||
|
||||
const decodeJsonUnknown = S.decodeUnknownOption(S.UnknownFromJsonString);
|
||||
const decodeTerm = S.decodeUnknownOption(TermSchema);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function isToolAvailable(
|
|||
const config = tool.config ?? {};
|
||||
|
||||
// Get tool groups (default to ["default"])
|
||||
let toolGroups = config["group"] as string[] | string | undefined;
|
||||
let toolGroups = config.group as string[] | string | undefined;
|
||||
if (toolGroups === undefined) toolGroups = ["default"];
|
||||
if (!Array.isArray(toolGroups)) toolGroups = [toolGroups];
|
||||
|
||||
|
|
@ -56,6 +56,6 @@ function isToolAvailable(
|
|||
* Get the next state after successful tool execution.
|
||||
*/
|
||||
export function getNextState(tool: AgentTool, currentState: string): string {
|
||||
const nextState = tool.config?.["state"] as string | undefined;
|
||||
const nextState = tool.config?.state as string | undefined;
|
||||
return nextState ?? currentState;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,22 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/chunking/recursive_splitter/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
TextDocument,
|
||||
Chunk,
|
||||
Triples,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
makeParameterSpec,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type TextDocument,
|
||||
type Chunk,
|
||||
type Triples,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,16 @@ import {NodeRuntime} from "@effect/platform-node";
|
|||
import {Duration, Effect, HashMap, Match, Option, SynchronizedRef} from "effect";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
import type {
|
||||
AsyncProcessorRuntime,
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
ConfigOperation,
|
||||
ConfigRequest,
|
||||
ConfigResponse,
|
||||
Message,
|
||||
ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
ConfigRequest as ConfigRequestSchema,
|
||||
ConfigResponse as ConfigResponseSchema,
|
||||
|
|
@ -18,14 +28,6 @@ import {
|
|||
optionalStringConfig,
|
||||
processorLifecycleError,
|
||||
topics,
|
||||
type AsyncProcessorRuntime,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type ConfigOperation,
|
||||
type ConfigRequest,
|
||||
type ConfigResponse,
|
||||
type Message,
|
||||
type ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import {readTextFileEffect, writeTextFileEffect} from "../runtime/effect-files.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,17 @@
|
|||
*/
|
||||
|
||||
import {NodeRuntime} from "@effect/platform-node";
|
||||
import type {
|
||||
AsyncProcessorRuntime,
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
KnowledgeOperation,
|
||||
KnowledgeRequest,
|
||||
KnowledgeResponse,
|
||||
Message,
|
||||
ProcessorConfig,
|
||||
PubSubError,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
KnowledgeRequest as KnowledgeRequestSchema,
|
||||
KnowledgeResponse as KnowledgeResponseSchema,
|
||||
|
|
@ -17,15 +28,6 @@ import {
|
|||
optionalStringConfig,
|
||||
processorLifecycleError,
|
||||
topics,
|
||||
type AsyncProcessorRuntime,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
type KnowledgeOperation,
|
||||
type KnowledgeRequest,
|
||||
type KnowledgeResponse,
|
||||
type Message,
|
||||
type ProcessorConfig,
|
||||
type PubSubError,
|
||||
} from "@trustgraph/base";
|
||||
import {Duration, Effect, HashMap, Match, SynchronizedRef} from "effect";
|
||||
import * as O from "effect/Option";
|
||||
|
|
|
|||
|
|
@ -15,26 +15,28 @@
|
|||
|
||||
import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
|
||||
import type { TextItem } from "pdfjs-dist/types/src/display/api.js";
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
Document,
|
||||
TextDocument,
|
||||
Triples,
|
||||
Triple,
|
||||
Term,
|
||||
LibrarianRequest,
|
||||
LibrarianResponse,
|
||||
MessagingDeliveryError,
|
||||
MessagingLifecycleError,
|
||||
MessagingTimeoutError,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
makeRequestResponseSpec,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type Document,
|
||||
type TextDocument,
|
||||
type Triples,
|
||||
type Triple,
|
||||
type Term,
|
||||
type LibrarianRequest,
|
||||
type LibrarianResponse,
|
||||
type MessagingDeliveryError,
|
||||
type MessagingLifecycleError,
|
||||
type MessagingTimeoutError,
|
||||
type Spec,
|
||||
errorMessage,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
|
|
|
|||
|
|
@ -8,14 +8,16 @@ import { NodeRuntime } from "@effect/platform-node";
|
|||
import { Config, Effect, Layer } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import type {
|
||||
EmbeddingsServiceShape,
|
||||
ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
Embeddings,
|
||||
EmbeddingsError,
|
||||
errorMessage,
|
||||
makeEmbeddingsService,
|
||||
makeEmbeddingsSpecs,
|
||||
type EmbeddingsServiceShape,
|
||||
type ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
|
||||
|
|
|
|||
|
|
@ -10,29 +10,31 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/extract/knowledge/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowContext,
|
||||
Chunk,
|
||||
Triples,
|
||||
EntityContexts,
|
||||
EntityContext,
|
||||
PromptRequest,
|
||||
PromptResponse,
|
||||
TextCompletionRequest,
|
||||
TextCompletionResponse,
|
||||
Triple,
|
||||
Term,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
EffectRequestResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
makeRequestResponseSpec,
|
||||
makeFlowProcessorProgram,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowContext,
|
||||
type Chunk,
|
||||
type Triples,
|
||||
type EntityContexts,
|
||||
type EntityContext,
|
||||
type PromptRequest,
|
||||
type PromptResponse,
|
||||
type TextCompletionRequest,
|
||||
type TextCompletionResponse,
|
||||
type Triple,
|
||||
type Term,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type EffectRequestResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { Effect } from "effect";
|
||||
|
|
@ -375,7 +377,7 @@ function jsonCandidates(raw: string): ReadonlyArray<string> {
|
|||
const partial = arrayMatch[0];
|
||||
const lastBrace = partial.lastIndexOf("}");
|
||||
if (lastBrace > 0) {
|
||||
candidates.push(partial.slice(0, lastBrace + 1) + "]");
|
||||
candidates.push(`${partial.slice(0, lastBrace + 1)}]`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,21 +14,23 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/flow/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
AsyncProcessorRuntime,
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
RequestResponse,
|
||||
ConfigRequest,
|
||||
ConfigResponse,
|
||||
FlowRequest,
|
||||
FlowResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeAsyncProcessor,
|
||||
type ProcessorConfig,
|
||||
type AsyncProcessorRuntime,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
topics,
|
||||
makeRequestResponse,
|
||||
type RequestResponse,
|
||||
type ConfigRequest,
|
||||
type ConfigResponse,
|
||||
FlowRequest as FlowRequestSchema,
|
||||
FlowResponse as FlowResponseSchema,
|
||||
type FlowRequest,
|
||||
type FlowResponse,
|
||||
errorMessage,
|
||||
processorLifecycleError,
|
||||
} from "@trustgraph/base";
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@
|
|||
*/
|
||||
|
||||
import { Clock, Effect, Exit, HashMap, HashSet, Option, Random, Scope, SynchronizedRef, Tuple } from "effect";
|
||||
import type {
|
||||
EffectRequestResponse,
|
||||
MessagingDeliveryError,
|
||||
MessagingLifecycleError,
|
||||
MessagingTimeoutError,
|
||||
PubSubBackend,
|
||||
PubSubError,
|
||||
RequestResponseFactoryService,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
loadMessagingRuntimeConfig,
|
||||
makeNatsBackend,
|
||||
|
|
@ -17,19 +26,14 @@ import {
|
|||
makeRequestResponseFactoryService,
|
||||
messagingDeliveryError,
|
||||
messagingLifecycleError,
|
||||
type EffectRequestResponse,
|
||||
type MessagingDeliveryError,
|
||||
type MessagingLifecycleError,
|
||||
type MessagingTimeoutError,
|
||||
type PubSubBackend,
|
||||
type PubSubError,
|
||||
type RequestResponseFactoryService,
|
||||
} from "@trustgraph/base";
|
||||
import type { GatewayConfig } from "../server.js";
|
||||
import type {
|
||||
DispatchSerializationError,
|
||||
} from "./serialize.js";
|
||||
import {
|
||||
translateRequestEffect,
|
||||
translateResponseEffect,
|
||||
type DispatchSerializationError,
|
||||
} from "./serialize.js";
|
||||
|
||||
export type EffectResponder<E = never, R = never> = (
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
* Python reference: trustgraph-base/trustgraph/messaging/translators/primitives.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
Term,
|
||||
Triple,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
BlankTerm,
|
||||
errorMessage,
|
||||
|
|
@ -26,8 +30,6 @@ import {
|
|||
Term as TermSchema,
|
||||
Triple as TripleSchema,
|
||||
TripleTerm,
|
||||
type Term,
|
||||
type Triple,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, HashSet, Match } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { Cause, Effect, Layer, Queue, Scope } from "effect";
|
||||
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
||||
import type { Cause, Scope } from "effect";
|
||||
import { Effect, Layer, Queue, } from "effect";
|
||||
import type { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
||||
import * as RpcServer from "effect/unstable/rpc/RpcServer";
|
||||
import { errorMessage } from "@trustgraph/base";
|
||||
import type { DispatcherManager, DispatcherStreamError } from "./dispatch/manager.js";
|
||||
import { DispatchError, DispatchPayload, DispatchStreamChunk, TrustGraphRpcs } from "./rpc-contract.js";
|
||||
import type { DispatchPayload, } from "./rpc-contract.js";
|
||||
import { DispatchError, DispatchStreamChunk, TrustGraphRpcs } from "./rpc-contract.js";
|
||||
|
||||
export interface GatewayRpcServer {
|
||||
readonly httpEffect: Effect.Effect<
|
||||
|
|
|
|||
|
|
@ -12,17 +12,21 @@ import * as O from "effect/Option";
|
|||
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
||||
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
||||
import type {
|
||||
PubSubBackend,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
formatPrometheusMetrics,
|
||||
messagingLifecycleError,
|
||||
optionalStringConfig,
|
||||
prometheusContentType,
|
||||
toTgError,
|
||||
type PubSubBackend,
|
||||
} from "@trustgraph/base";
|
||||
import { GatewayWorkbenchHttpApi } from "@trustgraph/client/rpc/contract";
|
||||
import { makeDispatcherManagerScoped, type DispatcherManager } from "./dispatch/manager.js";
|
||||
import { makeGatewayRpcServer, type GatewayRpcServer } from "./rpc-server.js";
|
||||
import type { DispatcherManager } from "./dispatch/manager.js";
|
||||
import { makeDispatcherManagerScoped, } from "./dispatch/manager.js";
|
||||
import type { GatewayRpcServer } from "./rpc-server.js";
|
||||
import { makeGatewayRpcServer, } from "./rpc-server.js";
|
||||
|
||||
export interface GatewayConfig {
|
||||
port: number;
|
||||
|
|
|
|||
|
|
@ -10,32 +10,36 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/librarian/service/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
AsyncProcessorRuntime,
|
||||
BackendConsumer,
|
||||
BackendProducer,
|
||||
LibrarianRequest,
|
||||
LibrarianResponse,
|
||||
CollectionManagementRequest,
|
||||
CollectionManagementResponse,
|
||||
DocumentMetadata,
|
||||
ProcessingMetadata,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
errorMessage,
|
||||
makeAsyncProcessor,
|
||||
makeProcessorProgram,
|
||||
type ProcessorConfig,
|
||||
type AsyncProcessorRuntime,
|
||||
type BackendConsumer,
|
||||
type BackendProducer,
|
||||
topics,
|
||||
type LibrarianRequest,
|
||||
type LibrarianResponse,
|
||||
type CollectionManagementRequest,
|
||||
type CollectionManagementResponse,
|
||||
DocumentMetadata as DocumentMetadataSchema,
|
||||
type DocumentMetadata,
|
||||
ProcessingMetadata as ProcessingMetadataSchema,
|
||||
type ProcessingMetadata,
|
||||
Triple as TripleSchema,
|
||||
processorLifecycleError,
|
||||
} from "@trustgraph/base";
|
||||
import type { Message } from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { Clock, Config, DateTime, Duration, Effect, Match, Option, Random, SynchronizedRef } from "effect";
|
||||
import * as A from "effect/Array";
|
||||
import * as MutableHashMap from "effect/MutableHashMap";
|
||||
import * as S from "effect/Schema";
|
||||
import { makeCollectionManager, type CollectionManager } from "./collection-manager.js";
|
||||
import type { CollectionManager } from "./collection-manager.js";
|
||||
import { makeCollectionManager, } from "./collection-manager.js";
|
||||
import {
|
||||
ensureDirectoryEffect,
|
||||
joinPath,
|
||||
|
|
@ -127,13 +131,10 @@ const decodePersistedLibrarianState = (
|
|||
);
|
||||
|
||||
const randomUuid: Effect.Effect<string> = Effect.gen(function* () {
|
||||
const bytes: number[] = [];
|
||||
for (let index = 0; index < 16; index += 1) {
|
||||
bytes.push(yield* Random.nextIntBetween(0, 255));
|
||||
}
|
||||
|
||||
bytes[6] = (bytes[6]! & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
|
||||
const raw = yield* Effect.forEach(A.range(0, 15), () => Random.nextIntBetween(0, 255));
|
||||
const bytes = A.map(raw, (byte, index) =>
|
||||
index === 6 ? (byte & 0x0f) | 0x40 : index === 8 ? (byte & 0x3f) | 0x80 : byte,
|
||||
);
|
||||
|
||||
const hex = bytes.map((byte) => byte.toString(16).padStart(2, "0"));
|
||||
return [
|
||||
|
|
@ -760,25 +761,24 @@ export function makeLibrarianService(config: LibrarianServiceConfig): LibrarianS
|
|||
|
||||
|
||||
handleLibrarianOperation: function(this: LibrarianService, request: LibrarianRequest): Effect.Effect<LibrarianResponse, LibrarianServiceError> {
|
||||
const service = this;
|
||||
return Match.value(request.operation).pipe(
|
||||
Match.when("add-document", () => service.addDocument(request)),
|
||||
Match.when("remove-document", () => service.removeDocument(request)),
|
||||
Match.when("update-document", () => service.updateDocument(request)),
|
||||
Match.when("list-documents", () => service.listDocuments(request)),
|
||||
Match.when("add-document", () => this.addDocument(request)),
|
||||
Match.when("remove-document", () => this.removeDocument(request)),
|
||||
Match.when("update-document", () => this.updateDocument(request)),
|
||||
Match.when("list-documents", () => this.listDocuments(request)),
|
||||
Match.when("get-document-metadata", () => getDocumentMetadataEffect(request)),
|
||||
Match.when("get-document-content", () => service.getDocumentContent(request)),
|
||||
Match.when("add-child-document", () => service.addChildDocument(request)),
|
||||
Match.when("get-document-content", () => this.getDocumentContent(request)),
|
||||
Match.when("add-child-document", () => this.addChildDocument(request)),
|
||||
Match.when("list-children", () => listChildrenEffect(request)),
|
||||
Match.when("add-processing", () => service.addProcessing(request)),
|
||||
Match.when("remove-processing", () => service.removeProcessing(request)),
|
||||
Match.when("list-processing", () => service.listProcessing(request)),
|
||||
Match.when("begin-upload", () => service.beginUpload(request)),
|
||||
Match.when("add-processing", () => this.addProcessing(request)),
|
||||
Match.when("remove-processing", () => this.removeProcessing(request)),
|
||||
Match.when("list-processing", () => this.listProcessing(request)),
|
||||
Match.when("begin-upload", () => this.beginUpload(request)),
|
||||
Match.when("upload-chunk", () => uploadChunkEffect(request)),
|
||||
Match.when("complete-upload", () => service.completeUpload(request)),
|
||||
Match.when("complete-upload", () => this.completeUpload(request)),
|
||||
Match.when("get-upload-status", () => getUploadStatusEffect(request)),
|
||||
Match.when("abort-upload", () => abortUploadEffect(request)),
|
||||
Match.when("list-uploads", () => service.listUploads(request)),
|
||||
Match.when("list-uploads", () => this.listUploads(request)),
|
||||
Match.when("stream-document", () =>
|
||||
Effect.fail(
|
||||
librarianServiceError("stream-document", "stream-document must be handled as a streaming operation"),
|
||||
|
|
@ -1427,7 +1427,7 @@ export function makeLibrarianService(config: LibrarianServiceConfig): LibrarianS
|
|||
// ---------- Persistence ----------
|
||||
|
||||
persist: Effect.gen(function* () {
|
||||
const current = service!;
|
||||
const current = yield* getService;
|
||||
const serviceState = yield* SynchronizedRef.get(current.state);
|
||||
const data = {
|
||||
documents: Object.fromEntries(serviceState.documents),
|
||||
|
|
@ -1448,7 +1448,7 @@ export function makeLibrarianService(config: LibrarianServiceConfig): LibrarianS
|
|||
|
||||
|
||||
loadFromDisk: Effect.gen(function* () {
|
||||
const current = service!;
|
||||
const current = yield* getService;
|
||||
const parsed = yield* Effect.gen(function* () {
|
||||
const raw = yield* readTextFileEffect(current.persistPath).pipe(
|
||||
Effect.mapError((cause) => librarianServiceError("persist-read", cause)),
|
||||
|
|
|
|||
|
|
@ -10,16 +10,22 @@
|
|||
|
||||
import { AzureOpenAI } from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
type LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Stream } from "effect";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
llmStreamPart,
|
||||
makeTextCompletionLayer,
|
||||
|
|
@ -27,8 +33,6 @@ import {
|
|||
providerStatusError,
|
||||
requiredString,
|
||||
streamTextCompletionChunks,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type AzureOpenAIProcessorConfig = ProcessorConfig & {
|
||||
|
|
|
|||
|
|
@ -6,23 +6,27 @@
|
|||
|
||||
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Redacted } from "effect";
|
||||
import { FetchHttpClient } from "effect/unstable/http";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
makeLanguageModelProvider,
|
||||
makeTextCompletionLayer,
|
||||
optionalStringConfig,
|
||||
requiredString,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type ClaudeProcessorConfig = ProcessorConfig & {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
import type {
|
||||
LlmChunk,
|
||||
LlmResult,
|
||||
LlmProvider,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
Llm,
|
||||
TooManyRequestsError,
|
||||
errorMessage,
|
||||
makeLlmServiceShape,
|
||||
type LlmChunk,
|
||||
type LlmResult,
|
||||
type LlmProvider,
|
||||
} from "@trustgraph/base";
|
||||
import { Config, Context, Effect, Layer, Match, Ref, Result, Stream } from "effect";
|
||||
import type { Context, } from "effect";
|
||||
import { Config, Effect, Layer, Match, Ref, Result, Stream } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
import type * as Scope from "effect/Scope";
|
||||
import { AiError, LanguageModel, Prompt, Response } from "effect/unstable/ai";
|
||||
import type { LanguageModel, Prompt, Response } from "effect/unstable/ai";
|
||||
import { AiError, } from "effect/unstable/ai";
|
||||
|
||||
export class TextCompletionConfigError extends S.TaggedErrorClass<TextCompletionConfigError>()(
|
||||
"TextCompletionConfigError",
|
||||
|
|
|
|||
|
|
@ -8,16 +8,22 @@
|
|||
|
||||
import { Mistral } from "@mistralai/mistralai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
type LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Stream } from "effect";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
llmStreamPart,
|
||||
makeTextCompletionLayer,
|
||||
|
|
@ -26,8 +32,6 @@ import {
|
|||
requiredString,
|
||||
streamTextCompletionChunks,
|
||||
textFromContent,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type MistralProcessorConfig = ProcessorConfig & {
|
||||
|
|
|
|||
|
|
@ -8,24 +8,28 @@
|
|||
|
||||
import { Ollama } from "ollama";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
type LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Stream } from "effect";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
llmStreamPart,
|
||||
makeTextCompletionLayer,
|
||||
optionalStringConfig,
|
||||
providerRuntimeError,
|
||||
streamTextCompletionChunks,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type OllamaProcessorConfig = ProcessorConfig & {
|
||||
|
|
@ -68,7 +72,7 @@ const makeOllamaProviderFromClient = (
|
|||
_temperature?: number,
|
||||
) => {
|
||||
const modelName = model ?? defaultModel;
|
||||
const fullPrompt = system + "\n\n" + prompt;
|
||||
const fullPrompt = `${system}\n\n${prompt}`;
|
||||
|
||||
return Effect.tryPromise({
|
||||
try: () =>
|
||||
|
|
@ -95,7 +99,7 @@ const makeOllamaProviderFromClient = (
|
|||
_temperature?: number,
|
||||
) => {
|
||||
const modelName = model ?? defaultModel;
|
||||
const fullPrompt = system + "\n\n" + prompt;
|
||||
const fullPrompt = `${system}\n\n${prompt}`;
|
||||
|
||||
return Stream.fromEffect(
|
||||
Effect.tryPromise({
|
||||
|
|
|
|||
|
|
@ -11,16 +11,22 @@
|
|||
|
||||
import OpenAI from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
type LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Stream } from "effect";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
llmStreamPart,
|
||||
makeTextCompletionLayer,
|
||||
|
|
@ -28,8 +34,6 @@ import {
|
|||
providerStatusError,
|
||||
requiredString,
|
||||
streamTextCompletionChunks,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type OpenAICompatibleProcessorConfig = ProcessorConfig & {
|
||||
|
|
|
|||
|
|
@ -6,16 +6,22 @@
|
|||
|
||||
import OpenAI from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import type {
|
||||
Llm,
|
||||
LlmProvider,
|
||||
ProcessorConfig,
|
||||
LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeLlmService,
|
||||
makeFlowProcessorProgram,
|
||||
makeLlmSpecs,
|
||||
type Llm,
|
||||
type LlmProvider,
|
||||
type ProcessorConfig,
|
||||
type LlmResult,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Stream } from "effect";
|
||||
import type {
|
||||
TextCompletionConfigError,
|
||||
TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
import {
|
||||
llmStreamPart,
|
||||
makeTextCompletionLayer,
|
||||
|
|
@ -23,8 +29,6 @@ import {
|
|||
providerStatusError,
|
||||
requiredString,
|
||||
streamTextCompletionChunks,
|
||||
type TextCompletionConfigError,
|
||||
type TextCompletionRuntimeError,
|
||||
} from "./common.ts";
|
||||
|
||||
export type OpenAIProcessorConfig = ProcessorConfig & {
|
||||
|
|
|
|||
|
|
@ -24,19 +24,21 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/prompt/template/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
EffectConfigHandler,
|
||||
FlowContext,
|
||||
FlowProcessorRuntime,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
PromptRequest,
|
||||
PromptResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
type ProcessorConfig,
|
||||
type EffectConfigHandler,
|
||||
type FlowContext,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type PromptRequest,
|
||||
type PromptResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { QdrantClient, type QdrantClientParams } from "@qdrant/js-client-rest";
|
||||
import type { QdrantClientParams } from "@qdrant/js-client-rest";
|
||||
import { QdrantClient, } from "@qdrant/js-client-rest";
|
||||
import { errorMessage } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import * as S from "effect/Schema";
|
||||
|
|
|
|||
|
|
@ -7,30 +7,34 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/query/doc_embeddings/qdrant/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowProcessorStartEffect,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
DocumentEmbeddingsRequest,
|
||||
DocumentEmbeddingsResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
processorLifecycleError,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowProcessorStartEffect,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type DocumentEmbeddingsRequest,
|
||||
type DocumentEmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import type {
|
||||
QdrantDocQueryConfig,
|
||||
QdrantDocEmbeddingsQueryError,
|
||||
} from "./qdrant-doc.js";
|
||||
import {
|
||||
QdrantDocEmbeddingsQueryLive,
|
||||
QdrantDocEmbeddingsQueryService,
|
||||
makeQdrantDocEmbeddingsQueryServiceEffect,
|
||||
type QdrantDocQueryConfig,
|
||||
type QdrantDocEmbeddingsQueryError,
|
||||
} from "./qdrant-doc.js";
|
||||
|
||||
const DocumentEmbeddingsResponseProducer = makeProducerSpec<DocumentEmbeddingsResponse>("document-embeddings-response");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import { errorMessage } from "@trustgraph/base";
|
|||
import { Config, Context, Effect, Layer } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import { makeQdrantClient, type QdrantClientFactory, type QdrantClientLike } from "../../qdrant/client.js";
|
||||
import type { QdrantClientFactory, QdrantClientLike } from "../../qdrant/client.js";
|
||||
import { makeQdrantClient, } from "../../qdrant/client.js";
|
||||
|
||||
export interface QdrantDocQueryConfig {
|
||||
url?: string;
|
||||
|
|
|
|||
|
|
@ -7,30 +7,34 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/query/graph_embeddings/qdrant/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowProcessorStartEffect,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
GraphEmbeddingsRequest,
|
||||
GraphEmbeddingsResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
processorLifecycleError,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowProcessorStartEffect,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type GraphEmbeddingsRequest,
|
||||
type GraphEmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import type {
|
||||
QdrantGraphQueryConfig,
|
||||
QdrantGraphEmbeddingsQueryError,
|
||||
} from "./qdrant-graph.js";
|
||||
import {
|
||||
QdrantGraphEmbeddingsQueryLive,
|
||||
QdrantGraphEmbeddingsQueryService,
|
||||
makeQdrantGraphEmbeddingsQueryServiceEffect,
|
||||
type QdrantGraphQueryConfig,
|
||||
type QdrantGraphEmbeddingsQueryError,
|
||||
} from "./qdrant-graph.js";
|
||||
|
||||
const GraphEmbeddingsResponseProducer = makeProducerSpec<GraphEmbeddingsResponse>("graph-embeddings-response");
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/query/graph_embeddings/qdrant/service.py
|
||||
*/
|
||||
|
||||
import { errorMessage, type Term } from "@trustgraph/base";
|
||||
import type { Term } from "@trustgraph/base";
|
||||
import { errorMessage, } from "@trustgraph/base";
|
||||
import { Config, Context, Effect, Layer } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import { makeQdrantClient, type QdrantClientFactory, type QdrantClientLike } from "../../qdrant/client.js";
|
||||
import type { QdrantClientFactory, QdrantClientLike } from "../../qdrant/client.js";
|
||||
import { makeQdrantClient, } from "../../qdrant/client.js";
|
||||
|
||||
export interface QdrantGraphQueryConfig {
|
||||
url?: string;
|
||||
|
|
|
|||
|
|
@ -7,30 +7,34 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/query/triples/falkordb/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowProcessorStartEffect,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
TriplesQueryRequest,
|
||||
TriplesQueryResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeProducerSpec,
|
||||
processorLifecycleError,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowProcessorStartEffect,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type TriplesQueryRequest,
|
||||
type TriplesQueryResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import type {
|
||||
FalkorDBQueryConfig,
|
||||
FalkorDBTriplesQueryError,
|
||||
} from "./falkordb.js";
|
||||
import {
|
||||
FalkorDBTriplesQueryLive,
|
||||
FalkorDBTriplesQueryService,
|
||||
makeFalkorDBTriplesQueryServiceScoped,
|
||||
type FalkorDBQueryConfig,
|
||||
type FalkorDBTriplesQueryError,
|
||||
} from "./falkordb.js";
|
||||
|
||||
const TriplesResponseProducer = makeProducerSpec<TriplesQueryResponse>("triples-response");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import { createClient, Graph } from "falkordb";
|
||||
import { errorMessage, type Term, type Triple } from "@trustgraph/base";
|
||||
import type { Term, Triple } from "@trustgraph/base";
|
||||
import { errorMessage, } from "@trustgraph/base";
|
||||
import { Config, Context, Effect, Layer, Match } from "effect";
|
||||
import * as Predicate from "effect/Predicate";
|
||||
import * as S from "effect/Schema";
|
||||
|
|
|
|||
|
|
@ -8,36 +8,40 @@
|
|||
*/
|
||||
|
||||
import {NodeRuntime} from "@effect/platform-node";
|
||||
import type {
|
||||
DocumentEmbeddingsRequest,
|
||||
DocumentEmbeddingsResponse,
|
||||
DocumentRagRequest,
|
||||
DocumentRagResponse,
|
||||
EmbeddingsRequest,
|
||||
EmbeddingsResponse,
|
||||
FlowContext,
|
||||
FlowProcessorRuntime,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
ProcessorConfig,
|
||||
PromptRequest,
|
||||
PromptResponse,
|
||||
Spec,
|
||||
TextCompletionRequest,
|
||||
TextCompletionResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeConsumerSpec,
|
||||
makeFlowProcessor,
|
||||
makeProducerSpec,
|
||||
makeRequestResponseSpec,
|
||||
makeFlowProcessorProgram,
|
||||
type DocumentEmbeddingsRequest,
|
||||
type DocumentEmbeddingsResponse,
|
||||
type DocumentRagRequest,
|
||||
type DocumentRagResponse,
|
||||
type EmbeddingsRequest,
|
||||
type EmbeddingsResponse,
|
||||
type FlowContext,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type ProcessorConfig,
|
||||
type PromptRequest,
|
||||
type PromptResponse,
|
||||
type Spec,
|
||||
type TextCompletionRequest,
|
||||
type TextCompletionResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {Effect} from "effect";
|
||||
import type {
|
||||
DocumentRagEngineError,
|
||||
DocumentRagClients,
|
||||
} from "./document-rag.js";
|
||||
import {
|
||||
DocumentRagEngine,
|
||||
DocumentRagEngineError,
|
||||
DocumentRagLive,
|
||||
makeDocumentRagEngine,
|
||||
type DocumentRagClients,
|
||||
} from "./document-rag.js";
|
||||
|
||||
const DocumentRagResponseProducer = makeProducerSpec<DocumentRagResponse>("document-rag-response");
|
||||
|
|
|
|||
|
|
@ -8,39 +8,43 @@
|
|||
*/
|
||||
|
||||
import {NodeRuntime} from "@effect/platform-node";
|
||||
import type {
|
||||
FlowContext,
|
||||
FlowProcessorRuntime,
|
||||
FlowResourceNotFoundError,
|
||||
GraphEmbeddingsRequest,
|
||||
GraphEmbeddingsResponse,
|
||||
GraphRagRequest,
|
||||
GraphRagResponse,
|
||||
EmbeddingsRequest,
|
||||
EmbeddingsResponse,
|
||||
MessagingDeliveryError,
|
||||
ProcessorConfig,
|
||||
PromptRequest,
|
||||
PromptResponse,
|
||||
Spec,
|
||||
TextCompletionRequest,
|
||||
TextCompletionResponse,
|
||||
TriplesQueryRequest,
|
||||
TriplesQueryResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeConsumerSpec,
|
||||
makeFlowProcessor,
|
||||
makeProducerSpec,
|
||||
makeRequestResponseSpec,
|
||||
makeFlowProcessorProgram,
|
||||
type FlowContext,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowResourceNotFoundError,
|
||||
type GraphEmbeddingsRequest,
|
||||
type GraphEmbeddingsResponse,
|
||||
type GraphRagRequest,
|
||||
type GraphRagResponse,
|
||||
type EmbeddingsRequest,
|
||||
type EmbeddingsResponse,
|
||||
type MessagingDeliveryError,
|
||||
type ProcessorConfig,
|
||||
type PromptRequest,
|
||||
type PromptResponse,
|
||||
type Spec,
|
||||
type TextCompletionRequest,
|
||||
type TextCompletionResponse,
|
||||
type TriplesQueryRequest,
|
||||
type TriplesQueryResponse,
|
||||
} from "@trustgraph/base";
|
||||
import {Effect} from "effect";
|
||||
import type {
|
||||
GraphRagEngineError,
|
||||
GraphRagClients,
|
||||
GraphRagConfig,
|
||||
} from "./graph-rag.js";
|
||||
import {
|
||||
GraphRagEngine,
|
||||
GraphRagEngineError,
|
||||
GraphRagLive,
|
||||
makeGraphRagEngine,
|
||||
type GraphRagClients,
|
||||
type GraphRagConfig,
|
||||
} from "./graph-rag.js";
|
||||
|
||||
const GraphRagResponseProducer = makeProducerSpec<GraphRagResponse>("graph-rag-response");
|
||||
|
|
|
|||
|
|
@ -9,33 +9,37 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/storage/graph_embeddings/qdrant/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowProcessorStartEffect,
|
||||
FlowContext,
|
||||
FlowResourceNotFoundError,
|
||||
MessagingDeliveryError,
|
||||
MessagingLifecycleError,
|
||||
MessagingTimeoutError,
|
||||
EntityContexts,
|
||||
EmbeddingsRequest,
|
||||
EmbeddingsResponse,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
makeRequestResponseSpec,
|
||||
processorLifecycleError,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowProcessorStartEffect,
|
||||
type FlowContext,
|
||||
type FlowResourceNotFoundError,
|
||||
type MessagingDeliveryError,
|
||||
type MessagingLifecycleError,
|
||||
type MessagingTimeoutError,
|
||||
type EntityContexts,
|
||||
type EmbeddingsRequest,
|
||||
type EmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import type {
|
||||
QdrantGraphEmbeddingsConfig,
|
||||
QdrantGraphEmbeddingsStoreError,
|
||||
} from "./qdrant-graph.js";
|
||||
import {
|
||||
QdrantGraphEmbeddingsStoreLive,
|
||||
QdrantGraphEmbeddingsStoreService,
|
||||
makeQdrantGraphEmbeddingsStoreServiceEffect,
|
||||
type QdrantGraphEmbeddingsConfig,
|
||||
type QdrantGraphEmbeddingsStoreError,
|
||||
} from "./qdrant-graph.js";
|
||||
|
||||
type GraphEmbeddingsStoreRequirements = QdrantGraphEmbeddingsStoreService;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ import { Config, Effect, Random } from "effect";
|
|||
import * as MutableHashSet from "effect/MutableHashSet";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import { makeQdrantClient, type QdrantClientFactory, type QdrantClientLike } from "../../qdrant/client.js";
|
||||
import type { QdrantClientFactory, QdrantClientLike } from "../../qdrant/client.js";
|
||||
import { makeQdrantClient, } from "../../qdrant/client.js";
|
||||
|
||||
export interface QdrantDocEmbeddingsConfig {
|
||||
url?: string;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/storage/graph_embeddings/qdrant/write.py
|
||||
*/
|
||||
|
||||
import { errorMessage, type Term } from "@trustgraph/base";
|
||||
import type { Term } from "@trustgraph/base";
|
||||
import { errorMessage, } from "@trustgraph/base";
|
||||
import { Config, Context, Effect, Layer, Match, Random } from "effect";
|
||||
import * as MutableHashSet from "effect/MutableHashSet";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import { makeQdrantClient, type QdrantClientFactory, type QdrantClientLike } from "../../qdrant/client.js";
|
||||
import type { QdrantClientFactory, QdrantClientLike } from "../../qdrant/client.js";
|
||||
import { makeQdrantClient, } from "../../qdrant/client.js";
|
||||
|
||||
export interface QdrantGraphEmbeddingsConfig {
|
||||
url?: string;
|
||||
|
|
|
|||
|
|
@ -8,26 +8,30 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/storage/triples/falkordb/service.py
|
||||
*/
|
||||
|
||||
import type {
|
||||
ProcessorConfig,
|
||||
FlowProcessorRuntime,
|
||||
FlowProcessorStartEffect,
|
||||
FlowContext,
|
||||
Triples,
|
||||
Spec,
|
||||
} from "@trustgraph/base";
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
makeConsumerSpec,
|
||||
processorLifecycleError,
|
||||
type ProcessorConfig,
|
||||
type FlowProcessorRuntime,
|
||||
type FlowProcessorStartEffect,
|
||||
type FlowContext,
|
||||
type Triples,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import type {
|
||||
FalkorDBConfig,
|
||||
FalkorDBTriplesStoreError,
|
||||
} from "./falkordb.js";
|
||||
import {
|
||||
FalkorDBTriplesStoreLive,
|
||||
FalkorDBTriplesStoreService,
|
||||
makeFalkorDBTriplesStoreServiceScoped,
|
||||
type FalkorDBConfig,
|
||||
type FalkorDBTriplesStoreError,
|
||||
} from "./falkordb.js";
|
||||
|
||||
const onStoreTriplesMessage = Effect.fn("TriplesStoreService.onMessage")(function* (
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
*/
|
||||
|
||||
import { createClient, Graph } from "falkordb";
|
||||
import { errorMessage, type Term, type Triple } from "@trustgraph/base";
|
||||
import type { Term, Triple } from "@trustgraph/base";
|
||||
import { errorMessage, } from "@trustgraph/base";
|
||||
import { Config, Context, Effect, Layer, Match } from "effect";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue