Skip to content

Commit

Permalink
Merge pull request janhq#1830 from janhq/main
Browse files Browse the repository at this point in the history
Sync Release 0.4.5 to dev
  • Loading branch information
louis-jan authored Jan 29, 2024
2 parents 7c30c56 + 025415f commit 97a4978
Show file tree
Hide file tree
Showing 29 changed files with 358 additions and 253 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/jan-electron-build-nightly.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Jan Build Electron App Nightly or Manual

on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'docs/**'
schedule:
- cron: '0 20 * * 1,2,3' # At 8 PM UTC on Monday, Tuesday, and Wednesday which is 3 AM UTC+7 Tuesday, Wednesday, and Thursday
workflow_dispatch:
Expand All @@ -23,12 +29,20 @@ jobs:
- name: Set public provider
id: set-public-provider
run: |
if [ ${{ github.event == 'workflow_dispatch' }} ]; then
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "::set-output name=public_provider::${{ github.event.inputs.public_provider }}"
echo "::set-output name=ref::${{ github.ref }}"
else
echo "::set-output name=public_provider::cloudflare-r2"
echo "::set-output name=ref::refs/heads/dev"
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "::set-output name=public_provider::cloudflare-r2"
echo "::set-output name=ref::refs/heads/dev"
elif [ "${{ github.event_name }}" == "push" ]; then
echo "::set-output name=public_provider::cloudflare-r2"
echo "::set-output name=ref::${{ github.ref }}"
else
echo "::set-output name=public_provider::none"
echo "::set-output name=ref::${{ github.ref }}"
fi
fi
# Job create Update app version based on latest release tag with build number and save to output
get-update-version:
Expand Down Expand Up @@ -73,6 +87,17 @@ jobs:
push_to_branch: dev
new_version: ${{ needs.get-update-version.outputs.new_version }}

noti-discord-pre-release-and-update-url-readme:
needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider]
secrets: inherit
if: github.event_name == 'push'
uses: ./.github/workflows/template-noti-discord-and-update-url-readme.yml
with:
ref: refs/heads/dev
build_reason: Pre-release
push_to_branch: dev
new_version: ${{ needs.get-update-version.outputs.new_version }}

noti-discord-manual-and-update-url-readme:
needs: [build-macos, build-windows-x64, build-linux-x64, get-update-version, set-public-provider]
secrets: inherit
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/jan-electron-build-pre-release.yml

This file was deleted.

30 changes: 14 additions & 16 deletions core/src/node/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,36 @@ import fs from 'fs'
import util from 'util'
import { getAppLogPath, getServerLogPath } from './utils'

export const log = function (message: string) {
const appLogPath = getAppLogPath()
export const log = (message: string) => {
const path = getAppLogPath()
if (!message.startsWith('[')) {
message = `[APP]::${message}`
}

message = `${new Date().toISOString()} ${message}`

if (fs.existsSync(appLogPath)) {
var log_file = fs.createWriteStream(appLogPath, {
flags: 'a',
})
log_file.write(util.format(message) + '\n')
log_file.close()
console.debug(message)
}
writeLog(message, path)
}

export const logServer = function (message: string) {
const serverLogPath = getServerLogPath()
export const logServer = (message: string) => {
const path = getServerLogPath()
if (!message.startsWith('[')) {
message = `[SERVER]::${message}`
}

message = `${new Date().toISOString()} ${message}`
writeLog(message, path)
}

if (fs.existsSync(serverLogPath)) {
var log_file = fs.createWriteStream(serverLogPath, {
const writeLog = (message: string, logPath: string) => {
if (!fs.existsSync(logPath)) {
fs.writeFileSync(logPath, message)
} else {
const logFile = fs.createWriteStream(logPath, {
flags: 'a',
})
log_file.write(util.format(message) + '\n')
log_file.close()
logFile.write(util.format(message) + '\n')
logFile.close()
console.debug(message)
}
}
6 changes: 6 additions & 0 deletions core/src/types/config/appConfigEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* App configuration event name
*/
export enum AppConfigurationEventName {
OnConfigurationUpdate = 'OnConfigurationUpdate',
}
1 change: 1 addition & 0 deletions core/src/types/config/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './appConfigEntity'
export * from './appConfigEvent'
20 changes: 18 additions & 2 deletions extensions/inference-openai-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
MessageEvent,
ModelEvent,
InferenceEvent,
AppConfigurationEventName,
joinPath,
} from "@janhq/core";
import { requestInference } from "./helpers/sse";
import { ulid } from "ulid";
Expand Down Expand Up @@ -71,6 +73,20 @@ export default class JanInferenceOpenAIExtension extends BaseExtension {
events.on(InferenceEvent.OnInferenceStopped, () => {
JanInferenceOpenAIExtension.handleInferenceStopped(this);
});

const settingsFilePath = await joinPath([
JanInferenceOpenAIExtension._engineDir,
JanInferenceOpenAIExtension._engineMetadataFileName,
]);

events.on(
AppConfigurationEventName.OnConfigurationUpdate,
(settingsKey: string) => {
// Update settings on changes
if (settingsKey === settingsFilePath)
JanInferenceOpenAIExtension.writeDefaultEngineSettings();
},
);
}

/**
Expand Down Expand Up @@ -182,7 +198,7 @@ export default class JanInferenceOpenAIExtension extends BaseExtension {
},
error: async (err) => {
if (instance.isCancelled || message.content.length > 0) {
message.status = MessageStatus.Error;
message.status = MessageStatus.Stopped;
events.emit(MessageEvent.OnMessageUpdate, message);
return;
}
Expand All @@ -194,7 +210,7 @@ export default class JanInferenceOpenAIExtension extends BaseExtension {
},
};
message.content = [messageContent];
message.status = MessageStatus.Ready;
message.status = MessageStatus.Error;
events.emit(MessageEvent.OnMessageUpdate, message);
},
});
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:cursor-not-allowed disabled:bg-zinc-100;
@apply disabled:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
@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;
}
3 changes: 2 additions & 1 deletion uikit/src/select/styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +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 disabled:opacity-50 [&>span]:line-clamp-1;
@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:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
@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
13 changes: 4 additions & 9 deletions web/containers/CardSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { useClickOutside } from '@/hooks/useClickOutside'

import { usePath } from '@/hooks/usePath'

import { openFileTitle } from '@/utils/titleUtils'

import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'

interface Props {
Expand All @@ -38,13 +40,6 @@ export default function CardSidebar({

useClickOutside(() => setMore(false), null, [menu, toggle])

let openFolderTitle: string = 'Open Containing Folder'
if (isMac) {
openFolderTitle = 'Show in Finder'
} else if (isWindows) {
openFolderTitle = 'Show in File Explorer'
}

return (
<div
className={twMerge(
Expand Down Expand Up @@ -118,15 +113,15 @@ export default function CardSidebar({
{title === 'Model' ? (
<div className="flex flex-col">
<span className="font-medium text-black dark:text-muted-foreground">
{openFolderTitle}
{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">
Show in Finder
{openFileTitle()}
</span>
)}
</>
Expand Down
Loading

0 comments on commit 97a4978

Please sign in to comment.