From e34b5f0119f717d5af83e878f4ee91fb77110ad0 Mon Sep 17 00:00:00 2001 From: James Braza Date: Mon, 2 Oct 2023 09:14:10 -0700 Subject: [PATCH] Cleaning up `examples/` models and starter `.env` files (#1124) Closes https://github.com/go-skynet/LocalAI/issues/1066 and https://github.com/go-skynet/LocalAI/issues/1065 Standardizes all `examples/`: - Models in one place (other than `rwkv`, which was one-offy) - Env files as `.env.example` with `cp` - Also standardizes comments and links docs --- examples/autoGPT/{.env => .env.example} | 8 ++++++-- examples/autoGPT/README.md | 6 +++++- examples/chatbot-ui-manual/models | 1 + examples/discord-bot/.env.example | 3 +++ examples/discord-bot/models | 2 +- examples/functions/{.env => .env.example} | 6 +++++- examples/functions/README.md | 7 +++++-- examples/langchain-chroma/.env.example | 3 +++ examples/langchain-chroma/models | 1 + .../langchain-chroma/models/completion.tmpl | 1 - .../langchain-chroma/models/gpt-3.5-turbo.yaml | 16 ---------------- examples/langchain-chroma/models/gpt4all.tmpl | 4 ---- examples/langchain-huggingface/models | 1 + .../models/completion.tmpl | 1 - .../models/gpt-3.5-turbo.yaml | 17 ----------------- .../langchain-huggingface/models/gpt4all.tmpl | 4 ---- examples/langchain/models | 1 + examples/langchain/models/completion.tmpl | 1 - examples/langchain/models/gpt-3.5-turbo.yaml | 17 ----------------- examples/langchain/models/gpt4all.tmpl | 4 ---- examples/localai-webui/docker-compose.yml | 2 -- examples/models/.gitignore | 7 +++++++ .../models/completion.tmpl | 0 .../models/embeddings.yaml | 0 .../models/gpt-3.5-turbo.yaml | 0 .../{chatbot-ui-manual => }/models/gpt4all.tmpl | 0 examples/query_data/models | 1 + examples/query_data/models/completion.tmpl | 1 - examples/query_data/models/embeddings.yaml | 6 ------ examples/query_data/models/gpt-3.5-turbo.yaml | 16 ---------------- examples/slack-bot/.env.example | 3 +++ examples/slack-bot/README.md | 2 +- examples/slack-bot/models | 2 +- examples/slack-qa-bot/.env.example | 3 +++ 34 files changed, 48 insertions(+), 99 deletions(-) rename examples/autoGPT/{.env => .env.example} (60%) create mode 120000 examples/chatbot-ui-manual/models rename examples/functions/{.env => .env.example} (59%) create mode 120000 examples/langchain-chroma/models delete mode 100644 examples/langchain-chroma/models/completion.tmpl delete mode 100644 examples/langchain-chroma/models/gpt-3.5-turbo.yaml delete mode 100644 examples/langchain-chroma/models/gpt4all.tmpl create mode 120000 examples/langchain-huggingface/models delete mode 100644 examples/langchain-huggingface/models/completion.tmpl delete mode 100644 examples/langchain-huggingface/models/gpt-3.5-turbo.yaml delete mode 100644 examples/langchain-huggingface/models/gpt4all.tmpl create mode 120000 examples/langchain/models delete mode 100644 examples/langchain/models/completion.tmpl delete mode 100644 examples/langchain/models/gpt-3.5-turbo.yaml delete mode 100644 examples/langchain/models/gpt4all.tmpl create mode 100644 examples/models/.gitignore rename examples/{chatbot-ui-manual => }/models/completion.tmpl (100%) rename examples/{langchain-chroma => }/models/embeddings.yaml (100%) rename examples/{chatbot-ui-manual => }/models/gpt-3.5-turbo.yaml (100%) rename examples/{chatbot-ui-manual => }/models/gpt4all.tmpl (100%) create mode 120000 examples/query_data/models delete mode 100644 examples/query_data/models/completion.tmpl delete mode 100644 examples/query_data/models/embeddings.yaml delete mode 100644 examples/query_data/models/gpt-3.5-turbo.yaml diff --git a/examples/autoGPT/.env b/examples/autoGPT/.env.example similarity index 60% rename from examples/autoGPT/.env rename to examples/autoGPT/.env.example index ca0e93e3..df5cc0c3 100644 --- a/examples/autoGPT/.env +++ b/examples/autoGPT/.env.example @@ -1,5 +1,9 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + OPENAI_API_KEY=sk---anystringhere OPENAI_API_BASE=http://api:8080/v1 # Models to preload at start -# Here we configure gpt4all as gpt-3.5-turbo and bert as embeddings -PRELOAD_MODELS=[{"url": "github:go-skynet/model-gallery/gpt4all-j.yaml", "name": "gpt-3.5-turbo"}, { "url": "github:go-skynet/model-gallery/bert-embeddings.yaml", "name": "text-embedding-ada-002"}] \ No newline at end of file +# Here we configure gpt4all as gpt-3.5-turbo and bert as embeddings, +# see other options in the model gallery at https://github.com/go-skynet/model-gallery +PRELOAD_MODELS=[{"url": "github:go-skynet/model-gallery/gpt4all-j.yaml", "name": "gpt-3.5-turbo"}, { "url": "github:go-skynet/model-gallery/bert-embeddings.yaml", "name": "text-embedding-ada-002"}] diff --git a/examples/autoGPT/README.md b/examples/autoGPT/README.md index f5269a3a..32793606 100644 --- a/examples/autoGPT/README.md +++ b/examples/autoGPT/README.md @@ -10,12 +10,16 @@ git clone https://github.com/go-skynet/LocalAI cd LocalAI/examples/autoGPT +cp -rfv .env.example .env + +# Edit the .env file to set a different model by editing `PRELOAD_MODELS`. +vim .env + docker-compose run --rm auto-gpt ``` Note: The example automatically downloads the `gpt4all` model as it is under a permissive license. The GPT4All model does not seem to be enough to run AutoGPT. WizardLM-7b-uncensored seems to perform better (with `f16: true`). -See the `.env` configuration file to set a different model with the [model-gallery](https://github.com/go-skynet/model-gallery) by editing `PRELOAD_MODELS`. ## Without docker diff --git a/examples/chatbot-ui-manual/models b/examples/chatbot-ui-manual/models new file mode 120000 index 00000000..1e266b1b --- /dev/null +++ b/examples/chatbot-ui-manual/models @@ -0,0 +1 @@ +../models \ No newline at end of file diff --git a/examples/discord-bot/.env.example b/examples/discord-bot/.env.example index 7f94e673..332a71b7 100644 --- a/examples/discord-bot/.env.example +++ b/examples/discord-bot/.env.example @@ -1,3 +1,6 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + OPENAI_API_KEY=x DISCORD_BOT_TOKEN=x DISCORD_CLIENT_ID=x diff --git a/examples/discord-bot/models b/examples/discord-bot/models index 7055d2b8..1e266b1b 120000 --- a/examples/discord-bot/models +++ b/examples/discord-bot/models @@ -1 +1 @@ -../chatbot-ui/models/ \ No newline at end of file +../models \ No newline at end of file diff --git a/examples/functions/.env b/examples/functions/.env.example similarity index 59% rename from examples/functions/.env rename to examples/functions/.env.example index 8dcea057..8abf0d15 100644 --- a/examples/functions/.env +++ b/examples/functions/.env.example @@ -1,7 +1,11 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + OPENAI_API_KEY=sk---anystringhere OPENAI_API_BASE=http://api:8080/v1 # Models to preload at start -# Here we configure gpt4all as gpt-3.5-turbo and bert as embeddings +# Here we configure gpt4all as gpt-3.5-turbo and bert as embeddings, +# see other options in the model gallery at https://github.com/go-skynet/model-gallery PRELOAD_MODELS=[{"url": "github:go-skynet/model-gallery/openllama-7b-open-instruct.yaml", "name": "gpt-3.5-turbo"}] ## Change the default number of threads diff --git a/examples/functions/README.md b/examples/functions/README.md index 8bd4cf5d..80f44659 100644 --- a/examples/functions/README.md +++ b/examples/functions/README.md @@ -10,9 +10,12 @@ git clone https://github.com/go-skynet/LocalAI cd LocalAI/examples/functions +cp -rfv .env.example .env + +# Edit the .env file to set a different model by editing `PRELOAD_MODELS`. +vim .env + docker-compose run --rm functions ``` Note: The example automatically downloads the `openllama` model as it is under a permissive license. - -See the `.env` configuration file to set a different model with the [model-gallery](https://github.com/go-skynet/model-gallery) by editing `PRELOAD_MODELS`. diff --git a/examples/langchain-chroma/.env.example b/examples/langchain-chroma/.env.example index 37cda598..54388e31 100644 --- a/examples/langchain-chroma/.env.example +++ b/examples/langchain-chroma/.env.example @@ -1,3 +1,6 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + THREADS=4 CONTEXT_SIZE=512 MODELS_PATH=/models diff --git a/examples/langchain-chroma/models b/examples/langchain-chroma/models new file mode 120000 index 00000000..1e266b1b --- /dev/null +++ b/examples/langchain-chroma/models @@ -0,0 +1 @@ +../models \ No newline at end of file diff --git a/examples/langchain-chroma/models/completion.tmpl b/examples/langchain-chroma/models/completion.tmpl deleted file mode 100644 index 9867cfcd..00000000 --- a/examples/langchain-chroma/models/completion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{.Input}} \ No newline at end of file diff --git a/examples/langchain-chroma/models/gpt-3.5-turbo.yaml b/examples/langchain-chroma/models/gpt-3.5-turbo.yaml deleted file mode 100644 index 5c192f5d..00000000 --- a/examples/langchain-chroma/models/gpt-3.5-turbo.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: gpt-3.5-turbo -parameters: - model: ggml-gpt4all-j - top_k: 80 - temperature: 0.2 - top_p: 0.7 -context_size: 1024 -stopwords: -- "HUMAN:" -- "GPT:" -roles: - user: " " - system: " " -template: - completion: completion - chat: gpt4all \ No newline at end of file diff --git a/examples/langchain-chroma/models/gpt4all.tmpl b/examples/langchain-chroma/models/gpt4all.tmpl deleted file mode 100644 index f76b080a..00000000 --- a/examples/langchain-chroma/models/gpt4all.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -The prompt below is a question to answer, a task to complete, or a conversation to respond to; decide which and write an appropriate response. -### Prompt: -{{.Input}} -### Response: diff --git a/examples/langchain-huggingface/models b/examples/langchain-huggingface/models new file mode 120000 index 00000000..1e266b1b --- /dev/null +++ b/examples/langchain-huggingface/models @@ -0,0 +1 @@ +../models \ No newline at end of file diff --git a/examples/langchain-huggingface/models/completion.tmpl b/examples/langchain-huggingface/models/completion.tmpl deleted file mode 100644 index 1e04a465..00000000 --- a/examples/langchain-huggingface/models/completion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{.Input}} diff --git a/examples/langchain-huggingface/models/gpt-3.5-turbo.yaml b/examples/langchain-huggingface/models/gpt-3.5-turbo.yaml deleted file mode 100644 index 76e9ab18..00000000 --- a/examples/langchain-huggingface/models/gpt-3.5-turbo.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: gpt-3.5-turbo -parameters: - model: gpt2 - top_k: 80 - temperature: 0.2 - top_p: 0.7 -context_size: 1024 -backend: "langchain-huggingface" -stopwords: -- "HUMAN:" -- "GPT:" -roles: - user: " " - system: " " -template: - completion: completion - chat: gpt4all diff --git a/examples/langchain-huggingface/models/gpt4all.tmpl b/examples/langchain-huggingface/models/gpt4all.tmpl deleted file mode 100644 index f76b080a..00000000 --- a/examples/langchain-huggingface/models/gpt4all.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -The prompt below is a question to answer, a task to complete, or a conversation to respond to; decide which and write an appropriate response. -### Prompt: -{{.Input}} -### Response: diff --git a/examples/langchain/models b/examples/langchain/models new file mode 120000 index 00000000..1e266b1b --- /dev/null +++ b/examples/langchain/models @@ -0,0 +1 @@ +../models \ No newline at end of file diff --git a/examples/langchain/models/completion.tmpl b/examples/langchain/models/completion.tmpl deleted file mode 100644 index 9867cfcd..00000000 --- a/examples/langchain/models/completion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{.Input}} \ No newline at end of file diff --git a/examples/langchain/models/gpt-3.5-turbo.yaml b/examples/langchain/models/gpt-3.5-turbo.yaml deleted file mode 100644 index ea894fb9..00000000 --- a/examples/langchain/models/gpt-3.5-turbo.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: gpt-3.5-turbo -parameters: - model: ggml-gpt4all-j # ggml-koala-13B-4bit-128g - top_k: 80 - temperature: 0.2 - top_p: 0.7 -context_size: 1024 -stopwords: -- "HUMAN:" -- "GPT:" -roles: - user: " " - system: " " -backend: "gptj" -template: - completion: completion - chat: gpt4all \ No newline at end of file diff --git a/examples/langchain/models/gpt4all.tmpl b/examples/langchain/models/gpt4all.tmpl deleted file mode 100644 index f76b080a..00000000 --- a/examples/langchain/models/gpt4all.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -The prompt below is a question to answer, a task to complete, or a conversation to respond to; decide which and write an appropriate response. -### Prompt: -{{.Input}} -### Response: diff --git a/examples/localai-webui/docker-compose.yml b/examples/localai-webui/docker-compose.yml index a40bc395..1609f604 100644 --- a/examples/localai-webui/docker-compose.yml +++ b/examples/localai-webui/docker-compose.yml @@ -8,8 +8,6 @@ services: dockerfile: Dockerfile ports: - 8080:8080 - env_file: - - .env volumes: - ./models:/models:cached command: ["/usr/bin/local-ai"] diff --git a/examples/models/.gitignore b/examples/models/.gitignore new file mode 100644 index 00000000..9237b97c --- /dev/null +++ b/examples/models/.gitignore @@ -0,0 +1,7 @@ +# Ignore everything but predefined models +* +!.gitignore +!completion.tmpl +!embeddings.yaml +!gpt4all.tmpl +!gpt-3.5-turbo.yaml diff --git a/examples/chatbot-ui-manual/models/completion.tmpl b/examples/models/completion.tmpl similarity index 100% rename from examples/chatbot-ui-manual/models/completion.tmpl rename to examples/models/completion.tmpl diff --git a/examples/langchain-chroma/models/embeddings.yaml b/examples/models/embeddings.yaml similarity index 100% rename from examples/langchain-chroma/models/embeddings.yaml rename to examples/models/embeddings.yaml diff --git a/examples/chatbot-ui-manual/models/gpt-3.5-turbo.yaml b/examples/models/gpt-3.5-turbo.yaml similarity index 100% rename from examples/chatbot-ui-manual/models/gpt-3.5-turbo.yaml rename to examples/models/gpt-3.5-turbo.yaml diff --git a/examples/chatbot-ui-manual/models/gpt4all.tmpl b/examples/models/gpt4all.tmpl similarity index 100% rename from examples/chatbot-ui-manual/models/gpt4all.tmpl rename to examples/models/gpt4all.tmpl diff --git a/examples/query_data/models b/examples/query_data/models new file mode 120000 index 00000000..1e266b1b --- /dev/null +++ b/examples/query_data/models @@ -0,0 +1 @@ +../models \ No newline at end of file diff --git a/examples/query_data/models/completion.tmpl b/examples/query_data/models/completion.tmpl deleted file mode 100644 index 9867cfcd..00000000 --- a/examples/query_data/models/completion.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{.Input}} \ No newline at end of file diff --git a/examples/query_data/models/embeddings.yaml b/examples/query_data/models/embeddings.yaml deleted file mode 100644 index b90ca75a..00000000 --- a/examples/query_data/models/embeddings.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: text-embedding-ada-002 -parameters: - model: bert -threads: 14 -backend: bert-embeddings -embeddings: true diff --git a/examples/query_data/models/gpt-3.5-turbo.yaml b/examples/query_data/models/gpt-3.5-turbo.yaml deleted file mode 100644 index 5c192f5d..00000000 --- a/examples/query_data/models/gpt-3.5-turbo.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: gpt-3.5-turbo -parameters: - model: ggml-gpt4all-j - top_k: 80 - temperature: 0.2 - top_p: 0.7 -context_size: 1024 -stopwords: -- "HUMAN:" -- "GPT:" -roles: - user: " " - system: " " -template: - completion: completion - chat: gpt4all \ No newline at end of file diff --git a/examples/slack-bot/.env.example b/examples/slack-bot/.env.example index d4fe401b..e169e0cf 100644 --- a/examples/slack-bot/.env.example +++ b/examples/slack-bot/.env.example @@ -1,3 +1,6 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + SLACK_APP_TOKEN=xapp-1-... SLACK_BOT_TOKEN=xoxb-... OPENAI_API_KEY=sk-... diff --git a/examples/slack-bot/README.md b/examples/slack-bot/README.md index 9c9f10f1..23a5c884 100644 --- a/examples/slack-bot/README.md +++ b/examples/slack-bot/README.md @@ -18,7 +18,7 @@ git clone https://github.com/seratch/ChatGPT-in-Slack # Download gpt4all-j to models/ wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j -# Set the discord bot options (see: https://github.com/seratch/ChatGPT-in-Slack) +# Set the Slack bot options (see: https://github.com/seratch/ChatGPT-in-Slack) cp -rfv .env.example .env vim .env diff --git a/examples/slack-bot/models b/examples/slack-bot/models index 9c5c2aaf..1e266b1b 120000 --- a/examples/slack-bot/models +++ b/examples/slack-bot/models @@ -1 +1 @@ -../chatbot-ui/models \ No newline at end of file +../models \ No newline at end of file diff --git a/examples/slack-qa-bot/.env.example b/examples/slack-qa-bot/.env.example index 72937b9c..29c68dde 100644 --- a/examples/slack-qa-bot/.env.example +++ b/examples/slack-qa-bot/.env.example @@ -1,3 +1,6 @@ +# CPU .env docs: https://localai.io/howtos/easy-setup-docker-cpu/ +# GPU .env docs: https://localai.io/howtos/easy-setup-docker-gpu/ + # Create an app-level token with connections:write scope SLACK_APP_TOKEN=xapp-1-... # Install the app into your workspace to grab this token