Skip to main content

AI, Inside your Editor.

Project description

uniteai

Interact with local/cloud AIs via the editor you already use, directly inside the document you're editing.

This is driven from a python backend, and therefore highly extensible. A key goal is to make this code simple, robust, and contributor-friendly, and to expand it to solving everything that's worth solving via this type of interface.

Please consider adding to ./contributions, make a PR against the main library, add a .todo/042_my_feature.md, or make an Issue with your cool concept.

AI You
Knows what you want
Doesn't hallucinate
Knows a ton
Thinks super fast
Easy to automate tasks
Supported in uniteai

The Vision

For those of us who wish, our interface with technology will increasingly be augmented/mediated by AI.

We'll create code/books/emails/content/work-outputs via collaborating with AI.

We'll manage tasks/processes via help from AI.

We'll learn and explore via collaborating with AI.

We'll seek entertainment value from interacting with an AI.

What does the ideal interface look like?

This project seeks to answer that.

Screencast Demo

screencast.webm

Capabilities

Features
local voice-to-text
local LLM (eg Falcon)
ChatGPT & GPT API
Works via standard LSP
Only enable features you want
Future
Document retrieval & Embedding Indexing _
Prompt engineering / Assistants _
Write-ahead for tab-completion _
Contextualized on your files, repo, email, etc. _
Contextualized on multiple highlighted regions _
Editors
emacs
vscode _
vim _
jetbrains _
atom _
Meta
contrib dir for community contributions
well documented
robust simple code

Setup

Setup code is crazy simple (see: doc/example_lsp_mode_config.el), but I only use emacs (on ubuntu), and would love some help for the other environments.

Emacs

1. Setup

git clone git@github.com:freckletonj/uniteai
cd uniteai/
pip install -r requirements.txt
sudo apt install portaudio19-dev  # if you want transcription

2. Setup emacs's init.el

3. Optional: Run the local LLM server

uvicorn llm_server:app --port 8000

This reads your .uniteai.yml configuration (example is in the repo) to find a Transformers-compatible model, eg Falcon, and will run it.

I imagine if you point at the dir of any Transformers-compatible model, this should work.

4. Give it a go.

Keycombos

Your client configuration determines this, so if you are using the example client config examples in ./doc:

Keycombo Effect
M-' Show Code Actions Menu
C-c l g Send region to GPT, stream output to text buffer
C-c l c Same, but ChatGPT
C-c l l Same, but local (eg Falcon) model
C-c l v Start transcribing from microphone
C-c l s Whatevers streaming, stop it

vscode

Accepting contributions. See .doc/ for examples in other editors, it's quite simple.

vim

Accepting contributions. See .doc/ for examples in other editors, it's quite simple.

jetbrains

Accepting contributions. See .doc/ for examples in other editors, it's quite simple.

atom

Accepting contributions. See .doc/ for examples in other editors, it's quite simple.

Misc

TODO

See ./todo/README.md.

At a high level:

  • support other editors
  • add cool features

Notes on Local LLMs

The file ./llm_server.py launches a TCP server in which the LLM weights are booted up. The lsp_server will make calls to this llm_server.

The reason is that the lsp_server lifecycle is (generally*) managed by the text editor, and LLM features can be really slow to boot up. Especially if you're developing a feature, you do not want the LLM to keep being read into your GPU each time you restart the lsp_server.

* you don't have to let the editor manage the lsp_server. For instance, eglot in emacs allows you to launch it yourself, and then the editor client can just bind to the port.

Falcon LLM Issue:

If Falcon runs on multiple threads, its cache has an issue. You need a separate modelling_RW.py that makes sure it never tries to cache. https://github.com/h2oai/h2ogpt/pull/297

Replacing cos_sim with this seems to do the trick:

def cos_sin(
    self,
    seq_len: int,
    device="cuda",
    dtype=torch.bfloat16,
) -> torch.Tensor:
    t = torch.arange(seq_len, device=device).type_as(self.inv_freq)
    freqs = torch.einsum("i,j->ij", t, self.inv_freq)
    emb = torch.cat((freqs, freqs), dim=-1).to(device)

    if dtype in [torch.float16, torch.bfloat16]:
        emb = emb.float()

    cos_cached = emb.cos()[None, :, :]
    sin_cached = emb.sin()[None, :, :]

    cos_cached = cos_cached.type(dtype)
    sin_cached = sin_cached.type(dtype)

    return cos_cached, sin_cached

A separate bitsandbytes issue remains unresolved, but is less serious than the above. https://github.com/h2oai/h2ogpt/issues/104 https://github.com/TimDettmers/bitsandbytes/issues/162

License

Copyright (c) Josh Freckleton. All rights reserved.

Licensed under the Apache-2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uniteai-0.1.3.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uniteai-0.1.3-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file uniteai-0.1.3.tar.gz.

File metadata

  • Download URL: uniteai-0.1.3.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for uniteai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9dd46a89f5d1b1d5d4f57f11367ca04fa6e58a9b53d7a3fbcb6ca634154c1cad
MD5 7c3c895bca0129b52114c2175d46f3d9
BLAKE2b-256 e95bc452f8a7349ee578cd9879ad079aef87ae51c54b4f506847a88f77d5e1df

See more details on using hashes here.

File details

Details for the file uniteai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: uniteai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for uniteai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 07bb7f6e0ee8842ecc7f36452511ed60778cb1c96bd41354f5e99b515a6869bf
MD5 8fad5debeca745b33e116470d5316269
BLAKE2b-256 a4f87d9192571baa0f11593feb0cd92d02d97a40b08fd3189cc00089451b24e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page