Skip to content

Commit

Permalink
Merge branch 'main' into add/model-list
Browse files Browse the repository at this point in the history
  • Loading branch information
hahuyhoang411 authored Dec 28, 2023
2 parents 4e5297b + c580b4c commit 975f187
Show file tree
Hide file tree
Showing 24 changed files with 562 additions and 271 deletions.
19 changes: 8 additions & 11 deletions .github/ISSUE_TEMPLATE/epic-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ assignees: ''

---

**Motivation**
## Motivation
-

**Specs & Designs**
## Specs
-

**In Scope**
-
## Designs
[Figma](link)

**Not in Scope**
-
## Tasklist
- [ ]

**Tasklist**
> Note: All issues need to share the same `milestone` as this epic
## Not in Scope
-

**Related Milestones**
- Past
- Future
## Appendix
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ 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 (Nighlty Build)</b></td>
<td style="text-align:center" colspan="4">
<a href='https://github.com/janhq/jan/actions/runs/7329755769'>
<a href='https://github.com/janhq/jan/actions/runs/7341513351'>
<b>Github action artifactory</b>
</a>
</td>
Expand Down
75 changes: 49 additions & 26 deletions docs/docs/guides/04-using-models/02-import-manually.mdx
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
---
title: Import Models Manually
slug: /guides/using-models/import-manually
description: Jan is a ChatGPT-alternative that runs on your own computer, with a local API server.
keywords:
[
Jan AI,
Jan,
ChatGPT alternative,
local AI,
private AI,
conversational AI,
no-subscription fee,
large language model,
import-models-manually,
]
---

:::caution
This is currently under development.
:::

{/* Imports */}
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

Jan is compatible with all GGUF models.

If you don't see the model you want in the Hub, or if you have a custom model, you can add it to Jan.
If you can not find the model you want in the Hub or have a custom model you want to use, you can import it manually.

