Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/app/packages/block-md/component/InstructionsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import {
type PeerIdValidator,
peerIdPlugin,
} from '@lexical-core';
import type { MarkdownRewriteOutput } from '@service-cognition/generated/tools/types';
import { debounce } from '@solid-primitives/scheduled';
import { createMethodRegistration } from 'core/orchestrator';
import type { EditorState } from 'lexical';
Expand All @@ -67,6 +66,7 @@ import {
Show,
} from 'solid-js';
import { blockDataSignal, mdStore } from '../signal/markdownBlockData';
import type { MarkdownRewriteOutput } from '../signal/rewriteSignal';
import { useBlockSave, useSaveMarkdownDocument } from '../signal/save';
import { MarkdownCollabProvider } from './MarkdownCollabProvider';

Expand Down
3 changes: 1 addition & 2 deletions js/app/packages/block-md/component/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ import {
type PeerIdValidator,
peerIdPlugin,
} from '@lexical-core';
import type { MarkdownRewriteOutput } from '@service-cognition/generated/tools/types';
import { waitBulkUploadStatus } from '@service-connection/bulkUpload';
import { fileExtension } from '@service-storage/util/filename';
import { createCallback } from '@solid-primitives/rootless';
Expand All @@ -159,7 +158,6 @@ import {
$isElementNode,
type EditorState,
} from 'lexical';

