Skip to content

Commit

Permalink
Merge branch 'main' into docs/openai-api
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-homebrew authored Nov 18, 2023
2 parents b276542 + 66b0511 commit 6e571e8
Show file tree
Hide file tree
Showing 124 changed files with 2,358 additions and 1,768 deletions.
11 changes: 8 additions & 3 deletions .github/scripts/auto-sign.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

APP_PATH=${APP_PATH}
DEVELOPER_ID=${DEVELOPER_ID}
find $APP_PATH \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \;
# Check if both APP_PATH and DEVELOPER_ID environment variables are set
if [[ -z "$APP_PATH" ]] || [[ -z "$DEVELOPER_ID" ]]; then
echo "Either APP_PATH or DEVELOPER_ID is not set. Skipping script execution."
exit 0
fi

# If both variables are set, execute the following commands
find "$APP_PATH" \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \;
12 changes: 6 additions & 6 deletions .github/workflows/jan-electron-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ jobs:
run: |
yarn build:core
yarn install
yarn build:plugins-darwin
yarn build:plugins
env:
APP_PATH: "."
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}

- name: Build and publish app
run: |
yarn build:publish-darwin
yarn build:publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: "/tmp/codesign.p12"
Expand Down Expand Up @@ -122,11 +122,11 @@ jobs:
yarn build:core
yarn install
$env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION
yarn build:plugins-win32
yarn build:plugins
- name: Build and publish app
run: |
yarn build:publish-win32
yarn build:publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -178,11 +178,11 @@ jobs:
yarn config set network-timeout 300000
yarn build:core
yarn install
yarn build:plugins-linux
yarn build:plugins
- name: Build and publish app
run: |
yarn build:publish-linux
yarn build:publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/jan-electron-linter-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ jobs:
yarn build:core
yarn install
$env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION
yarn build:plugins-win32
yarn build:test-win32
yarn build:plugins
yarn build:test
$env:CI="e2e"
yarn test
Expand Down Expand Up @@ -131,6 +131,6 @@ jobs:
yarn config set network-timeout 300000
yarn build:core
yarn install
yarn build:plugins-linux
yarn build:test-linux
yarn build:plugins
yarn build:test
yarn test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jan - Personal AI
# Jan - Own Your AI

![Project Cover](https://github.com/janhq/jan/assets/89722390/be4f07ef-13df-4621-8f25-b861f1d5b7b3)
![Jan banner](https://github.com/janhq/jan/assets/89722390/35daac7d-b895-487c-a6ac-6663daaad78e)

<p align="center">
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
Expand All @@ -21,7 +21,7 @@

> ⚠️ **Jan is currently in Development**: Expect breaking changes and bugs!
Jan is a free, open-source alternative to OpenAI that runs on your personal computer.
Jan is a free, open-source alternative to OpenAI's platform that runs on a local folder of open-format files.

**Jan runs on any hardware.** From PCs to multi-GPU clusters, Jan supports universal architectures:

Expand Down
41 changes: 8 additions & 33 deletions core/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,16 @@ export enum EventName {
OnDownloadError = "onDownloadError",
}

export type MessageHistory = {
role: string;
content: string;
};
/**
* The `NewMessageRequest` type defines the shape of a new message request object.
*/
export type NewMessageRequest = {
_id?: string;
conversationId?: string;
user?: string;
avatar?: string;
message?: string;
createdAt?: string;
updatedAt?: string;
history?: MessageHistory[];
};

/**
* The `NewMessageRequest` type defines the shape of a new message request object.
*/
export type NewMessageResponse = {
_id?: string;
conversationId?: string;
user?: string;
avatar?: string;
message?: string;
createdAt?: string;
updatedAt?: string;
};

/**
* Adds an observer for an event.
*
* @param eventName The name of the event to observe.
* @param handler The handler function to call when the event is observed.
*/
const on: (eventName: string, handler: Function) => void = (eventName, handler) => {
const on: (eventName: string, handler: Function) => void = (
eventName,
handler
) => {
window.corePlugin?.events?.on(eventName, handler);
};

Expand All @@ -59,7 +31,10 @@ const on: (eventName: string, handler: Function) => void = (eventName, handler)
* @param eventName The name of the event to stop observing.
* @param handler The handler function to call when the event is observed.
*/
const off: (eventName: string, handler: Function) => void = (eventName, handler) => {
const off: (eventName: string, handler: Function) => void = (
eventName,
handler
) => {
window.corePlugin?.events?.off(eventName, handler);
};

Expand Down
17 changes: 17 additions & 0 deletions core/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ const writeFile: (path: string, data: string) => Promise<any> = (path, data) =>
window.coreAPI?.writeFile(path, data) ??
window.electronAPI?.writeFile(path, data);

/**
* Gets the user space path.
* @returns {Promise<any>} A Promise that resolves with the user space path.
*/
const getUserSpace = (): Promise<string> =>
window.coreAPI?.getUserSpace() ?? window.electronAPI?.getUserSpace();

/**
* Checks whether the path is a directory.
* @param path - The path to check.
* @returns {boolean} A boolean indicating whether the path is a directory.
*/
const isDirectory = (path: string): Promise<boolean> =>
window.coreAPI?.isDirectory(path) ?? window.electronAPI?.isDirectory(path);

/**
* Reads the contents of a file at the specified path.
* @param {string} path - The path of the file to read.
Expand Down Expand Up @@ -48,6 +63,8 @@ const deleteFile: (path: string) => Promise<any> = (path) =>
window.coreAPI?.deleteFile(path) ?? window.electronAPI?.deleteFile(path);

export const fs = {
isDirectory,
getUserSpace,
writeFile,
readFile,
listFiles,
Expand Down
11 changes: 4 additions & 7 deletions core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ export { events } from "./events";
* Events types exports.
* @module
*/
export {
EventName,
NewMessageRequest,
NewMessageResponse,
MessageHistory,
} from "./events";
export * from "./events";

export * from "./types/index";

/**
* Filesystem module exports.
Expand All @@ -37,4 +34,4 @@ export { fs } from "./fs";
* Plugin base module export.
* @module
*/
export { JanPlugin, PluginType } from "./plugin";
export * from "./plugin";
6 changes: 3 additions & 3 deletions core/src/plugins/conversational.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Thread } from "../index";
import { JanPlugin } from "../plugin";
import { Conversation } from "../types/index";

/**
* Abstract class for conversational plugins.
Expand All @@ -17,10 +17,10 @@ export abstract class ConversationalPlugin extends JanPlugin {
/**
* Saves a conversation.
* @abstract
* @param {Conversation} conversation - The conversation to save.
* @param {Thread} conversation - The conversation to save.
* @returns {Promise<void>} A promise that resolves when the conversation is saved.
*/
abstract saveConversation(conversation: Conversation): Promise<void>;
abstract saveConversation(conversation: Thread): Promise<void>;

/**
* Deletes a conversation.
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/inference.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NewMessageRequest } from "../events";
import { MessageRequest } from "../index";
import { JanPlugin } from "../plugin";

/**
Expand All @@ -21,5 +21,5 @@ export abstract class InferencePlugin extends JanPlugin {
* @param data - The data for the inference request.
* @returns The result of the inference request.
*/
abstract inferenceRequest(data: NewMessageRequest): Promise<any>;
abstract inferenceRequest(data: MessageRequest): Promise<any>;
}
Loading

0 comments on commit 6e571e8

Please sign in to comment.