mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
Use Match for workbench dispatch
This commit is contained in:
parent
dfc79bb050
commit
e46fc64275
3 changed files with 44 additions and 27 deletions
|
|
@ -2,7 +2,7 @@ import { Clipboard as BrowserClipboard } from "@effect/platform-browser";
|
|||
import * as BrowserHttpClient from "@effect/platform-browser/BrowserHttpClient";
|
||||
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
||||
import { BaseApi, type ConnectionState, type DocumentMetadata, type ExplainEvent, type StreamingMetadata, type Term, type Triple } from "@trustgraph/client";
|
||||
import { Cause, Clock, Context, Effect, Layer, Metric, Option, Random, Schema as S } from "effect";
|
||||
import { Cause, Clock, Context, Effect, Layer, Match, Metric, Option, Random, Schema as S } from "effect";
|
||||
import * as Otlp from "effect/unstable/observability/Otlp";
|
||||
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
||||
import * as Atom from "effect/unstable/reactivity/Atom";
|
||||
|
|
@ -1576,14 +1576,14 @@ export const submitMessageAtom = commandAtom<{ input: string }, void>(
|
|||
explainEvents.push(event);
|
||||
};
|
||||
|
||||
switch (chatMode) {
|
||||
case "graph-rag":
|
||||
Match.value(chatMode).pipe(
|
||||
Match.when("graph-rag", () => {
|
||||
flow.graphRagStreaming(trimmed, onChunk, onError, undefined, collection, onExplain);
|
||||
break;
|
||||
case "document-rag":
|
||||
}),
|
||||
Match.when("document-rag", () => {
|
||||
flow.documentRagStreaming(trimmed, onChunk, onError, undefined, collection, onExplain);
|
||||
break;
|
||||
case "agent":
|
||||
}),
|
||||
Match.when("agent", () => {
|
||||
flow.agent(
|
||||
trimmed,
|
||||
(chunk, complete) => {
|
||||
|
|
@ -1633,8 +1633,9 @@ export const submitMessageAtom = commandAtom<{ input: string }, void>(
|
|||
onExplain,
|
||||
collection,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}),
|
||||
Match.exhaustive,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { makeBaseApiWithRpc, type BaseApi, type DocumentMetadata, type ProcessingMetadata, type StreamingMetadata, type Triple } from "@trustgraph/client";
|
||||
import { Clock, Effect, Option, Schema as S } from "effect";
|
||||
import { Clock, Effect, Match, Option, Schema as S } from "effect";
|
||||
|
||||
type ConfigValues = Record<string, Record<string, unknown>>;
|
||||
|
||||
|
|
@ -284,22 +284,15 @@ function addDocument(state: MockState, metadata: DocumentMetadata): DocumentMeta
|
|||
}
|
||||
|
||||
function dispatchRequest(state: MockState, service: string, request: Record<string, unknown>, flow: string | undefined): unknown {
|
||||
switch (service) {
|
||||
case "flow":
|
||||
return dispatchFlow(state, request);
|
||||
case "config":
|
||||
return dispatchConfig(state, request);
|
||||
case "librarian":
|
||||
return dispatchLibrarian(state, request);
|
||||
case "knowledge":
|
||||
return dispatchKnowledge(state, request);
|
||||
case "collection-management":
|
||||
return dispatchCollections(state, request);
|
||||
case "triples":
|
||||
return dispatchTriples(state, request, flow);
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return Match.value(service).pipe(
|
||||
Match.when("flow", () => dispatchFlow(state, request)),
|
||||
Match.when("config", () => dispatchConfig(state, request)),
|
||||
Match.when("librarian", () => dispatchLibrarian(state, request)),
|
||||
Match.when("knowledge", () => dispatchKnowledge(state, request)),
|
||||
Match.when("collection-management", () => dispatchCollections(state, request)),
|
||||
Match.when("triples", () => dispatchTriples(state, request, flow)),
|
||||
Match.orElse(() => ({})),
|
||||
);
|
||||
}
|
||||
|
||||
function dispatchFlow(state: MockState, request: Record<string, unknown>): unknown {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue