mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-12-02 17:58:14 +00:00
Refactor types and imports for consistency
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import { applyPatch } from 'rfc6902';
|
import { applyPatch } from 'rfc6902';
|
||||||
|
import { Block } from './types';
|
||||||
|
|
||||||
class SessionManager {
|
class SessionManager {
|
||||||
private static sessions = new Map<string, SessionManager>();
|
private static sessions = new Map<string, SessionManager>();
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
type ChatTurnMessage = {
|
export type ChatTurnMessage = {
|
||||||
role: 'user' | 'assistant' | 'system';
|
role: 'user' | 'assistant' | 'system';
|
||||||
content: string;
|
content: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Chunk = {
|
export type Chunk = {
|
||||||
content: string;
|
content: string;
|
||||||
metadata: Record<string, any>;
|
metadata: Record<string, any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type TextBlock = {
|
export type TextBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'text';
|
type: 'text';
|
||||||
data: string;
|
data: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SourceBlock = {
|
export type SourceBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'source';
|
type: 'source';
|
||||||
data: Chunk[];
|
data: Chunk[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type SuggestionBlock = {
|
export type SuggestionBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'suggestion';
|
type: 'suggestion';
|
||||||
data: string[];
|
data: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type WidgetBlock = {
|
export type WidgetBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'widget';
|
type: 'widget';
|
||||||
data: {
|
data: {
|
||||||
@@ -35,27 +35,30 @@ type WidgetBlock = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type ReasoningResearchBlock = {
|
export type ReasoningResearchBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
|
type: 'reasoning';
|
||||||
reasoning: string;
|
reasoning: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SearchingResearchBlock = {
|
export type SearchingResearchBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
|
type: 'searching';
|
||||||
searching: string[];
|
searching: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type ReadingResearchBlock = {
|
export type ReadingResearchBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
|
type: 'reading';
|
||||||
reading: Chunk[];
|
reading: Chunk[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type ResearchBlockSubStep =
|
export type ResearchBlockSubStep =
|
||||||
| ReasoningResearchBlock
|
| ReasoningResearchBlock
|
||||||
| SearchingResearchBlock
|
| SearchingResearchBlock
|
||||||
| ReadingResearchBlock;
|
| ReadingResearchBlock;
|
||||||
|
|
||||||
type ResearchBlock = {
|
export type ResearchBlock = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'research';
|
type: 'research';
|
||||||
data: {
|
data: {
|
||||||
@@ -63,7 +66,7 @@ type ResearchBlock = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type Block =
|
export type Block =
|
||||||
| TextBlock
|
| TextBlock
|
||||||
| SourceBlock
|
| SourceBlock
|
||||||
| SuggestionBlock
|
| SuggestionBlock
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
const formatChatHistoryAsString = (history: Message[]) => {
|
import { ChatTurnMessage } from '../types';
|
||||||
|
|
||||||
|
const formatChatHistoryAsString = (history: ChatTurnMessage[]) => {
|
||||||
return history
|
return history
|
||||||
.map(
|
.map(
|
||||||
(message) =>
|
(message) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user