Thanks to visit codestin.com
Credit goes to github.com

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
24 changes: 22 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"@typescript-eslint",
"react",
"react-hooks",
"prettier"
"prettier",
"import"
],
"extends": [
"eslint:recommended",
Expand All @@ -16,7 +17,26 @@
],
"ignorePatterns": [],
"rules": {
"react/react-in-jsx-scope": "off"
"react/react-in-jsx-scope": "off",
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
"pathGroups": [
{
"pattern": "react",
"group": "external",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["builtin"],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"newlines-between": "always"
}
]
},
"settings": {
"react": {
Expand Down
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"css-loader": "^6.8.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
29 changes: 16 additions & 13 deletions src/components/ChatBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { ChangeEvent, useEffect, useRef, useState } from "react";

import {
Avatar,
ChatContainer,
Message,
MessageList,
TypingIndicator,
} from "@chatscope/chat-ui-kit-react";
import HistoryIcon from "@mui/icons-material/History";
import InfoIcon from "@mui/icons-material/Info";
import SaveAltIcon from "@mui/icons-material/SaveAlt";
import {
Alert,
Box,
Expand All @@ -13,18 +24,11 @@ import {
Tooltip,
Typography,
} from "@mui/material";
import HistoryIcon from "@mui/icons-material/History";
import InfoIcon from "@mui/icons-material/Info";
import SaveAltIcon from "@mui/icons-material/SaveAlt";
import {
Avatar,
ChatContainer,
Message,
MessageList,
TypingIndicator,
} from "@chatscope/chat-ui-kit-react";
import Markdown from "markdown-to-jsx";
import { v4 as uuidv4 } from "uuid";

import { getContentConfig } from "../contentConfig";
import { useThemeContext } from "../contexts/ThemeContext";
import {
CHAT_CONTAINER_HEIGHT_MAX,
CHAT_CONTAINER_HEIGHT_MIN,
Expand All @@ -33,12 +37,11 @@ import {
getLumosOptions,
} from "../pages/Options";
import { getHtmlContent } from "../scripts/content";
import { getContentConfig } from "../contentConfig";
import { CodeBlock, PreBlock } from "./CodeBlock";

import ChatHistory from "./ChatHistory";
import { CodeBlock, PreBlock } from "./CodeBlock";
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
import "./ChatBar.css";
import { useThemeContext } from "../contexts/ThemeContext";

export class LumosMessage {
constructor(
Expand Down
5 changes: 3 additions & 2 deletions src/components/ChatHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import PropTypes from "prop-types";

import DeleteIcon from "@mui/icons-material/Delete";
import {
Box,
IconButton,
Expand All @@ -9,7 +10,7 @@ import {
ListItemText,
ListSubheader,
} from "@mui/material";
import DeleteIcon from "@mui/icons-material/Delete";
import PropTypes from "prop-types";

interface ChatHistoryProps {
loadChat: (chatId: string) => void;
Expand Down
2 changes: 2 additions & 0 deletions src/contexts/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { createContext, useContext, useState, useEffect } from "react";

import { Theme, ThemeProvider as MUIThemeProvider } from "@mui/material";

import getAppTheme from "../themes/AppTheme";

interface ThemeContextValue {
Expand Down
6 changes: 4 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from "react";
import ReactDOM from "react-dom/client";

import CssBaseline from "@mui/material/CssBaseline";
import { ThemeProvider } from "./contexts/ThemeContext";
import ReactDOM from "react-dom/client";

import App from "./App";
import { ThemeProvider } from "./contexts/ThemeContext";

const root = document.createElement("div");
root.className = "container";
Expand Down
4 changes: 3 additions & 1 deletion src/options.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";

import CssBaseline from "@mui/material/CssBaseline";
import ReactDOM from "react-dom/client";

import { ThemeProvider } from "./contexts/ThemeContext";
import CssBaseline from "@mui/material/CssBaseline";
import Options from "./pages/Options";

const root = document.createElement("div");
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeEvent, useEffect, useState } from "react";

import {
Box,
FormControl,
Expand All @@ -12,6 +13,7 @@ import {
TextField,
ThemeProvider,
} from "@mui/material";

import {
ContentConfig,
defaultContentConfig,
Expand Down
19 changes: 10 additions & 9 deletions src/scripts/background.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { ChatOllama } from "@langchain/community/chat_models/ollama";
import { OllamaEmbeddings } from "@langchain/community/embeddings/ollama";
import { Ollama } from "@langchain/community/llms/ollama";
import { Document } from "@langchain/core/documents";
import {
AIMessage,
Expand All @@ -15,22 +18,20 @@ import { ConsoleCallbackHandler } from "@langchain/core/tracers/console";
import { IterableReadableStream } from "@langchain/core/utils/stream";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { formatDocumentsAsString } from "langchain/util/document";
import { ChatOllama } from "@langchain/community/chat_models/ollama";
import { OllamaEmbeddings } from "@langchain/community/embeddings/ollama";
import { Ollama } from "@langchain/community/llms/ollama";

import { LumosMessage } from "../components/ChatBar";
import {
Calculator,
CLS_CALC_PROMPT,
CLS_CALC_TYPE,
} from "../tools/calculator";
import { EnhancedMemoryVectorStore } from "../vectorstores/enhanced_memory";
import {
DEFAULT_KEEP_ALIVE,
getLumosOptions,
isMultimodal,
LumosOptions,
} from "../pages/Options";
import {
Calculator,
CLS_CALC_PROMPT,
CLS_CALC_TYPE,
} from "../tools/calculator";
import { EnhancedMemoryVectorStore } from "../vectorstores/enhanced_memory";

interface VectorStoreMetadata {
vectorStore: EnhancedMemoryVectorStore;
Expand Down
2 changes: 1 addition & 1 deletion src/themes/AppTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTheme, Theme } from "@mui/material/styles";
import { amber, lightGreen } from "@mui/material/colors";
import { createTheme, Theme } from "@mui/material/styles";

const getAppTheme = (darkMode: boolean): Theme => {
return createTheme({
Expand Down
2 changes: 1 addition & 1 deletion src/vectorstores/enhanced_memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
BaseRetriever,
type BaseRetrieverInput,
} from "@langchain/core/retrievers";
import { MemoryVectorStore } from "langchain/vectorstores/memory";
import Fuse from "fuse.js";
import { MemoryVectorStore } from "langchain/vectorstores/memory";

export type EnhancedMemoryRetrieverInput<V extends EnhancedMemoryVectorStore> =
BaseRetrieverInput &
Expand Down