diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/History.ts | 21 | ||||
-rw-r--r-- | src/client/views/nodes/chatbot/types/types.ts | 6 |
2 files changed, 10 insertions, 17 deletions
diff --git a/src/client/util/History.ts b/src/client/util/History.ts index 0d0c056a4..cf156014d 100644 --- a/src/client/util/History.ts +++ b/src/client/util/History.ts @@ -1,10 +1,7 @@ /* eslint-disable no-use-before-define */ /* eslint-disable no-empty */ -/* eslint-disable no-continue */ -/* eslint-disable guard-for-in */ -/* eslint-disable no-restricted-syntax */ /* eslint-disable no-param-reassign */ -import * as qs from 'query-string'; +import queryString from 'query-string'; import { Doc } from '../../fields/Doc'; import { OmitKeys, ClientUtils } from '../../ClientUtils'; import { DocServer } from '../DocServer'; @@ -82,7 +79,7 @@ export namespace HistoryUtil { // } // } - const parsers: { [type: string]: (pathname: string[], opts: qs.ParsedQuery) => ParsedUrl | undefined } = {}; + const parsers: { [type: string]: (pathname: string[], opts: queryString.ParsedQuery) => ParsedUrl | undefined } = {}; const stringifiers: { [type: string]: (state: ParsedUrl) => string } = {}; type ParserValue = true | 'none' | 'json' | ((value: string) => string | null | (string | null)[]); @@ -91,8 +88,8 @@ export namespace HistoryUtil { [key: string]: ParserValue; }; - function addParser(type: string, requiredFields: Parser, optionalFields: Parser, customParser?: (pathname: string[], opts: qs.ParsedQuery, current: ParsedUrl) => ParsedUrl | null | undefined) { - function parse(parser: ParserValue, value: string | (string | null)[] | null | undefined) { + function addParser(type: string, requiredFields: Parser, optionalFields: Parser, customParser?: (pathname: string[], opts: queryString.ParsedQuery, current: ParsedUrl) => ParsedUrl | null | undefined) { + function parseValue(parser: ParserValue, value: string | (string | null)[] | null | undefined) { if (value === undefined || value === null) { return value; } @@ -112,7 +109,7 @@ export namespace HistoryUtil { return undefined; } const parser = requiredFields[required]; - const value = parse(parser, opts[required]); + const value = parseValue(parser, opts[required]); if (value !== null && value !== undefined) { current[required] = value; } @@ -122,7 +119,7 @@ export namespace HistoryUtil { continue; } const parser = optionalFields[opt]; - const value = parse(parser, opts[opt]); + const value = parseValue(parser, opts[opt]); if (value !== undefined) { current[opt] = value; } @@ -152,8 +149,8 @@ export namespace HistoryUtil { Object.keys(queryObj).forEach(key => { query[key] = queryObj[key] === null ? null : JSON.stringify(queryObj[key]); }); - const queryString = qs.stringify(query); - return path + (queryString ? `?${queryString}` : ''); + const qstr = queryString.stringify(query); + return path + (queryString ? `?${qstr}` : ''); }; } @@ -170,7 +167,7 @@ export namespace HistoryUtil { export function parseUrl(location: Location | URL): ParsedUrl | undefined { const pathname = location.pathname.substring(1); const { search } = location; - const opts = search.length ? qs.parse(search, { sort: false }) : {}; + const opts = search.length ? queryString.parse(search, { sort: false }) : {}; const pathnameSplit = pathname.split('/'); const type = pathnameSplit[0]; diff --git a/src/client/views/nodes/chatbot/types/types.ts b/src/client/views/nodes/chatbot/types/types.ts index 995ac531d..882e74ebb 100644 --- a/src/client/views/nodes/chatbot/types/types.ts +++ b/src/client/views/nodes/chatbot/types/types.ts @@ -1,6 +1,3 @@ -import { indexes } from 'd3'; -import { AnyLayer } from 'react-map-gl'; - export enum ASSISTANT_ROLE { USER = 'user', ASSISTANT = 'assistant', @@ -122,9 +119,8 @@ export interface AI_Document { type: string; } +export type Observation = { type: 'text'; text: string } | { type: 'image_url'; image_url: { url: string } }; export interface AgentMessage { role: 'system' | 'user' | 'assistant'; content: string | Observation[]; } - -export type Observation = { type: 'text'; text: string } | { type: 'image_url'; image_url: { url: string } }; |