import {
type Accessor,
createEffect,
Expand All @@ -179,6 +177,7 @@ import {
isGeneratingSignal,
} from '../signal/generateSignal';
import { blockDataSignal, mdStore } from '../signal/markdownBlockData';
import type { MarkdownRewriteOutput } from '../signal/rewriteSignal';
import { useBlockSave, useSaveMarkdownDocument } from '../signal/save';
import { MarkdownCollabProvider } from './MarkdownCollabProvider';
import { MarkdownPopup } from './MarkdownPopup';
Expand Down
2 changes: 1 addition & 1 deletion js/app/packages/block-md/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { serializedStateFromBlob } from '@core/component/LexicalMarkdown/collabo
import { ENABLE_MARKDOWN_LIVE_COLLABORATION } from '@core/constant/featureFlags';
import { isErr, ok } from '@core/util/maybeResult';
import { type SchemaType, schema } from '@loro-mirror/packages/core/src';
import type { MarkdownRewriteOutput } from '@service-cognition/generated/tools/types';
import { storageServiceClient } from '@service-storage/client';
import { fetchBinary } from '@service-storage/util/fetchBinary';
import { makeFileFromBlob } from '@service-storage/util/makeFileFromBlob';
Expand All @@ -19,6 +18,7 @@ import { createSyncServiceSource } from '@service-sync/source';
import { untrack } from 'solid-js';
import { createStore } from 'solid-js/store';
import MarkdownBlock from './component/Block';
import type { MarkdownRewriteOutput } from './signal/rewriteSignal';

const nodeSchema = schema.LoroMap({
$: schema.LoroMap({} as any, {
Expand Down
7 changes: 6 additions & 1 deletion js/app/packages/block-md/signal/rewriteSignal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { createBlockSignal } from '@core/block';
import type { MarkdownRewriteOutput } from '@service-cognition/generated/tools/types';
import type { NamedTool } from '@service-cognition/generated/tools/tool';

export type MarkdownRewriteOutput = NamedTool<
'MarkdownRewrite',
'response'
>['data'];

export const rewriteSignal = createBlockSignal<boolean>(false);
export const isRewritingSignal = createBlockSignal<boolean>(false);
Expand Down
14 changes: 10 additions & 4 deletions js/app/packages/core/component/AI/component/debug/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function ToolCallResponseRender() {
{
type: 'toolCall',
tool: {
name: 'WebSearch',
name: 'web_search',
data: {
query: 'most important headlines today',
},
Expand All @@ -285,10 +285,16 @@ function ToolCallResponseRender() {
{
type: 'toolResponse',
tool: {
name: 'WebSearch',
name: 'web_search',
data: {
results: [{ name: 'news.com', url: 'www.news.com' }],
content: 'I read the results and there is news!!!',
content: [
{
type: 'web_search_result',
title: 'news.com',
url: 'www.news.com',
},
],
tool_use_id: 'I read the results and there is news!!!',
},
},
},
Expand Down
24 changes: 13 additions & 11 deletions js/app/packages/core/component/AI/component/debug/Tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function ToolCall() {
{
type: 'toolCall',
tool: {
name: 'WebSearch',
name: 'web_search',
data: {
query: 'Weather in nyc now',
},
Expand All @@ -48,7 +48,7 @@ function ToolResponse() {
{
type: 'toolCall',
tool: {
name: 'WebSearch',
name: 'web_search',
data: {
query: 'Weather in nyc now',
},
Expand All @@ -58,15 +58,16 @@ function ToolResponse() {
type: 'toolResponse',
tool: {
data: {
content: 'it is sunny',
results: [
tool_use_id: 'hehexd',
content: [
{
name: 'weather.com',
title: 'its sunny',
type: 'web_search_result',
url: 'https://weather.com',
},
],
},
name: 'WebSearch',
name: 'web_search',
},
},
{
Expand All @@ -90,7 +91,7 @@ function ToolResponsStreamEnd() {
{
type: 'toolCall',
tool: {
name: 'WebSearch',
name: 'web_search',
data: {
query: 'Weather in nyc now',
},
Expand All @@ -100,15 +101,16 @@ function ToolResponsStreamEnd() {
type: 'toolResponse',
tool: {
data: {
content: 'it is sunny',
results: [
tool_use_id: 'hehexd',
content: [
{
name: 'weather.com',
title: 'its sunny',
type: 'web_search_result',
url: 'https://weather.com',
},
],
},
name: 'WebSearch',
name: 'web_search',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { fileTypeToBlockName } from '@core/constant/allBlocks';
import ChevronDown from '@icon/regular/caret-down.svg?component-solid';
import ChevronUp from '@icon/regular/caret-up.svg?component-solid';
import List from '@phosphor-icons/core/regular/list.svg';
import type { ListDocumentsResult } from '@service-cognition/toolTypes';
import type { NamedTool } from '@service-cognition/generated/tools/tool';
import type { FileType } from '@service-storage/generated/schemas/fileType';
import { useSplitLayout } from 'app/component/split-layout/layout';
import { createMemo, createSignal, Show } from 'solid-js';
import { VList } from 'virtua/solid';
import { BaseTool } from './BaseTool';
import { createToolRenderer } from './ToolRenderer';

type ListDocumentsResult = NamedTool<
'ListDocuments',
'response'
>['data']['results'][number];

const ListDocumentsToolResponse = (props: {
results: ListDocumentsResult[];
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import { TruncatedText } from '@core/component/FileList/TruncatedText';
import ChevronDown from '@icon/regular/caret-down.svg?component-solid';
import ChevronUp from '@icon/regular/caret-up.svg?component-solid';
import List from '@phosphor-icons/core/regular/list.svg';
import type { ListEmailsResult } from '@service-cognition/toolTypes';
import type { NamedTool } from '@service-cognition/generated/tools/tool';
import { useSplitLayout } from 'app/component/split-layout/layout';
import { createMemo, createSignal, Show } from 'solid-js';
import { VList } from 'virtua/solid';
import { BaseTool } from './BaseTool';
import { createToolRenderer } from './ToolRenderer';

type ListEmailsResult = NamedTool<
'ListEmails',
'response'
>['data']['items'][number];

const ListEmailsToolResponse = (props: { results: ListEmailsResult[] }) => {
const [isExpanded, setIsExpanded] = createSignal(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { fileTypeToBlockName } from '@core/constant/allBlocks';
import ChevronDown from '@icon/regular/caret-down.svg?component-solid';
import ChevronUp from '@icon/regular/caret-up.svg?component-solid';
import MagnifyingGlass from '@phosphor-icons/core/regular/magnifying-glass.svg';
import type { UnifiedSearchResult } from '@service-cognition/toolTypes';
import type { NamedTool } from '@service-cognition/generated/tools/tool';
import type { FileType } from '@service-storage/generated/schemas/fileType';
import { useSplitLayout } from 'app/component/split-layout/layout';
import { createMemo, createSignal, Show } from 'solid-js';
import { VList } from 'virtua/solid';
import { BaseTool } from './BaseTool';
import { createToolRenderer } from './ToolRenderer';

type UnifiedSearchResult = NamedTool<
'UnifiedSearch',
'response'
>['data']['response']['results'][number];

const UnifiedSearchToolResponse = (props: {
results: UnifiedSearchResult[];
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BaseTool } from './BaseTool';
import { createToolRenderer } from './ToolRenderer';

const handler = createToolRenderer({
name: 'WebSearch',
name: 'web_search',
renderCall: (ctx) => (
<BaseTool
icon={Globe}
Expand All @@ -23,8 +23,8 @@ const handler = createToolRenderer({
type="response"
>
<UnfurledLinkCollection
links={ctx.tool.data.results.map((result) => ({
title: result.name,
links={ctx.tool.data.content.map((result) => ({
title: result.title,
url: result.url,
}))}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const [renderStore, setRenderStore] = createStore<

const toolHandlers: ToolHandlerMap<RenderContext> = {
UnifiedSearch: unifiedSearchHandler,
WebSearch: webSearchHandler,
web_search: webSearchHandler,
MarkdownRewrite: rewriteHandler,
Read: readHandler,
ListDocuments: listDocumentsHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
$getNodeById,
$isDiffNode,
} from '@lexical-core';
import type { MarkdownRewriteOutput } from '@service-cognition/generated/tools/types';
import type { NamedTool } from '@service-cognition/generated/tools/tool';
import { useUserId } from '@service-gql/client';
import type { LexicalEditor } from 'lexical';
import {
Expand All @@ -20,7 +20,7 @@ import {
import { createEffect } from 'solid-js';
import { mapRegisterDelete } from '../shared/utils';

type Diff = MarkdownRewriteOutput['diffs'][number];
type Diff = NamedTool<'MarkdownRewrite', 'response'>['data']['diffs'][number];

export type DiffPluginArgs = {
revisionsSignal: ReturnType<typeof createBlockSignal<Diff[] | undefined>>;
Expand Down
Loading