Skip to content

Commit

Permalink
Merge branch 'llm'
Browse files Browse the repository at this point in the history
  • Loading branch information
noob9527 committed Jul 23, 2024
2 parents c56a4dd + 521c32b commit fb1fd8a
Show file tree
Hide file tree
Showing 81 changed files with 4,731 additions and 319 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
4 changes: 3 additions & 1 deletion config/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const common = {
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
// somehow I need to comment this line out
// to make gemini-llm-service-impl.test.ts work
// "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
Expand Down
3 changes: 2 additions & 1 deletion doc/notes/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
- overview page
- add a progress bar for sync items process.
- builtin dictionary?
- vocabulary quiz?
- vocabulary quiz
- show choice's meaning?
- anki?
- alfred API?
- global sync window?
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noob-dict-desktop",
"version": "0.0.9",
"version": "0.0.10",
"description": "A dictionary aim to help myself learning English",
"private": true,
"main": "build/main.js",
Expand Down Expand Up @@ -49,6 +49,10 @@
"@babel/core": "^7.9.0",
"@electron/remote": "^2.0.8",
"@jest-runner/electron": "^3.0.1",
"@langchain/community": "^0.0.56",
"@langchain/core": "^0.1.62",
"@langchain/google-genai": "^0.0.12",
"@langchain/openai": "^0.0.28",
"@noob9527/noob-dict-core": "^1.0.0",
"@noob9527/noob-dict-ecdict": "^0.0.2",
"@noob9527/noob-dict-net-engines": "^0.0.3",
Expand All @@ -67,6 +71,7 @@
"axios": "^0.19.2",
"babel-jest": "^24.7.1",
"babel-preset-react-app": "^9.0.0",
"best-effort-json-parser": "^1.1.0",
"bizcharts": "^3.5.5",
"camelcase": "^5.2.0",
"color": "^3.1.2",
Expand All @@ -82,20 +87,24 @@
"electron-log": "^5.0.3",
"electron-store": "^8.0.2",
"electron-updater": "^5.0.5",
"franc-min": "^6.2.0",
"history": "^4.10.1",
"identity-obj-proxy": "3.0.0",
"immer": "^10.1.1",
"inversify": "^5.0.1",
"jest": "^24.7.1",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.7.1",
"jest-watch-typeahead": "0.3.0",
"langchain": "^0.1.37",
"moment": "^2.24.0",
"node-machine-id": "^1.1.12",
"prettier": "3.1.1",
"react": "^16.10.1",
"react-app-polyfill": "^1.0.1",
"react-dom": "^16.10.1",
"react-highlight-words": "^0.18.0",
"react-markdown": "^9.0.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.2",
"react-scrollbar": "^0.5.6",
Expand Down
3 changes: 3 additions & 0 deletions src/browser/components/themed-ui/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const ThemedButton = styled(Button)`
color: ${props => props.theme[ColorId.button_foreground]};
background-color: ${props => props.theme[ColorId.button_hoverBackground]};
}
&[disabled] {
background-color: ${props => props.theme[ColorId.button_disabledBackground]};
}
}
`;

Expand Down
12 changes: 12 additions & 0 deletions src/browser/components/themed-ui/content/scroll-area.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styled from 'styled-components'
import ScrollArea from 'react-scrollbar'

export const ThemedScrollArea = styled(ScrollArea)`
&.scrollarea {
height: 100%;
.scrollbar {
background-color: white !important;
}
}
`
52 changes: 52 additions & 0 deletions src/browser/components/themed-ui/input/textarea2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import styled from 'styled-components';
import ColorId from '../../../styles/ColorId';

/**
* without antd dep
*/
const ThemedTextArea2 = styled.textarea`
color: ${props => props.theme[ColorId.input_foreground]};
background-color: ${props => props.theme[ColorId.input_background]};
border: 0;
border-radius: 0;
padding: 4px 11px;
&:focus, &:focus-visible {
border: 0;
box-shadow: none;
outline: none;
}
&::-webkit-scrollbar {
position: absolute;
width: 6px;
}
&::-webkit-scrollbar-track {
}
&::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: none;
transition: all .4s;
&:hover{
background: grey;
opacity: .6 !important;
}
&.active{
background: gray;
opacity: .6 !important;
}
}
&::-webkit-scrollbar-corner {
}
&::-webkit-resizer {
//display: none;
}
`;

export {
ThemedTextArea2,
};
77 changes: 77 additions & 0 deletions src/browser/components/themed-ui/menu/side-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Menu } from 'antd';
import styled from 'styled-components';
import ColorId from '../../../styles/ColorId';


const SideMenu = styled(Menu)`
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
color: ${props => props.theme[ColorId.tab_inactiveForeground]};
&.ant-menu-vertical, &.ant-menu-inline {
border: none;
}
`

const SideMenuItem = styled(SideMenu.Item)`
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
&:active {
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
}
> a {
color: ${props => props.theme[ColorId.tab_inactiveForeground]};
&:hover {
color: ${props => props.theme[ColorId.tab_activeForeground]}
}
}
&.ant-menu-item-selected {
> a, > a:hover {
color: ${props => props.theme[ColorId.tab_activeForeground]};
}
&:after {
border-right: 3px solid ${props => props.theme[ColorId.tab_activeForeground]};
//border-right: none;
}
}
.ant-menu:not(.ant-menu-horizontal) &.ant-menu-item-selected {
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
}
`

const SideSubMenu = styled(SideMenu.SubMenu)`
> .ant-menu {
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
}
.ant-menu-submenu-title {
color: ${props => props.theme[ColorId.tab_inactiveForeground]};
&:active {
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
}
}
.ant-menu-submenu-title:hover {
color: ${props => props.theme[ColorId.tab_activeForeground]};
}
&.ant-menu-submenu-inline > .ant-menu-submenu-title:hover .ant-menu-submenu-arrow {
&::before {
background: ${props => props.theme[ColorId.tab_activeForeground]};
}
&::after {
background: ${props => props.theme[ColorId.tab_activeForeground]};
}
}
&.ant-menu-submenu-selected {
color: ${props => props.theme[ColorId.tab_activeForeground]};
}
`

export {
SideMenu,
SideSubMenu,
SideMenuItem,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'
import { LLMProvider } from '../../../../common/services/llm/provider'
import { ThemedSelect } from './select'

export interface LLMProviderSelectorProps {
value: LLMProvider.Constant | null
availableProviders: LLMProvider.Constant[]
onSelect?: (provider: LLMProvider.Constant) => void
className?: string
}

export const LLMProviderSelector: React.FC<LLMProviderSelectorProps> = (
props: LLMProviderSelectorProps,
) => {
const { onSelect, value, availableProviders } = props
const providers = availableProviders.map((e) => LLMProvider.of(e))

return (
<ThemedSelect
className={props.className}
size={'small'}
placeholder="Service Provider"
value={value}
optionLabelProp="label"
onChange={(value) => {
onSelect?.(value as LLMProvider.Constant)
}}
>
{providers.map((e) => {
return (
<ThemedSelect.Option key={e.name} label={e.label}>
{e.label}
</ThemedSelect.Option>
)
})}
</ThemedSelect>
)
}
68 changes: 68 additions & 0 deletions src/browser/components/themed-ui/selector/select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Select } from 'antd'
import styled, { createGlobalStyle } from 'styled-components';
import ColorId from '../../../styles/ColorId';

export const GlobalSelectStyles = createGlobalStyle`
.ant-select-dropdown {
border-radius: 0;
color: ${props => props.theme[ColorId.input_foreground]};
background-color: ${props => props.theme[ColorId.input_background]};
}
.ant-select-dropdown-menu-item {
border-radius: 0;
background-color: #3C3C3C;
color: #F0F0F0;
&:hover:not(&-disabled) {
background-color: rebeccapurple;
}
&-selected {
background-color: rebeccapurple;
}
&-active {
background-color: rebeccapurple;
&:not(&-disabled) {
background-color: rebeccapurple;
}
}
}
`;

export const ThemedSelect = styled(Select)`
// &.ant-select-focused {
// .ant-select-selection {
// border-color: ${props => props.theme[ColorId.input_border]};
// &:hover {
// border-color: ${props => props.theme[ColorId.input_border]};
// }
// &:focus {
// border-color: ${props => props.theme[ColorId.input_border]};
// }
// }
// }
.ant-select-selection {
color: ${props => props.theme[ColorId.input_foreground]};
background-color: ${props => props.theme[ColorId.input_background]};
border-radius: 0;
//border-color: unset;
border-color: ${props => props.theme[ColorId.input_border]};
&:focus {
//border-color: unset;
border-color: ${props => props.theme[ColorId.input_border]};
box-shadow: none;
}
&:hover {
//border-color: unset;
border-color: ${props => props.theme[ColorId.input_border]};
}
.ant-select-arrow {
color: ${props => props.theme[ColorId.input_foreground]};
}
}
`

54 changes: 54 additions & 0 deletions src/browser/components/themed-ui/tabs/router-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import styled from 'styled-components'
import ColorId from '../../../styles/ColorId'
import React from 'react'
import { Link } from 'react-router-dom'

export const RouterMenu = styled.ul`
background-color: ${(props) => props.theme[ColorId.tab_inactiveBackground]};
color: ${(props) => props.theme[ColorId.tab_inactiveForeground]};
margin: 0;
padding: 0;
`

const MenuItemContainer = styled.li`
display: inline-block;
//border-bottom: none;
//position: relative;
//list-style: none;
//cursor: pointer;
color:${props => props.theme[ColorId.tab_inactiveForeground]};
background-color: ${props => props.theme[ColorId.tab_inactiveBackground]};
&.active {
color:${props => props.theme[ColorId.tab_activeForeground]};
background-color: ${props => props.theme[ColorId.tab_activeBackground]};
}
a {
display: inline-block;
text-align: center;
padding: 6px 12px;
width: 8em;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
color: unset;
transition: none;
}
a:hover {
color: unset;
}
`

export const RouterMenuItem: React.FC<any> = (props) => {
let { active, onClick, to, className, children } = props
className += active ? ' active' : ''
return (
<MenuItemContainer className={className} onClick={onClick}>
<Link tabIndex={-1} to={to}>
{children}
</Link>
</MenuItemContainer>
)
}
Loading

0 comments on commit fb1fd8a

Please sign in to comment.