Skip to content

Commit

Permalink
Merge branch 'main' into fix350
Browse files Browse the repository at this point in the history
  • Loading branch information
freelerobot authored Oct 16, 2023
2 parents 614c58f + 4b92366 commit 7edb938
Show file tree
Hide file tree
Showing 34 changed files with 7,611 additions and 7,223 deletions.
699 changes: 647 additions & 52 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Jan - Run your own AI

<p align="center">
<img alt="janlogo" src="https://user-images.githubusercontent.com/69952136/266827788-b37d6f41-fc34-4677-aa1f-3e2ca6d3c91a.png">
</p>
![](./docs/static/img/github-readme-banner.png)

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

> ⚠️ **Jan is currently in Development**: Expect breaking changes and bugs!
**Use offline LLMs with your own data.** Run open source models like Llama2 or Falcon on your internal computers/servers.
Jan runs Large Language Models and AIs on your own Windows, Mac or Linux computer. Jan can be run as a desktop app, or as a cloud-native deployment.

Jan is free and open source, under the GPLv3 license.

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

Expand Down
Binary file added docs/static/img/github-readme-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions electron/core/plugins/data-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export function init({ register }: { register: RegisterExtensionPoint }) {

register(DataService.GetConversations, getConversations.name, getConversations);
register(DataService.CreateConversation, createConversation.name, createConversation);
register(DataService.UpdateConversation, updateConversation.name, updateConversation);
register(DataService.UpdateMessage, updateMessage.name, updateMessage);
register(DataService.DeleteConversation, deleteConversation.name, deleteConversation);
register(DataService.CreateMessage, createMessage.name, createMessage);
Expand All @@ -160,13 +161,19 @@ export function init({ register }: { register: RegisterExtensionPoint }) {
function getConversations(): Promise<any> {
return store.findMany("conversations", {}, [{ updatedAt: "desc" }]);
}

function createConversation(conversation: any): Promise<number | undefined> {
return store.insertOne("conversations", conversation);
}

function updateConversation(conversation: any): Promise<void> {
return store.updateOne("conversations", conversation._id, conversation);
}

function createMessage(message: any): Promise<number | undefined> {
return store.insertOne("messages", message);
}

function updateMessage(message: any): Promise<void> {
return store.updateOne("messages", message._id, message);
}
Expand Down
9 changes: 7 additions & 2 deletions electron/core/plugins/data-plugin/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ function insertOne(collectionName: string, value: any): Promise<any> {
*
*/
function updateOne(collectionName: string, key: string, value: any): Promise<void> {
console.debug(`updateOne ${collectionName}: ${key} - ${JSON.stringify(value)}`);
return dbs[collectionName].get(key).then((doc) => {
return dbs[collectionName].put({
_id: key,
_rev: doc._rev,
force: true,
...value,
});
},
{ force: true });
}).then((res: any) => {
console.info(`updateOne ${collectionName} result: ${JSON.stringify(res)}`);
}).catch((err: any) => {
console.error(`updateOne ${collectionName} error: ${err}`);
});
}

Expand Down
2 changes: 1 addition & 1 deletion electron/core/plugins/data-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-plugin",
"version": "1.0.3",
"version": "1.0.4",
"description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg",
"main": "dist/esm/index.js",
Expand Down
109 changes: 105 additions & 4 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions plugin-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export enum DataService {
*/
CreateConversation = "createConversation",

/**
* Updates an existing conversation on the server.
*/
UpdateConversation = "updateConversation",

/**
* Deletes an existing conversation from the server.
*/
Expand Down
2 changes: 1 addition & 1 deletion plugin-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/plugin-core",
"version": "0.1.5",
"version": "0.1.6",
"description": "Plugin core lib",
"keywords": [
"jan",
Expand Down
68 changes: 30 additions & 38 deletions web/app/_components/HistoryItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import JanImage from "../JanImage";
import { useAtomValue, useSetAtom } from "jotai";
import Image from "next/image";
import { Conversation } from "@/_models/Conversation";
Expand All @@ -17,18 +16,21 @@ import {
MainViewState,
} from "@/_helpers/atoms/MainView.atom";
import useInitModel from "@/_hooks/useInitModel";
import { displayDate } from "@/_utils/datetime";

type Props = {
conversation: Conversation;
avatarUrl?: string;
name: string;
summary?: string;
updatedAt?: string;
};

const HistoryItem: React.FC<Props> = ({
conversation,
avatarUrl,
name,
summary,
updatedAt,
}) => {
const setMainViewState = useSetAtom(setMainViewStateAtom);
Expand Down Expand Up @@ -73,49 +75,39 @@ const HistoryItem: React.FC<Props> = ({
rightImageUrl = "icons/loading.svg";
}

const description = conversation?.lastMessage ?? "No new message";

return (
<button
className={`flex flex-row mx-1 items-center gap-2.5 rounded-lg p-2 ${backgroundColor} hover:bg-hover-light`}
<li
role="button"
className={`flex flex-row ml-3 mr-2 rounded p-3 ${backgroundColor} hover:bg-hover-light`}
onClick={onClick}
>
<Image
width={36}
height={36}
src={avatarUrl ?? "icons/app_icon.svg"}
className="w-9 aspect-square rounded-full"
alt=""
/>
<div className="flex flex-col justify-between text-sm leading-[20px] w-full">
<div className="flex flex-row items-center justify-between">
<span className="text-gray-900 text-left">{name}</span>
<span className="text-xs leading-[13px] tracking-[-0.4px] text-gray-400">
{updatedAt && new Date(updatedAt).toDateString()}
<div className="w-8 h-8">
<Image
width={32}
height={32}
src={avatarUrl ?? "icons/app_icon.svg"}
className="aspect-square rounded-full"
alt=""
/>
</div>

<div className="flex flex-col ml-2 flex-1">
{/* title */}
<div className="flex">
<span className="flex-1 text-gray-900 line-clamp-1">
{summary ?? name}
</span>
<span className="text-xs leading-5 text-gray-500 line-clamp-1">
{updatedAt && displayDate(new Date(updatedAt).getTime())}
</span>
</div>
<div className="flex items-center justify-between gap-1">
<div className="flex-1">
<span className="text-gray-400 hidden-text text-left">
{conversation?.message ?? (
<span>
No new message
<br className="h-5 block" />
</span>
)}
</span>
</div>
<>
{rightImageUrl != null ? (
<JanImage
imageUrl={rightImageUrl ?? ""}
className="rounded"
width={24}
height={24}
/>
) : undefined}
</>
</div>

{/* description */}
<span className="mt-1 text-gray-400 line-clamp-2">{description}</span>
</div>
</button>
</li>
);
};

Expand Down
Loading

0 comments on commit 7edb938

Please sign in to comment.