Skip to content

Commit

Permalink
Merge branch 'enricoros:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
icratech authored Feb 22, 2024
2 parents f331338 + f560272 commit b407a02
Show file tree
Hide file tree
Showing 23 changed files with 426 additions and 180 deletions.
73 changes: 50 additions & 23 deletions docs/config-local-localai.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
# Local LLM integration with `localai`
# Run your models with `LocalAI` x `big-AGI`

Integrate local Large Language Models (LLMs) with [LocalAI](https://localai.io).
[LocalAI](https://localai.io) lets you run your AI models locally, or in the cloud. It supports text, image, asr, speech, and more models.

_Last updated Nov 7, 2023_
We are deepening the integration between the two products. As of the time of writing, we integrate the following features:

## Instructions
-[Text generation](https://localai.io/features/text-generation/) with GPTs
-[Function calling](https://localai.io/features/openai-functions/) by GPTs 🆕
-[Model Gallery](https://localai.io/models/) to list and install models
- ✖️ [Vision API](https://localai.io/features/gpt-vision/) for image chats
- ✖️ [Image generation](https://localai.io/features/image-generation) with stable diffusion
- ✖️ [Audio to Text](https://localai.io/features/audio-to-text/)
- ✖️ [Text to Audio](https://localai.io/features/text-to-audio/)
- ✖️ [Embeddings generation](https://localai.io/features/embeddings/)
- ✖️ [Constrained grammars](https://localai.io/features/constrained_grammars/) (JSON output)
- ✖️ Voice cloning 🆕

_Last updated Feb 21, 2024_

## Guide

### LocalAI installation and configuration

Follow the guide at: https://localai.io/basics/getting_started/

For instance with [Use luna-ai-llama2 with docker compose](https://localai.io/basics/getting_started/#example-use-luna-ai-llama2-model-with-docker-compose):

- clone LocalAI
- get the model
- copy the prompt template
- start docker
- -> the server will be listening on `localhost:8080`
- verify it works by going to [http://localhost:8080/v1/models](http://localhost:8080/v1/models) on
your browser and seeing listed the model you downloaded
- verify it works by browsing to [http://localhost:8080/v1/models](http://localhost:8080/v1/models)
(or the IP:Port of the machine, if running remotely) and seeing listed the model(s) you downloaded
listed in the JSON response.

### Integrating LocalAI with big-AGI
### Integration: chat with LocalAI

- Go to Models > Add a model source of type: **LocalAI**
- Enter the address: `http://localhost:8080` (default)
- If running remotely, replace localhost with the IP of the machine. Make sure to use the **IP:Port** format
- Load the models
- Select model & Chat

> NOTE: LocalAI does not list details about the mdoels. Every model is assumed to be
> capable of chatting, and with a context window of 4096 tokens.
> Please update the [src/modules/llms/transports/server/openai/models.data.ts](../src/modules/llms/server/openai/models.data.ts)
> file with the mapping information between LocalAI model IDs and names/descriptions/tokens, etc.
- Enter the default address: `http://localhost:8080`, or the address of your localAI cloud instance
![configure models](pixels/config-localai-1-models.png)
- If running remotely, replace localhost with the IP of the machine. Make sure to use the **IP:Port** format
- Load the models (click on `Models 🔄`)
- Select the model and chat

### Integration: Models Gallery

If the running LocalAI instance is configured with a [Model Gallery](https://localai.io/models/):

- Go to Models > LocalAI
- Click on `Gallery Admin`
- Select the models to install, and view installation progress
![img.png](pixels/config-localai-2-gallery.png)

## Troubleshooting

##### Unknown Context Window Size

At the time of writing, LocalAI does not publish the model `context window size`.
Every model is assumed to be capable of chatting, and with a context window of 4096 tokens.
Please update the [src/modules/llms/transports/server/openai/models.data.ts](../src/modules/llms/server/openai/models.data.ts)
file with the mapping information between LocalAI model IDs and names/descriptions/tokens, etc.

# 🤝 Support

- Hop into the [LocalAI Discord](https://discord.gg/uJAeKSAGDy) for support and questions
- Hop into the [big-AGI Discord](https://discord.gg/MkH4qj2Jp9) for questions
- For big-AGI support, please open an issue in our [big-AGI issue tracker](https://bit.ly/agi-request)
Binary file added docs/pixels/config-localai-1-models.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pixels/config-localai-2-gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 14 additions & 10 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
const BuildOptions = {
standalone: !!process.env.BUILD_STANDALONE,
};
// Non-default build types
const buildType =
process.env.BIG_AGI_BUILD === 'standalone' ? 'standalone'
: process.env.BIG_AGI_BUILD === 'static' ? 'export'
: undefined;

buildType && console.log(` 🧠 big-AGI: building for ${buildType}...\n`);

/** @type {import('next').NextConfig} */
let nextConfig = {
reactStrictMode: true,

// [exporting] https://nextjs.org/docs/advanced-features/static-html-export
...BuildOptions.standalone && {
// Export the frontend to ./dist
output: 'standalone',
// [exports] https://nextjs.org/docs/advanced-features/static-html-export
...buildType && {
output: buildType,
distDir: 'dist',

// Disable Image optimization
// disable image optimization for exports
images: { unoptimized: true },

// Optional: Change links `/me` -> `/me/` and emit `/me.html` -> `/me/index.html`
Expand All @@ -34,8 +37,9 @@ let nextConfig = {
layers: true,
};

// [exporting] prevent too many small files (50kb)
BuildOptions.standalone && (config.optimization.splitChunks.minSize = 50 * 1024);
// prevent too many small chunks (40kb min) on 'client' packs (not 'server' or 'edge-server')
if (typeof config.optimization.splitChunks === 'object' && config.optimization.splitChunks.minSize)
config.optimization.splitChunks.minSize = 40 * 1024;

return config;
},
Expand Down
Loading

1 comment on commit b407a02

@vercel
Copy link

@vercel vercel bot commented on b407a02 Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.