In this guide we will use our latest model, [Trinity](https://huggingface.co/janhq/trinity-v1-GGUF), as an example.
In this guide, we will show you how to import a GGUF model from [HuggingFace](https://huggingface.co/), using our lastest model, [Trinity](https://huggingface.co/janhq/trinity-v1-GGUF), as an example.

> We are fast shipping a UI to make this easier, but it's a bit manual for now. Apologies.
## 1. Create a model folder
## Steps to Manually Import a Model

Navigate to the `~/jan/models` folder on your computer.
### 1. Create a Model Folder

In `App Settings`, go to `Advanced`, then `Open App Directory`.
Navigate to the `~/jan/models` folder. You can find this folder by going to `App Settings` > `Advanced` > `Open App Directory`.

<Tabs groupId="operating-systems">
<TabItem value="mac" label="macOS">
Expand Down Expand Up @@ -70,11 +88,11 @@ In the `models` folder, create a folder with the name of the model.
</TabItem>
</Tabs>

## 2. Create a model JSON
### 2. Create a Model JSON

Jan follows a folder-based, [standard model template](/specs/models) called a `model.json` to persist the model configurations on your local filesystem.
Jan follows a folder-based, [standard model template](/docs/engineering/models) called a `model.json` to persist the model configurations on your local filesystem.

This means you can easily & transparently reconfigure your models and export and share your preferences.
This means that you can easily reconfigure your models, export them, and share your preferences transparently.

<Tabs groupId="operating-systems">
<TabItem value="mac" label="macOS">
Expand All @@ -89,7 +107,7 @@ This means you can easily & transparently reconfigure your models and export and

```sh
cd trinity-v1-7b
touch model.json
echo {} > model.json
```

</TabItem>
Expand All @@ -103,48 +121,53 @@ This means you can easily & transparently reconfigure your models and export and
</TabItem>
</Tabs>

Copy the following configurations into the `model.json`.

1. Make sure the `id` property is the same as the folder name you created.
2. Make sure the `source_url` property is the direct binary download link ending in `.gguf`. In HuggingFace, you can find the directl links in `Files and versions` tab.
3. Ensure you are using the correct `prompt_template`. This is usually provided in the HuggingFace model's description page.
Edit `model.json` and include the following configurations:

> Note: Currently, the filename must be `model.json` and the ID has to be equal to the foldername. In the `model.json`, you have to include the `state` property and set it to `ready` for Jan to recognize the model.
- Ensure the filename must be `model.json`.
- Ensure the `id` property matches the folder name you created.
- Ensure the GGUF filename should match the `id` property exactly.
- Ensure the `source_url` property is the direct binary download link ending in `.gguf`. In HuggingFace, you can find the direct links in `Files and versions` tab.
- Ensure you are using the correct `prompt_template`. This is usually provided in the HuggingFace model's description page.
- Ensure the `state` property is set to `ready`.

```js
{
// highlight-start
"source_url": "https://huggingface.co/janhq/trinity-v1-GGUF/resolve/main/trinity-v1.Q4_K_M.gguf",
"id": "trinity-v1-7b",
// highlight-end
"object": "model",
"name": "Trinity 7B Q4",
"name": "Trinity-v1 7B Q4",
"version": "1.0",
"description": "Trinity is an experimental model merge of GreenNodeLM & LeoScorpius using the Slerp method. Recommended for daily assistance purposes.",
"format": "gguf",
"settings": {
"ctx_len": 2048,
"prompt_template": "<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant"
"ctx_len": 4096,
// highlight-next-line
"prompt_template": "{system_message}\n### Instruction:\n{prompt}\n### Response:"
},
"parameters": {
"max_tokens": 2048
"max_tokens": 4096
},
"metadata": {
"author": "Jan",
"tags": ["7B", "Merged", "Featured"],
"tags": ["7B", "Merged"],
"size": 4370000000
},
// highlight-next-line
"state": "ready",
"engine": "nitro"
}
```

## 3. Download your model
### 3. Download the Model

Restart the Jan application and look for your model in the Hub.
Restart Jan and navigate to the Hub. Locate your model and click the `Download` button to download the model binary.

Click the green `download` button to download your actual model binary. This pulls from the `source_url` you provided above.
![image](assets/download-model.png)

![image](https://hackmd.io/_uploads/HJLAqvwI6.png)
Your model is now ready to use in Jan.

There you go! You are ready to use your model.
## Assistance and Support

If you have any questions or want to request for more preconfigured GGUF models, please message us in [Discord](https://discord.gg/Dt7MxDyNNZ).
If you have questions or are looking for more preconfigured GGUF models, please feel free to join our [Discord community](https://discord.gg/Dt7MxDyNNZ) for support, updates, and discussions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 7 additions & 22 deletions web/containers/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
import { FieldValues, UseFormRegister } from 'react-hook-form'
import React from 'react'

import { ModelRuntimeParams } from '@janhq/core'
import { Switch } from '@janhq/uikit'

import { useAtomValue } from 'jotai'

import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'

import {
getActiveThreadIdAtom,
getActiveThreadModelRuntimeParamsAtom,
} from '@/helpers/atoms/Thread.atom'
import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom'

type Props = {
name: string
title: string
checked: boolean
register: UseFormRegister<FieldValues>
}

const Checkbox: React.FC<Props> = ({ name, title, checked, register }) => {
const Checkbox: React.FC<Props> = ({ name, title, checked }) => {
const { updateModelParameter } = useUpdateModelParameters()
const threadId = useAtomValue(getActiveThreadIdAtom)
const activeModelParams = useAtomValue(getActiveThreadModelRuntimeParamsAtom)

const onCheckedChange = (checked: boolean) => {
if (!threadId || !activeModelParams) return
if (!threadId) return

const updatedModelParams: ModelRuntimeParams = {
...activeModelParams,
[name]: checked,
}

updateModelParameter(threadId, updatedModelParams)
updateModelParameter(threadId, name, checked)
}

return (
<div className="flex justify-between">
<label>{title}</label>
<Switch
checked={checked}
{...register(name)}
onCheckedChange={onCheckedChange}
/>
<p className="mb-2 text-sm font-semibold text-gray-600">{title}</p>
<Switch checked={checked} onCheckedChange={onCheckedChange} />
</div>
)
}
Expand Down
Loading

0 comments on commit 975f187

Please sign in to comment.