Skip to content

Commit

Permalink
Merge branch 'dev' into devdocs_updates_chat_completions
Browse files Browse the repository at this point in the history
  • Loading branch information
avb-is-me authored Feb 27, 2024
2 parents a971766 + a4d1317 commit 3c0ef12
Show file tree
Hide file tree
Showing 65 changed files with 363 additions and 397 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,31 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
<tr style="text-align:center">
<td style="text-align:center"><b>Experimental (Nightly Build)</b></td>
<td style="text-align:center">
<a href='https://delta.jan.ai/latest/jan-win-x64-0.4.7-289.exe'>
<a href='https://delta.jan.ai/latest/jan-win-x64-0.4.7-290.exe'>
<img src='./docs/static/img/windows.png' style="height:14px; width: 14px" />
<b>jan.exe</b>
</a>
</td>
<td style="text-align:center">
<a href='https://delta.jan.ai/latest/jan-mac-x64-0.4.7-289.dmg'>
<a href='https://delta.jan.ai/latest/jan-mac-x64-0.4.7-290.dmg'>
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
<b>Intel</b>
</a>
</td>
<td style="text-align:center">
<a href='https://delta.jan.ai/latest/jan-mac-arm64-0.4.7-289.dmg'>
<a href='https://delta.jan.ai/latest/jan-mac-arm64-0.4.7-290.dmg'>
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
<b>M1/M2</b>
</a>
</td>
<td style="text-align:center">
<a href='https://delta.jan.ai/latest/jan-linux-amd64-0.4.7-289.deb'>
<a href='https://delta.jan.ai/latest/jan-linux-amd64-0.4.7-290.deb'>
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
<b>jan.deb</b>
</a>
</td>
<td style="text-align:center">
<a href='https://delta.jan.ai/latest/jan-linux-x86_64-0.4.7-289.AppImage'>
<a href='https://delta.jan.ai/latest/jan-linux-x86_64-0.4.7-290.AppImage'>
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
<b>jan.AppImage</b>
</a>
Expand Down
2 changes: 1 addition & 1 deletion core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export enum DownloadEvent {

export enum LocalImportModelEvent {
onLocalImportModelUpdate = 'onLocalImportModelUpdate',
onLocalImportModelError = 'onLocalImportModelError',
onLocalImportModelFailed = 'onLocalImportModelFailed',
onLocalImportModelSuccess = 'onLocalImportModelSuccess',
onLocalImportModelFinished = 'onLocalImportModelFinished',
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const joinPath: (paths: string[]) => Promise<string> = (paths) => global.core.ap
* @param path - The path to retrieve.
* @returns {Promise<string>} A promise that resolves with the basename.
*/
const baseName: (paths: string[]) => Promise<string> = (path) => global.core.api?.baseName(path)
const baseName: (paths: string) => Promise<string> = (path) => global.core.api?.baseName(path)

/**
* Opens an external URL in the default web browser.
Expand Down
1 change: 1 addition & 0 deletions core/src/types/model/modelImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type ImportingModel = {
status: ImportingModelStatus
format: string
percentage?: number
error?: string
}
28 changes: 18 additions & 10 deletions extensions/model-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
OptionType,
ImportingModel,
LocalImportModelEvent,
baseName,
} from '@janhq/core'

import { extractFileName } from './helpers/path'
Expand Down Expand Up @@ -488,7 +489,7 @@ export default class JanModelExtension extends ModelExtension {
return
}

const binaryFileName = extractFileName(modelBinaryPath, '')
const binaryFileName = await baseName(modelBinaryPath)

const model: Model = {
...defaultModel,
Expand Down Expand Up @@ -555,7 +556,7 @@ export default class JanModelExtension extends ModelExtension {
model: ImportingModel,
optionType: OptionType
): Promise<Model> {
const binaryName = extractFileName(model.path, '').replace(/\s/g, '')
const binaryName = (await baseName(model.path)).replace(/\s/g, '')

let modelFolderName = binaryName
if (binaryName.endsWith(JanModelExtension._supportedModelFormat)) {
Expand All @@ -568,7 +569,7 @@ export default class JanModelExtension extends ModelExtension {
const modelFolderPath = await this.getModelFolderName(modelFolderName)
await fs.mkdirSync(modelFolderPath)

const uniqueFolderName = modelFolderPath.split('/').pop()
const uniqueFolderName = await baseName(modelFolderPath)
const modelBinaryFile = binaryName.endsWith(
JanModelExtension._supportedModelFormat
)
Expand Down Expand Up @@ -637,14 +638,21 @@ export default class JanModelExtension extends ModelExtension {

for (const model of models) {
events.emit(LocalImportModelEvent.onLocalImportModelUpdate, model)
const importedModel = await this.importModel(model, optionType)

events.emit(LocalImportModelEvent.onLocalImportModelSuccess, {
...model,
modelId: importedModel.id,
})
importedModels.push(importedModel)
try {
const importedModel = await this.importModel(model, optionType)
events.emit(LocalImportModelEvent.onLocalImportModelSuccess, {
...model,
modelId: importedModel.id,
})
importedModels.push(importedModel)
} catch (err) {
events.emit(LocalImportModelEvent.onLocalImportModelFailed, {
...model,
error: err,
})
}
}

events.emit(
LocalImportModelEvent.onLocalImportModelFinished,
importedModels
Expand Down
8 changes: 4 additions & 4 deletions uikit/src/button/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
@apply disabled:pointer-events-none disabled:bg-zinc-100 disabled:text-zinc-400;

&-primary {
@apply bg-primary hover:bg-primary/90 text-white;
@apply bg-blue-600 text-white hover:bg-blue-600/90;
}

&-secondary-blue {
@apply bg-blue-200 text-blue-600 hover:bg-blue-300/50 dark:hover:bg-blue-200/80;
@apply bg-blue-200 text-blue-600 hover:bg-blue-300/50;
}

&-danger {
@apply bg-danger text-danger-foreground hover:bg-danger/90;
}

&-secondary-danger {
@apply bg-red-200 text-red-600 hover:bg-red-300/50 dark:hover:bg-red-200/80;
@apply bg-red-200 text-red-600 hover:bg-red-300/50;
}

&-outline {
Expand Down Expand Up @@ -66,7 +66,7 @@
[type='reset'],
[type='submit'] {
&.btn-primary {
@apply bg-primary hover:bg-primary/90;
@apply bg-blue-600 hover:bg-blue-600/90;
@apply disabled:pointer-events-none disabled:bg-zinc-100 disabled:text-zinc-400;
}
&.btn-secondary {
Expand Down
2 changes: 1 addition & 1 deletion uikit/src/checkbox/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.checkbox {
@apply border-border data-[state=checked]:bg-primary h-5 w-5 flex-shrink-0 rounded-md border data-[state=checked]:text-white;
@apply border-border h-5 w-5 flex-shrink-0 rounded-md border data-[state=checked]:bg-blue-600 data-[state=checked]:text-white;

&--icon {
@apply h-4 w-4;
Expand Down
2 changes: 1 addition & 1 deletion uikit/src/input/styles.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.input {
@apply border-border placeholder:text-muted-foreground flex h-9 w-full rounded-lg border bg-transparent px-3 py-1 transition-colors;
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100;
@apply focus-within:outline-none focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1;
@apply file:border-0 file:bg-transparent file:font-medium;
}
4 changes: 2 additions & 2 deletions uikit/src/progress/styles.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.progress {
@apply bg-secondary relative h-4 w-full overflow-hidden rounded-full;
@apply relative h-4 w-full overflow-hidden rounded-full bg-gray-100;

&-indicator {
@apply bg-primary h-full w-full flex-1 transition-all;
@apply h-full w-full flex-1 bg-blue-600 transition-all;
}
}
2 changes: 1 addition & 1 deletion uikit/src/select/styles.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.select {
@apply placeholder:text-muted-foreground border-border flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm disabled:cursor-not-allowed [&>span]:line-clamp-1;
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100;
@apply focus-within:outline-none focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1;

&-caret {
Expand Down
4 changes: 2 additions & 2 deletions uikit/src/slider/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@apply relative flex w-full touch-none select-none items-center;

&-track {
@apply relative h-1.5 w-full grow overflow-hidden rounded-full bg-gray-200 dark:bg-gray-800;
@apply relative h-1.5 w-full grow overflow-hidden rounded-full bg-gray-200;
[data-disabled] {
@apply cursor-not-allowed opacity-50;
}
Expand All @@ -13,6 +13,6 @@
}

&-thumb {
@apply border-primary/50 bg-background focus-visible:ring-ring block h-4 w-4 rounded-full border shadow transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:pointer-events-none disabled:opacity-50;
@apply bg-background focus-visible:ring-ring block h-4 w-4 rounded-full border border-blue-600/50 shadow transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:pointer-events-none disabled:opacity-50;
}
}
2 changes: 1 addition & 1 deletion uikit/src/switch/styles.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.switch {
@apply inline-flex h-[20px] w-[36px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent;
@apply focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2;
@apply data-[state=checked]:bg-primary data-[state=unchecked]:bg-input;
@apply data-[state=unchecked]:bg-input data-[state=checked]:bg-blue-600;
@apply disabled:cursor-not-allowed disabled:opacity-50;

&-toggle {
Expand Down
4 changes: 2 additions & 2 deletions uikit/src/tooltip/styles.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.tooltip {
@apply dark:bg-input dark:text-foreground z-50 overflow-hidden rounded-md bg-gray-950 px-2 py-1.5 text-xs font-medium text-gray-200 shadow-md;
@apply z-50 overflow-hidden rounded-md bg-gray-950 px-2 py-1.5 text-xs font-medium text-gray-200 shadow-md;
&-arrow {
@apply dark:fill-input fill-gray-950;
@apply fill-gray-950;
}
}
2 changes: 1 addition & 1 deletion web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: PropsWithChildren) {
return (
<html lang="en" suppressHydrationWarning>
<body className="bg-white font-sans text-sm antialiased dark:bg-background">
<body className="bg-white font-sans text-sm antialiased">
<div className="title-bar" />
<Providers>{children}</Providers>
</body>
Expand Down
14 changes: 7 additions & 7 deletions web/containers/CardSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function CardSidebar({
return (
<div
className={twMerge(
'flex w-full flex-col border-t border-border bg-zinc-100 dark:bg-zinc-900',
'flex w-full flex-col border-t border-border bg-zinc-100',
asChild ? 'rounded-lg border' : 'border-t'
)}
>
Expand All @@ -61,7 +61,7 @@ export default function CardSidebar({
if (!children) return
setShow(!show)
}}
className="flex w-full flex-1 items-center space-x-2 rounded-lg bg-zinc-100 py-2 pr-2 dark:bg-zinc-900"
className="flex w-full flex-1 items-center space-x-2 rounded-lg bg-zinc-100 py-2 pr-2"
>
<ChevronDownIcon
className={twMerge(
Expand All @@ -79,7 +79,7 @@ export default function CardSidebar({
{!hideMoreVerticalAction && (
<div
ref={setToggle}
className="cursor-pointer rounded-lg bg-zinc-100 p-2 px-3 dark:bg-zinc-900"
className="cursor-pointer rounded-lg bg-zinc-100 p-2 px-3"
onClick={() => setMore(!more)}
>
<MoreVerticalIcon className="h-5 w-5" />
Expand Down Expand Up @@ -114,15 +114,15 @@ export default function CardSidebar({
<>
{title === 'Model' ? (
<div className="flex flex-col">
<span className="font-medium text-black dark:text-muted-foreground">
<span className="font-medium text-black">
{openFileTitle()}
</span>
<span className="mt-1 text-muted-foreground">
Opens thread.json. Changes affect this thread only.
</span>
</div>
) : (
<span className="text-bold text-black dark:text-muted-foreground">
<span className="text-bold text-black">
{openFileTitle()}
</span>
)}
Expand All @@ -141,7 +141,7 @@ export default function CardSidebar({
/>
<>
<div className="flex flex-col">
<span className="line-clamp-1 font-medium text-black dark:text-muted-foreground">
<span className="line-clamp-1 font-medium text-black">
Edit Global Defaults for{' '}
<span
className="font-bold"
Expand Down Expand Up @@ -175,7 +175,7 @@ export default function CardSidebar({
{show && (
<div
className={twMerge(
'flex flex-col gap-2 bg-white px-2 dark:bg-background',
'flex flex-col gap-2 bg-white px-2',
asChild && 'rounded-b-lg'
)}
>
Expand Down
6 changes: 2 additions & 4 deletions web/containers/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ const Checkbox: React.FC<Props> = ({
return (
<div className="flex justify-between">
<div className="mb-1 flex items-center gap-x-2">
<p className="text-sm font-semibold text-zinc-500 dark:text-gray-300">
{title}
</p>
<p className="text-sm font-semibold text-zinc-500">{title}</p>
<Tooltip>
<TooltipTrigger asChild>
<InfoIcon size={16} className="flex-shrink-0 dark:text-gray-500" />
<InfoIcon size={16} className="flex-shrink-0" />
</TooltipTrigger>
<TooltipPortal>
<TooltipContent side="top" className="max-w-[240px]">
Expand Down
10 changes: 4 additions & 6 deletions web/containers/DropdownListSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,14 @@ const DropdownListSidebar = ({
isTabActive === 1 && '[&_.select-scroll-down-button]:hidden'
)}
>
<div className="relative px-2 py-2 dark:bg-secondary/50">
<ul className="inline-flex w-full space-x-2 rounded-lg bg-zinc-100 px-1 dark:bg-secondary">
<div className="relative px-2 py-2">
<ul className="inline-flex w-full space-x-2 rounded-lg bg-zinc-100 px-1">
{engineOptions.map((name, i) => {
return (
<li
className={twMerge(
'relative my-1 flex w-full cursor-pointer items-center justify-center space-x-2 px-2 py-2',
isTabActive === i &&
'rounded-md bg-background dark:bg-white'
isTabActive === i && 'rounded-md bg-background'
)}
key={i}
onClick={() => setIsTabActive(i)}
Expand All @@ -230,8 +229,7 @@ const DropdownListSidebar = ({
<span
className={twMerge(
'relative z-50 font-medium text-muted-foreground',
isTabActive === i &&
'font-bold text-foreground dark:text-black'
isTabActive === i && 'font-bold text-foreground'
)}
>
{name}
Expand Down
2 changes: 1 addition & 1 deletion web/containers/GPUDriverPromptModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const GPUDriverPrompt: React.FC = () => {
id="default-checkbox"
type="checkbox"
onChange={onDoNotShowAgainChange}
className="h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800 dark:focus:ring-blue-600"
className="h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-2 focus:ring-blue-500"
/>
<span>Don&apos;t show again</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/containers/Layout/BottomBar/DownloadingState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function DownloadingState() {
</span>
</Button>
<span
className="absolute left-0 h-full rounded-md rounded-l-md bg-primary/20"
className="absolute left-0 h-full rounded-md rounded-l-md bg-blue-500/20"
style={{
width: `${totalPercentage}%`,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ImportingModelState: React.FC = () => {
className="h-2 w-24"
value={transferredSize / totalSize}
/>
<span className="text-xs font-bold text-primary">
<span className="text-xs font-bold text-blue-600">
{progress.toFixed(2)}%
</span>
</div>
Expand Down
Loading

0 comments on commit 3c0ef12

Please sign in to comment.