Menlo Research
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Jan: File-based approach with OpenAI compatibility ## High Level Goals - OpenAI-compatible API - Local File Structure (as the permanent storage soln) - Composability & Extensibility *See rational at bottom* ### Nomenclature - `API`: - But Devs should be able to just use the API to build externally, e.g. a VSCode extension. - `SDK`: - Builds on top of the API - `Plugins`: - System-wide plugins, can be called by higher-level functions - `Assistants`: - An assistant is _not_ a `Plugin`; - Assistants are higher-level abstractions that are 1:1 with OpenAI's Assistants - `Assistants` can compose over `models` and `tools` , and run arbitrary code - `Tools`: - Equivalent to OpenAI's "tools" or "functions" (formerly "plugins"). - Installed at the Assistant level as npm imports? ### Deprecated - `Apps` are deprecated ## Directory Structure ```sh # Sample user folder structure /models /llama-7b # Model_id model.json # Default Model settings llama-7b-q4-k-l.gguf # Raw model file(s) /assistants /jan assistant.json # e.g. description model.jsons # MODELS * /homework-helper # Assistant_id assistant.json model.json # Overrides Model Settings, if set /files answer-sheet.pdf # Q!: files copied => More exportable files.json # Q!: referenced => More lightweight /my-ai-gf assistant.json model_x.json model_xx.json # Multi model assistant # Go workspace convention overrides would also allow: /models llama-7b /threads /... /stable-diffuser assistant.json model.json index.js # Q!: allow SDK impl here? /threads /jan_unixTimestamp thread.json model.json # Model that user chose for the thread messages.json # Messages.json, message.files point to `/files` /files /assistantName_unixTimestamp thread.json model.json # Overrides Assistant-level ModelFile messages.json ``` Note: The Jan Folder Structure follows Go Workspace Conventions, i.e. `the closest/deepest path import takes precedence`. This means that if there are multiple `/threads` or `/models` within an `/assistant` folder, the one that is imported from within the directory wins. ## Models - Models refer to the actual, low level, AI models ### model.json (i.e. `Modelfiles`) - A `ModelFile` is a specific snapshot of "a model's settings" - `ModelFiles` follow Go Workspace’s conventions: - A `Model` has a default, Model-level`ModelFile` - An `Assistant` can have an Assistant-level `ModelFile`, which overrides Model-level - A `Thread` can have a Thread-level `ModelFile`, which overrides Assistant-level Open questions: - Should ModelFiles be in `dockerfile` or `json`? - Should ModelFiles have a structured format (like Ollama) or unstructured? - See below: Structured: ```json from: "./models/..." parameter: {... //unstructured params go in here} template: system: ``` Unstructured: ```json from: "./models" param_1: "" param_2: ``` ## Messages - `Message` objects contain content, `files`, and other metadata - See [OpenAI message object](https://platform.openai.com/docs/api-reference/messages) ## Threads - Root level `/threads` contain convos with Jan assistant, and other assistants by default. Reasons: - When users delete an assistant, threads should persist - In the future, we may support 1 thread, many assistants - Threads are user conversations with `assistants` - Threads contain `Messages` - `Threads` can have its own `ModelFile`: When users start a new thread with an `assistant`, they have the option of changing model settings. This creates a new Thread-based `ModelFile` - Once the user sends a `message` in a `thread`, the `thread` is **locked**: - Locked: Users cannot change the `assistant` it is talking to. - Q: should users be able to edit modelfile parameters? e.g. temp? - Threads do not contain `files` Open questions: - How do users attach docs/pdfs within a thread? See OpenAI's [message obj](https://platform.openai.com/docs/api-reference/messages/object#messages/object-file_ids) - Should we let users modify Thread's `ModelFile` after messages are already sent? I don't see why not... ## Assistants Mode 1: Typical Assistant ```sh .jan /models /threads /assistants assistants.json index.js # SDK customizations model.json /files ``` Mode 2: Assistant overrides global threads & models ```sh .jan /models /threads /assistants assistants.json # -f: using locally packaged `model`, `thread` /models # optional & overrides /threads # optional & overrides ``` - Assistants are higher-level abstractions that compose on top of `threads`, `models` - Assistants can have a `model.json` - Assistants can have a knowledge base of files - If an `Assistant` is deleted, its entire folder and child files are deleted - If an `Assistant` is deleted, the underlying `model` remains, but the Assistant-level `model.json` is deleted - [To Discuss] If an `Assistant` is deleted, its previous `threads` remain, but users cannot chat again ## Stress test: *What if 2 different assistants use the same underlying model? It seems we reference a shared file-path to the model .bin/.gguf? Where is this folder that contains the raw models?* - It would just be in ./models *What happens when a user deletes an assistant? Do we delete the model? Separately, do we delete convo history from the app?* - Only the assets in ./assistants is deleted *Is model_config the same thing as Ollama's ModelFile? What are the properties in the file? How is it different for gguf vs another model format?* - Open to discussion *What if users just want to slightly tweak the system prompt of an assistant? Do they (a) edit the existing assistant or (b) create a new assistant?* - They would create a `thread` with an `assistant`, edit the settings (Thread-level ModelFile). This MF is saved in /threads. A new assistant is not created. *How would users chat with a model "out of box"? e.g. a base-case where I want to chat with a default mistral-7bn. So do we automatically create an assistant each time users download a model? Or can users start a thread directly with models, not just assistants?* - They would chat with a `model`, using the Model-level MF. *OpenAI allows `file_id` on 2 levels: (1) in an assistant and (2) within individual messages (threads). From the md above, it do we only support the latter?* - I'd prefer to stay OAI compatible, and support file_id for both `assistant` level and `message` level. But open to discussion. ## Strategic Rationale ### Why OpenAI Compatibility - We've been struggling to define what is a `model` vs `modelfile` vs `assistant/ai/app`. During retreat, we coincidentally converged on the `Assistant API` that OpenAI released last week. Rather than reinvent the wheel, we can leverage their ERD and default to an industry standard. - OpenAI has a moat, and are becoming the industry API standard - OpenAI needs an open source alternative - we can be ActuallyOpenAI - an "escape hatch" that developers can offramp from OpenAI within xx minutes. - **Our vision remains the same** - be a Personal AI that is local and private ### Why File-based Approach - `Data service` was quite convoluted, and a bit of legacy from our previous iterations. - Devs shouldn't have to learn our database to build on Jan - VSCode & Obsidian's use of local files allows for better performance and flexibility when it comes to data storage and retrieval. Files are faster to access and more lightweight than databases, which can be slower and more resource-intensive. Additionally, files allow for more straightforward data versioning and recovery, since they can be easily backed up and restored. This moves us closer to our vision of an AI "cortical stack". - **Our strategy remains the same** - build a dev ecosystem on top of Jan. This is a critical devex improvement.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully