docs: new docs

This commit is contained in:
0xSage 2023-11-13 11:01:26 +08:00
parent 21a616e838
commit c31091eca2
45 changed files with 2311 additions and 2297 deletions

View File

@ -0,0 +1,3 @@
---
title: Thread
---

3
docs/docs/api/chat.md Normal file
View File

@ -0,0 +1,3 @@
---
title: Chat
---

3
docs/docs/api/files.md Normal file
View File

@ -0,0 +1,3 @@
---
title: File
---

3
docs/docs/api/message.md Normal file
View File

@ -0,0 +1,3 @@
---
title: Message
---

3
docs/docs/api/model.md Normal file
View File

@ -0,0 +1,3 @@
---
title: Model
---

View File

@ -0,0 +1,4 @@
---
title: Overview
position: 1
---

3
docs/docs/api/thread.md Normal file
View File

@ -0,0 +1,3 @@
---
title: Chat
---

View File

@ -1,16 +0,0 @@
---
title: Overview
---
Jan's mission is to power the next-gen App with limitless extensibility by providing users with the following:
- Unified API/ Helpers so that they only need to care about what matters.
- Wide range of Optimized and state-of-the-art models that can help your App with Thinking/ Hearing/ Seeing capabilities. This is powered by our [Nitro](https://github.com/janhq/nitro).
- Strong support for the App marketplace and Model marketplace that streamline value from end customers to builders at all layers.
- The most important thing is: The users of Jan can use the Apps via UI and API for integration.
At Jan, we strongly believe in `Portable AI` and `Personal AI` that is created once and run anywhere.
## Downloads
[Jan.ai](https://jan.ai/) - Desktop app
[Jan Github](https://github.com/janhq/jan) - Opensource library for developers

View File

@ -1,5 +0,0 @@
---
title: "Azure OpenAI Plugin"
---
NPM Package: [@janhq/azure-openai-plugin](https://www.npmjs.com/package/@janhq/azure-openai-plugin)

View File

@ -1,5 +0,0 @@
---
title: "Data Plugin"
---
NPM Package: [@janhq/data-plugin](https://www.npmjs.com/package/@janhq/data-plugin)

View File

@ -1,5 +0,0 @@
---
title: "Inference Plugin"
---
NPM Package: [@janhq/inference-plugin](https://www.npmjs.com/package/@janhq/inference-plugin)

View File

@ -1,5 +0,0 @@
---
title: "Model Management Plugin"
---
NPM Package: [@janhq/model-management-plugin](https://www.npmjs.com/package/@janhq/model-management-plugin)

View File

@ -1,5 +0,0 @@
---
title: "Monitoring Plugin"
---
NPM Package: [@janhq/monitoring-plugin](https://www.npmjs.com/package/@janhq/monitoring-plugin)

View File

@ -1,5 +0,0 @@
---
title: "RAG Plugin"
---
Coming soon.

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 778 KiB

After

Width:  |  Height:  |  Size: 778 KiB

View File

Before

Width:  |  Height:  |  Size: 232 KiB

After

Width:  |  Height:  |  Size: 232 KiB

View File

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -0,0 +1,102 @@
---
title: Introduction
---
Jan can be used to build a variety of AI use cases, at every level of the stack:
- An OpenAI compatible API, with feature parity for `models`, `assistants`, `files` and more
- A standard data format on top of the user's local filesystem, allowing for transparency and composability
- Automatically package and distribute to Mac, Windows and Linux. Cloud coming soon
- An UI kit to customize user interactions with `assistants` and more
- A standalone inference engine for low level use cases
## Resources
<!-- (@Rex: to add some quickstart tutorials) -->
- Create an AI assistant
- Run an OpenAI compatible API endpoint
- Build a VSCode plugin with a local model
- Build a Jan platform module
## Key Concepts
### Modules
- Modules are modular, atomic implementations of a single OpenAI-compatible endpoint
- Modules can be swapped out for alternate implementations
- The default `messages` module persists messages in thread-specific `.json`
- `messages-postgresql` uses Postgres for production-grade cloud-native environments
| Jan Module | Description | API Docs |
| ---------- | ------------- | ---------------------------- |
| Chat | Inference | [/chat](/api/chat) |
| Models | Models | [/model](/api/model) |
| Assistants | Apps | [/assistant](/api/assistant) |
| Threads | Conversations | [/thread](/api/thread) |
| Messages | Messages | [/message](/api/message) |
![image](https://hackmd.io/_uploads/SkbP7LjmT.png)
### Local Filesystem
- Jan runs on top of standard structure of local files on user's filesystem
- This allows for composability and tinkerability
```sh=
/janroot # Jan's root folder (e.g. ~/jan)
/models # For raw AI models
/threads # For conversation history
/assistants # For AI assistants' configs, knowledge, etc.
```
```sh=
/models
/modelA
model.json # Default model settings
llama-7b-q4.gguf # Model binaries
llama-7b-q5.gguf # Include different quantizations
/threads
/jan-unixstamp-salt
model.json # Overrides assistant/model-level model settings
thread.json # thread metadata (e.g. subject)
messages.json # messages
content.json # What is this?
files/ # Future for RAG
/assistants
/jan
assistant.json # Assistant configs (see below)
# For any custom code
package.json # Import npm modules
# e.g. Langchain, Llamaindex
/src # Supporting files (needs better name)
index.js # Entrypoint
process.js # For electron IPC processes (needs better name)
# `/threads` at root level
# `/models` at root level
/shakespeare
assistant.json
model.json # Creator chooses model and settings
package.json
/src
index.js
process.js
/threads # Assistants remember conversations in the future
/models # Users can upload custom models
/finetuned-model
```
### Jan: a "global" assistant
Jan provides `/jan`, a default assistant that is available to users out-of-the-box. It is a generic assistant to illustrate power of Jan. In the future, it will support additional features e.g. multi-assistant conversations
- Your Assistant "Jan" lets you pick any model that is in the root /models folder
- Right panel: pick LLM model and set model parameters
- Jans threads will be at root level
- `model.json` will reflect model chosen for that session
- Be able to “add” other assistants in the future
- Jans files will be at thread level
- Jan is not a persistent memory assistant

View File

@ -0,0 +1,29 @@
---
title: "Chats"
---
Chats are essentially inference requests to a model
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/chat
## Chat Object
- Equivalent to: https://platform.openai.com/docs/api-reference/chat/object
## Chat API
See [/chat](/api/chat)
- Equivalent to: https://platform.openai.com/docs/api-reference/chat
```sh=
POST https://localhost:1337/v1/chat/completions
TODO:
# Figure out how to incorporate tools
```
## Chat Filesystem
- Chats will be persisted to `messages` within `threads`
- There is no data structure specific to Chats

View File

@ -0,0 +1,79 @@
---
title: "Models"
---
Models are AI models like Llama and Mistral
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/models
## Model Object
- `model.json`
> Equivalent to: https://platform.openai.com/docs/api-reference/models/object
```json=
{
// OpenAI model compatibility
// https://platform.openai.com/docs/api-reference/models)
"id": "llama-2-uuid",
"object": "model",
"created": 1686935002,
"owned_by": "you"
// Model settings (benchmark: Ollama)
// https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#template
"model_name": "llama2",
"model_path": "ROOT/models/...",
"parameters": {
"temperature": "..",
"token-limit": "..",
"top-k": "..",
"top-p": ".."
},
"template": "This is a full prompt template",
"system": "This is a system prompt",
// Model metadata (benchmark: HuggingFace)
"version": "...",
"author": "...",
"tags": "...",
...
}
```
## Model API
See [/model](/api/model)
- Equivalent to: https://platform.openai.com/docs/api-reference/models
```sh=
GET https://localhost:1337/v1/models # List models
GET https://localhost:1337/v1/models/{model} # Get model object
DELETE https://localhost:1337/v1/models/{model} # Delete model
TODO:
# Start model
# Stop model
```
## Model Filesystem
```sh
/janroot
/models
/modelA
model.json # Default model params
modelA.gguf
modelA.bin
/modelB/*
model.json
modelB.gguf
/assistants
model.json # Defines model, default: looks in `/models`
/models # Optional /models folder that overrides root
/modelA
model.json
modelA.bin
```

View File

@ -0,0 +1,80 @@
---
title: "Assistants"
---
Assistants can use models and tools.
- Jan's `Assistants` are even more powerful than OpenAI due to customizable code in `index.js`
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/assistants
## Assistant Object
- `assistant.json`
- Equivalent to: https://platform.openai.com/docs/api-reference/assistants/object
```json=
{
// Jan specific properties
"avatar": "https://lala.png"
"thread_location": "ROOT/threads" // Default to root (optional field)
// TODO: add moar
// OpenAI compatible properties: https://platform.openai.com/docs/api-reference/assistants
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698984975,
"name": "Math Tutor",
"description": null,
"model": reference model.json,
"instructions": reference model.json,
"tools": [
{
"type": "rag"
}
],
"file_ids": [],
"metadata": {}
}
```
## Assistants API
- _TODO_: What would modifying Assistant do? (doesn't mutate `index.js`?)
```sh=
GET https://api.openai.com/v1/assistants # List
POST https://api.openai.com/v1/assistants # C
GET https://api.openai.com/v1/assistants/{assistant_id} # R
POST https://api.openai.com/v1/assistants/{assistant_id} # U
DELETE https://api.openai.com/v1/assistants/{assistant_id} # D
```
## Assistants Filesystem
```sh=
/assistants
/jan
assistant.json # Assistant configs (see below)
# For any custom code
package.json # Import npm modules
# e.g. Langchain, Llamaindex
/src # Supporting files (needs better name)
index.js # Entrypoint
process.js # For electron IPC processes (needs better name)
# `/threads` at root level
# `/models` at root level
/shakespeare
assistant.json
model.json # Creator chooses model and settings
package.json
/src
index.js
process.js
/threads # Assistants remember conversations in the future
/models # Users can upload custom models
/finetuned-model
```

View File

@ -0,0 +1,53 @@
---
title: "Threads"
---
Threads contain `messages` history with assistants. Messages in a thread share context.
- Note: For now, threads "lock the model" after a `message` is sent
- When a new `thread` is created with Jan, users can choose the models
- Users can still edit model parameters/system prompts
- Note: future Assistants may customize this behavior
- Note: Assistants will be able to specify default thread location in the future
- Jan uses root-level threads, to allow for future multi-assistant threads
- Assistant Y may store threads in its own folder, to allow for [long-term assistant memory](https://github.com/janhq/jan/issues/344)
> OpenAI Equivalent: https://platform.openai.com/docs/api-reference/threads
## Thread Object
- `thread.json`
- Equivalent to: https://platform.openai.com/docs/api-reference/threads/object
```json
{
// Jan specific properties:
"summary": "HCMC restaurant recommendations",
"messages": {see below}
// OpenAI compatible properties: https://platform.openai.com/docs/api-reference/threads)
"id": "thread_abc123",
"object": "thread",
"created_at": 1698107661,
"metadata": {}
}
```
## Threads API
- Equivalent to: https://platform.openai.com/docs/api-reference/threads
```sh=
POST https://localhost:1337/v1/threads/{thread_id} # Create thread
GET https://localhost:1337/v1/threads/{thread_id} # Get thread
DELETE https://localhost:1337/v1/models/{thread_id} # Delete thread
```
## Threads Filesystem
```sh
/assistants
/homework-helper
/threads # context is "permanently remembered" by assistant in future conversations
/threads # context is only retained within a single thread
```

View File

@ -0,0 +1,53 @@
---
title: "Messages"
---
Messages are within `threads` and capture additional metadata.
- Equivalent to: https://platform.openai.com/docs/api-reference/messages
## Message Object
- Equivalent to: https://platform.openai.com/docs/api-reference/messages/object
```json
{
// Jan specific properties
"updatedAt": "..." // that's it I think
// OpenAI compatible properties: https://platform.openai.com/docs/api-reference/messages)
"id": "msg_dKYDWyQvtjDBi3tudL1yWKDa",
"object": "thread.message",
"created_at": 1698983503,
"thread_id": "thread_RGUhOuO9b2nrktrmsQ2uSR6I",
"role": "assistant",
"content": [
{
"type": "text",
"text": {
"value": "Hi! How can I help you today?",
"annotations": []
}
}
],
"file_ids": [],
"assistant_id": "asst_ToSF7Gb04YMj8AMMm50ZLLtY",
"run_id": "run_BjylUJgDqYK9bOhy4yjAiMrn",
"metadata": {}
}
```
## Messages API
- Equivalent to: https://platform.openai.com/docs/api-reference/messages
```sh=
POST https://api.openai.com/v1/threads/{thread_id}/messages # create msg
GET https://api.openai.com/v1/threads/{thread_id}/messages # list messages
GET https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}
# Get message file
GET https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files/{file_id}
# List message files
GET https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files
```

View File

@ -0,0 +1,43 @@
---
title: "Files"
---
Files can be used by `threads`, `assistants` and `fine-tuning`
> Equivalent to: https://platform.openai.com/docs/api-reference/files
## Files Object
- Equivalent to: https://platform.openai.com/docs/api-reference/files
- Note: OAI's struct doesn't seem very well designed
- `files.json`
```json
{
// Public properties (OpenAI Compatible: https://platform.openai.com/docs/api-reference/files/object)
"id": "file-BK7bzQj3FfZFXr7DbL6xJwfo",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "salesOverview.pdf",
"purpose": "assistants"
}
```
## File API
## Files Filesystem
- Files can exist in several parts of Jan's filesystem
- TODO: are files hard copied into these folders? Or do we define a `files.json` and only record the relative filepath?
```sh=
/files # root `/files` for finetuning, etc
/assistants
/jan
/files # assistant-specific files
/threads
/jan-12938912
/files # thread-specific files
```

View File

@ -0,0 +1,67 @@
---
title: User Interface
---
Jan provides a UI Kit for customize the UI for your use case. This means you can personalize the entire application according to your own brand and visual styles.
This page gives you an overview of how to customize the UI.
You can see some of the user interface components when you first open Jan.
To Link:
- Ribbon
- LeftSidebar
- Main
- RightSidebar
- StatusBar
## Views
![Jan Views](./img/jan-views.png)
TODO: add a better image.
### Ribbon
Assistants shortcuts and Modules settings show up here.
```js
import .. from "@jan"
sample code here
```
### LeftSidebar
Conversation threads show up here. This is customizable, so custom assistants can add additional menu items here.
```js
import .. from "@jan"
sample code here
```
### Main
The main view for interacting with assistants. This is customizable, so custom assistants can add in additional UI components. By default, this is a chat thread with assistants.
```js
import .. from "@jan"
sample code here
```
### RightSidebar
A "settings" view for each thread. Users should be able to edit settings or other configs to customize the assistant experience within each thread.
```js
import .. from "@jan"
sample code here
```
### StatusBar
A global status bar that shows processes, hardware/disk utilization and more.
```js
import .. from "@jan"
sample code here
```

View File

@ -1,44 +0,0 @@
---
title: Cloud Native
---
# Installing Jan Cloud Native
Cloud Native is useful when you want to deploy Jan to a shared/remote/cloud server, rather than running it as a local Desktop app.
> This is an experimental feature - expect breaking changes!
### Getting Started
#### Run from source code
```bash
git clone https://github.com/janhq/jan
cd jan
git checkout feat-255 && git pull
yarn install
yarn start:server
```
Open your browser at [http://localhost:4000](http://localhost:4000)
### Run from docker file
```bash
git clone https://github.com/janhq/jan
cd jan
git checkout feat-255 && git pull
docker build --platform linux/x86_64 --progress=plain -t jan-server .
docker run --platform linux/x86_64 --name jan-server -p4000:4000 -p3928:3928 -it jan-server
```
Open your browser at [http://localhost:4000](http://localhost:4000)
### Architecture
![cloudnative](../../developers/img/cloudnative.png)
### TODOs
- [Authencation Plugins](https://github.com/janhq/jan/issues/334)
- [Remote server](https://github.com/janhq/jan/issues/200)

View File

@ -1,5 +1,5 @@
---
title: Nitro
title: Nitro
slug: /nitro
---
@ -73,4 +73,4 @@ curl -X POST 'http://localhost:3928/inferences/llamacpp/loadmodel' \
## Architecture diagram
![Nitro Architecture](../developers/img/architecture.png)
![Nitro Architecture](../docs/img/architecture.png)

View File

@ -129,9 +129,15 @@ const config = {
},
{
type: "docSidebar",
sidebarId: "devSidebar",
sidebarId: "docsSidebar",
position: "left",
label: "Developers",
label: "Documentation",
},
{
type: "docSidebar",
sidebarId: "apiSidebar",
position: "left",
label: "API Reference",
},
// Navbar right
{

View File

@ -38,51 +38,43 @@ const sidebars = {
collapsed: true,
link: { type: "doc", id: "guides/install/install" },
items: [
"guides/install/linux",
"guides/install/windows",
"guides/install/mac",
"guides/install/cloud-native",
{
type: "autogenerated",
dirName: "guides/install",
},
],
},
"guides/troubleshooting",
],
devSidebar: [
"developers/developers",
"nitro/nitro",
docsSidebar: [
"docs/introduction",
{
type: "category",
label: "Apps",
label: "Modules",
collapsible: true,
collapsed: true,
collapsed: false,
items: [
{
type: "autogenerated",
dirName: "developers/apps",
dirName: "docs/modules",
},
],
},
"docs/user-interface",
],
apiSidebar: [
"api/overview",
{
type: "category",
label: "Plugins",
label: "Endpoints",
collapsible: true,
collapsed: true,
collapsed: false,
items: [
{
type: "autogenerated",
dirName: "developers/plugins",
},
],
},
{
type: "category",
label: "API Reference",
collapsible: true,
collapsed: true,
items: [
{
type: "autogenerated",
dirName: "reference",
dirName: "api",
},
],
},

File diff suppressed because it is too large Load Diff