mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 09:29:38 +02:00
Use native runtimes for flow entrypoints
This commit is contained in:
parent
54fc21b38d
commit
74955d6041
38 changed files with 233 additions and 134 deletions
|
|
@ -1 +1 @@
|
|||
export { McpToolService, run } from "./service.js";
|
||||
export { McpToolService, run, runMain } from "./service.js";
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
|
||||
import {
|
||||
makeFlowProcessor,
|
||||
|
|
@ -29,7 +30,7 @@ import {
|
|||
type MessagingDeliveryError,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { Context, Effect, Layer, Ref } from "effect";
|
||||
import { Context, Effect, Layer, ManagedRuntime, Ref } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
|
|
@ -315,6 +316,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, McpToolR
|
|||
layer: () => McpToolRuntimeLive,
|
||||
});
|
||||
|
||||
const mcpToolRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return mcpToolRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ import {
|
|||
type Triples,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import { recursiveSplit } from "./recursive-splitter.js";
|
||||
|
||||
const DEFAULT_CHUNK_SIZE = 2000;
|
||||
|
|
@ -102,6 +103,12 @@ export const program = makeFlowProcessorProgram({
|
|||
specs: () => makeChunkingSpecs(),
|
||||
});
|
||||
|
||||
const chunkingRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return chunkingRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ import {
|
|||
type Spec,
|
||||
errorMessage,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Clock, Effect } from "effect";
|
||||
import { Clock, Effect, Layer, ManagedRuntime } from "effect";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
export class PdfDecoderError extends S.TaggedErrorClass<PdfDecoderError>()(
|
||||
|
|
@ -252,6 +253,12 @@ export const program = makeFlowProcessorProgram({
|
|||
specs: () => makePdfDecoderSpecs(),
|
||||
});
|
||||
|
||||
const pdfDecoderRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return pdfDecoderRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
* Python reference: trustgraph-flow/trustgraph/embeddings/ollama/processor.py
|
||||
*/
|
||||
|
||||
import { Config, Effect, Layer } from "effect";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { Config, Effect, Layer, ManagedRuntime } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
import {
|
||||
|
|
@ -154,6 +155,12 @@ export const program = makeFlowProcessorProgram<OllamaEmbeddingsConfig, never, E
|
|||
layer: (config) => OllamaEmbeddingsLive(config),
|
||||
});
|
||||
|
||||
const ollamaEmbeddingsRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return ollamaEmbeddingsRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import {
|
|||
type EffectRequestResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
|
|
@ -386,6 +387,12 @@ export const program = makeFlowProcessorProgram({
|
|||
specs: () => makeKnowledgeExtractSpecs(),
|
||||
});
|
||||
|
||||
const knowledgeExtractRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return knowledgeExtractRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
import Fastify, { type FastifyReply } from "fastify";
|
||||
import websocketPlugin from "@fastify/websocket";
|
||||
import { Clock, Config, Effect, Exit, Random, Scope } from "effect";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { Clock, Config, Effect, Exit, Layer, ManagedRuntime, Random, Scope } from "effect";
|
||||
import * as O from "effect/Option";
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
||||
import * as EffectSocket from "effect/unstable/socket/Socket";
|
||||
|
|
@ -258,7 +259,11 @@ function headersFrom(headers: Record<string, string | string[] | number | undefi
|
|||
}
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return gatewayRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
||||
export const loadGatewayConfig = Effect.fn("loadGatewayConfig")(function* () {
|
||||
|
|
@ -291,3 +296,5 @@ export const program = Effect.scoped(
|
|||
return yield* Effect.never;
|
||||
}),
|
||||
);
|
||||
|
||||
const gatewayRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
import { AzureOpenAI } from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -20,7 +21,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerStatusError,
|
||||
|
|
@ -229,6 +230,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const azureOpenAITextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return azureOpenAITextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import Anthropic from "@anthropic-ai/sdk";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -16,7 +17,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerStatusError,
|
||||
|
|
@ -209,6 +210,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const claudeTextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return claudeTextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Mistral } from "@mistralai/mistralai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -18,7 +19,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerStatusError,
|
||||
|
|
@ -208,6 +209,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const mistralTextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return mistralTextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Ollama } from "ollama";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -18,7 +19,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerRuntimeError,
|
||||
|
|
@ -187,6 +188,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const ollamaTextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return ollamaTextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
import OpenAI from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -21,7 +22,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerStatusError,
|
||||
|
|
@ -220,6 +221,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const openAICompatibleTextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return openAICompatibleTextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import OpenAI from "openai";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import {
|
||||
Llm,
|
||||
makeLlmService,
|
||||
|
|
@ -16,7 +17,7 @@ import {
|
|||
type LlmResult,
|
||||
type LlmChunk,
|
||||
} from "@trustgraph/base";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime, Stream } from "effect";
|
||||
import {
|
||||
optionalStringConfig,
|
||||
providerStatusError,
|
||||
|
|
@ -211,6 +212,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig, never, Llm>({
|
|||
),
|
||||
});
|
||||
|
||||
const openAITextCompletionRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return openAITextCompletionRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ import {
|
|||
type PromptResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import * as S from "effect/Schema";
|
||||
|
||||
export interface PromptTemplate {
|
||||
|
|
@ -195,6 +196,12 @@ export const program = makeFlowProcessorProgram({
|
|||
configHandlers: (config: PromptTemplateConfig) => promptTemplateRuntime(config).configHandlers,
|
||||
});
|
||||
|
||||
const promptRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return promptRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import {
|
|||
type DocumentEmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import {
|
||||
QdrantDocEmbeddingsQueryLive,
|
||||
QdrantDocEmbeddingsQueryService,
|
||||
|
|
@ -113,6 +114,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig & QdrantDocQuery
|
|||
layer: (config) => QdrantDocEmbeddingsQueryLive(config),
|
||||
});
|
||||
|
||||
const docEmbeddingsQueryRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return docEmbeddingsQueryRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import {
|
|||
type GraphEmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import {
|
||||
QdrantGraphEmbeddingsQueryLive,
|
||||
QdrantGraphEmbeddingsQueryService,
|
||||
|
|
@ -114,6 +115,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig & QdrantGraphQue
|
|||
layer: (config) => QdrantGraphEmbeddingsQueryLive(config),
|
||||
});
|
||||
|
||||
const graphEmbeddingsQueryRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return graphEmbeddingsQueryRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import {
|
|||
type TriplesQueryResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import {
|
||||
FalkorDBTriplesQueryLive,
|
||||
FalkorDBTriplesQueryService,
|
||||
|
|
@ -100,6 +101,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig & FalkorDBQueryC
|
|||
layer: (config) => FalkorDBTriplesQueryLive(config),
|
||||
});
|
||||
|
||||
const triplesQueryRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return triplesQueryRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ import {
|
|||
type EmbeddingsResponse,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import {
|
||||
QdrantGraphEmbeddingsStoreLive,
|
||||
QdrantGraphEmbeddingsStoreService,
|
||||
|
|
@ -119,6 +120,12 @@ export const program = makeFlowProcessorProgram<
|
|||
layer: (config) => QdrantGraphEmbeddingsStoreLive(config),
|
||||
});
|
||||
|
||||
const graphEmbeddingsStoreRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return graphEmbeddingsStoreRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ import {
|
|||
type Triples,
|
||||
type Spec,
|
||||
} from "@trustgraph/base";
|
||||
import { NodeRuntime } from "@effect/platform-node";
|
||||
import { makeFlowProcessorProgram } from "@trustgraph/base";
|
||||
import { Effect } from "effect";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
import {
|
||||
FalkorDBTriplesStoreLive,
|
||||
FalkorDBTriplesStoreService,
|
||||
|
|
@ -78,6 +79,12 @@ export const program = makeFlowProcessorProgram<ProcessorConfig & FalkorDBConfig
|
|||
layer: (config) => FalkorDBTriplesStoreLive(config),
|
||||
});
|
||||
|
||||
const triplesStoreRuntime = ManagedRuntime.make(Layer.empty);
|
||||
|
||||
export function run(): Promise<void> {
|
||||
return Effect.runPromise(program);
|
||||
return triplesStoreRuntime.runPromise(program);
|
||||
}
|
||||
|
||||
export function runMain(): void {
|
||||
NodeRuntime.runMain(program);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue