refactor[utils.ts]: Add type to functions that didnt have it
This commit is contained in:
parent
33ea356eba
commit
54f1f5c504
2 changed files with 223 additions and 10 deletions
|
|
@ -203,3 +203,215 @@ export type HeaderProps = { children: ReactNode; description: string };
|
||||||
export interface languageMap {
|
export interface languageMap {
|
||||||
[key: string]: string | undefined;
|
[key: string]: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type groupedObjType = {
|
||||||
|
component: string;
|
||||||
|
family: string;
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type dataObjType = {
|
||||||
|
base_classes: string[];
|
||||||
|
custom_fields: object;
|
||||||
|
description: string;
|
||||||
|
display_name: string;
|
||||||
|
documentation: string;
|
||||||
|
output_types: Array<void | string>;
|
||||||
|
template: object;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type documentloadersType = {
|
||||||
|
AZLyricsLoader: dataObjType;
|
||||||
|
AirbyteJSONLoader: dataObjType;
|
||||||
|
BSHTMLLoader: dataObjType;
|
||||||
|
CSVLoader: dataObjType;
|
||||||
|
CoNLLULoader: dataObjType;
|
||||||
|
CollegeConfidentialLoader: dataObjType;
|
||||||
|
DirectoryLoader: dataObjType;
|
||||||
|
EverNoteLoader: dataObjType;
|
||||||
|
FacebookChatLoader: dataObjType;
|
||||||
|
GitLoader: dataObjType;
|
||||||
|
GitbookLoader: dataObjType;
|
||||||
|
GutenbergLoader: dataObjType;
|
||||||
|
HNLoader: dataObjType;
|
||||||
|
IFixitLoader: dataObjType;
|
||||||
|
IMSDbLoader: dataObjType;
|
||||||
|
NotionDirectoryLoader: dataObjType;
|
||||||
|
PyPDFDirectoryLoader: dataObjType;
|
||||||
|
PyPDFLoader: dataObjType;
|
||||||
|
ReadTheDocsLoader: dataObjType;
|
||||||
|
SRTLoader: dataObjType;
|
||||||
|
SlackDirectoryLoader: dataObjType;
|
||||||
|
TextLoader: dataObjType;
|
||||||
|
UnstructuredEmailLoader: dataObjType;
|
||||||
|
UnstructuredHTMLLoader: dataObjType;
|
||||||
|
UnstructuredMarkdownLoader: dataObjType;
|
||||||
|
UnstructuredPowerPointLoader: dataObjType;
|
||||||
|
UnstructuredWordDocumentLoader: dataObjType;
|
||||||
|
WebBaseLoader: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type agentsType = {
|
||||||
|
AgentInitializer: dataObjType;
|
||||||
|
CSVAgent: dataObjType;
|
||||||
|
JsonAgent: dataObjType;
|
||||||
|
SQLAgent: dataObjType;
|
||||||
|
VectorStoreAgent: dataObjType;
|
||||||
|
VectorStoreRouterAgent: dataObjType;
|
||||||
|
ZeroShotAgent: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type chainsType = {
|
||||||
|
CombineDocsChain: dataObjType;
|
||||||
|
ConversationChain: dataObjType;
|
||||||
|
ConversationalRetrievalChain: dataObjType;
|
||||||
|
LLMChain: dataObjType;
|
||||||
|
LLMCheckerChain: dataObjType;
|
||||||
|
LLMMathChain: dataObjType;
|
||||||
|
MidJourneyPromptChain: dataObjType;
|
||||||
|
RetrievalQA: dataObjType
|
||||||
|
RetrievalQAWithSourcesChain: dataObjType;
|
||||||
|
SQLDatabaseChain: dataObjType;
|
||||||
|
SeriesCharacterChain: dataObjType;
|
||||||
|
TimeTravelGuideChain: dataObjType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type embeddingsType = {
|
||||||
|
CohereEmbeddings: dataObjType;
|
||||||
|
HuggingFaceEmbeddings: dataObjType;
|
||||||
|
OpenAIEmbeddings: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type llmsTypes = {
|
||||||
|
Anthropic: dataObjType;
|
||||||
|
CTransformers: dataObjType;
|
||||||
|
ChatAnthropic: dataObjType;
|
||||||
|
ChatOpenAI: dataObjType;
|
||||||
|
Cohere: dataObjType;
|
||||||
|
HuggingFaceHub: dataObjType;
|
||||||
|
LlamaCpp: dataObjType;
|
||||||
|
OpenAI: dataObjType;
|
||||||
|
VertexAI: dataObjType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type memoriesType = {
|
||||||
|
ConversationBufferMemory: dataObjType;
|
||||||
|
ConversationBufferWindowMemory: dataObjType;
|
||||||
|
ConversationEntityMemory: dataObjType;
|
||||||
|
ConversationKGMemory: dataObjType;
|
||||||
|
ConversationSummaryMemory: dataObjType;
|
||||||
|
MongoDBChatMessageHistory: dataObjType;
|
||||||
|
PostgresChatMessageHistory: dataObjType;
|
||||||
|
VectorStoreRetrieverMemory: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type outputParsersType = {
|
||||||
|
ResponseSchema: dataObjType;
|
||||||
|
StructuredOutputParser: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type promptsType = {
|
||||||
|
ChatMessagePromptTemplate: dataObjType;
|
||||||
|
ChatPromptTemplate: dataObjType;
|
||||||
|
HumanMessagePromptTemplate: dataObjType;
|
||||||
|
PromptTemplate: dataObjType;
|
||||||
|
SystemMessagePromptTemplate: dataObjType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type retrieversType = {
|
||||||
|
MultiQueryRetriever: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type textSplittersType = {
|
||||||
|
CharacterTextSplitter: dataObjType;
|
||||||
|
RecursiveCharacterTextSplitter: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type toolkitsType = {
|
||||||
|
JsonToolkit: dataObjType;
|
||||||
|
OpenAPIToolkit: dataObjType;
|
||||||
|
VectorStoreInfo: dataObjType;
|
||||||
|
VectorStoreRouterToolkit: dataObjType;
|
||||||
|
VectorStoreToolkit: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type toolsType = {
|
||||||
|
BingSearchRun: dataObjType;
|
||||||
|
Calculator: dataObjType;
|
||||||
|
GoogleSearchResults: dataObjType;
|
||||||
|
GoogleSearchRun: dataObjType;
|
||||||
|
GoogleSerperRun: dataObjType;
|
||||||
|
InfoSQLDatabaseTool: dataObjType;
|
||||||
|
JsonGetValueTool: dataObjType;
|
||||||
|
JsonListKeysTool: dataObjType;
|
||||||
|
JsonSpec: dataObjType;
|
||||||
|
ListSQLDatabaseTool: dataObjType;
|
||||||
|
"News API": dataObjType;
|
||||||
|
'PAL-MATH': dataObjType;
|
||||||
|
"Podcast API": dataObjType;
|
||||||
|
PythonAstREPLTool: dataObjType;
|
||||||
|
PythonFunction: dataObjType;
|
||||||
|
PythonFunctionTool: dataObjType;
|
||||||
|
PythonREPLTool: dataObjType;
|
||||||
|
QuerySQLDataBaseTool: dataObjType;
|
||||||
|
RequestsDeleteTool: dataObjType;
|
||||||
|
RequestsGetTool: dataObjType;
|
||||||
|
RequestsPatchTool: dataObjType;
|
||||||
|
RequestsPostTool: dataObjType;
|
||||||
|
RequestsPutTool: dataObjType;
|
||||||
|
Search: dataObjType;
|
||||||
|
'TMDB API': dataObjType;
|
||||||
|
Tool: dataObjType;
|
||||||
|
WikipediaQueryRun: dataObjType;
|
||||||
|
WolframAlphaQueryRun: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type utilitiesType = {
|
||||||
|
BingSearchAPIWrapper: dataObjType;
|
||||||
|
GoogleSearchAPIWrapper: dataObjType;
|
||||||
|
GoogleSerperAPIWrapper: dataObjType;
|
||||||
|
SearxSearchWrapper: dataObjType;
|
||||||
|
SerpAPIWrapper: dataObjType;
|
||||||
|
WikipediaAPIWrapper: dataObjType;
|
||||||
|
WolframAlphaAPIWrapper: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type vectorStoresType = {
|
||||||
|
Chroma: dataObjType;
|
||||||
|
FAISS: dataObjType;
|
||||||
|
MongoDBAtlasVectorSearch: dataObjType;
|
||||||
|
Pinecone: dataObjType;
|
||||||
|
Qdrant: dataObjType;
|
||||||
|
SupabaseVectorStore: dataObjType;
|
||||||
|
Weaviate: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type wrappersType = {
|
||||||
|
SQLDatabase: dataObjType;
|
||||||
|
TextRequestsWrapper: dataObjType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type dataType = {
|
||||||
|
agents?: agentsType;
|
||||||
|
chains?: chainsType;
|
||||||
|
documentloaders?: documentloadersType;
|
||||||
|
embeddings?: embeddingsType;
|
||||||
|
llms?: llmsTypes;
|
||||||
|
memories?: memoriesType;
|
||||||
|
output_parsers?: outputParsersType;
|
||||||
|
prompts?: promptsType;
|
||||||
|
retrievers?: retrieversType;
|
||||||
|
textsplitters?: textSplittersType;
|
||||||
|
toolkits?: toolkitsType;
|
||||||
|
tools?: toolsType
|
||||||
|
utilities?: utilitiesType;
|
||||||
|
vectorstores?: vectorStoresType;
|
||||||
|
wrappers?: wrappersType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type tweakType = {
|
||||||
|
"ChatOpenAI-TxuiN": object;
|
||||||
|
"LLMChain-zPC3w": object;
|
||||||
|
"PromptTemplate-iNj5W": object;
|
||||||
|
"ConversationBufferMemory-JnodM": object;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
import clsx, { ClassValue } from "clsx";
|
import clsx, { ClassValue } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants";
|
||||||
import { IVarHighlightType } from "../types/components";
|
import { IVarHighlightType, dataType, groupedObjType, tweakType } from "../types/components";
|
||||||
import { FlowType } from "../types/flow";
|
import { FlowType } from "../types/flow";
|
||||||
import { TabsState } from "../types/tabs";
|
import { TabsState } from "../types/tabs";
|
||||||
import { buildTweaks } from "./reactflowUtils";
|
import { buildTweaks } from "./reactflowUtils";
|
||||||
|
|
||||||
export function classNames(...classes: Array<string>) {
|
export function classNames(...classes: Array<string>): string {
|
||||||
return classes.filter(Boolean).join(" ");
|
return classes.filter(Boolean).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]): string {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toNormalCase(str: string) {
|
export function toNormalCase(str: string): string {
|
||||||
let result = str
|
let result = str
|
||||||
.split("_")
|
.split("_")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
|
@ -36,7 +36,7 @@ export function toNormalCase(str: string) {
|
||||||
.join(" ");
|
.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalCaseToSnakeCase(str: string) {
|
export function normalCaseToSnakeCase(str: string): string {
|
||||||
return str
|
return str
|
||||||
.split(" ")
|
.split(" ")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
|
@ -48,7 +48,7 @@ export function normalCaseToSnakeCase(str: string) {
|
||||||
.join("_");
|
.join("_");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toTitleCase(str: string) {
|
export function toTitleCase(str: string): string {
|
||||||
let result = str
|
let result = str
|
||||||
.split("_")
|
.split("_")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
|
|
@ -75,7 +75,7 @@ export function toTitleCase(str: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const upperCaseWords: string[] = ["llm", "uri"];
|
export const upperCaseWords: string[] = ["llm", "uri"];
|
||||||
export function checkUpperWords(str: string) {
|
export function checkUpperWords(str: string): string {
|
||||||
const words = str.split(" ").map((word) => {
|
const words = str.split(" ").map((word) => {
|
||||||
return upperCaseWords.includes(word.toLowerCase())
|
return upperCaseWords.includes(word.toLowerCase())
|
||||||
? word.toUpperCase()
|
? word.toUpperCase()
|
||||||
|
|
@ -85,7 +85,7 @@ export function checkUpperWords(str: string) {
|
||||||
return words.join(" ");
|
return words.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function groupByFamily(data, baseClasses, left, type) {
|
export function groupByFamily(data: dataType, baseClasses: string, left: boolean, type: string): groupedObjType[] {
|
||||||
let parentOutput: string;
|
let parentOutput: string;
|
||||||
let arrOfParent: string[] = [];
|
let arrOfParent: string[] = [];
|
||||||
let arrOfType: { family: string; type: string; component: string }[] = [];
|
let arrOfType: { family: string; type: string; component: string }[] = [];
|
||||||
|
|
@ -200,7 +200,7 @@ export function groupByFamily(data, baseClasses, left, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildInputs(tabsState, id) {
|
export function buildInputs(tabsState: object, id: string): string {
|
||||||
return tabsState &&
|
return tabsState &&
|
||||||
tabsState[id] &&
|
tabsState[id] &&
|
||||||
tabsState[id].formKeysData &&
|
tabsState[id].formKeysData &&
|
||||||
|
|
@ -261,7 +261,8 @@ export function varHighlightHTML({ name }: IVarHighlightType): string {
|
||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function buildTweakObject(tweak) {
|
export function buildTweakObject(tweak: tweakType[]): string {
|
||||||
|
console.log(tweak)
|
||||||
tweak.forEach((el) => {
|
tweak.forEach((el) => {
|
||||||
Object.keys(el).forEach((key) => {
|
Object.keys(el).forEach((key) => {
|
||||||
for (let kp in el[key]) {
|
for (let kp in el[key]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue