mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 10:45:42 +01:00
Refactor documentation architecture (#1264)
* Refactor documentation architecture Split into several `tab` and sections * Fix Fern's docs.yml after PR review Thank you Danny! Co-authored-by: dannysheridan <danny@buildwithfern.com> * Re-add quickstart in the overview tab It went missing after a refactoring of the doc architecture * Documentation writing * Adapt Makefile to fern documentation * Do not create overlapping page names in fern documentation This is causing 500. Thank you to @dsinghvi for the troubleshooting and the help! * Add a readme to help to understand how fern documentation work and how to add new pages * Rework the welcome view Redirects directly users to installation guide with links for people that are not familiar with documentation browsing. * Simplify the quickstart guide * PR feedback on installation guide A ton of refactoring can still be made there * PR feedback on ingestion * PR feedback on ingestion splitting * Rename section on LLM * Fix missing word in list of LLMs --------- Co-authored-by: dannysheridan <danny@buildwithfern.com>
This commit is contained in:
parent
57a829a8e8
commit
36f69eed0f
18 changed files with 399 additions and 151 deletions
80
fern/docs/pages/manual/configuration.mdx
Normal file
80
fern/docs/pages/manual/configuration.mdx
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# Configure your private GPT
|
||||
|
||||
The configuration of your private GPT server is done thanks to `settings` files (more precisely `settings.yaml`).
|
||||
These text files are written using the [YAML](https://en.wikipedia.org/wiki/YAML) syntax.
|
||||
|
||||
While privateGPT is distributing safe and universal configuration files, you might want to quickly customize your
|
||||
privateGPT, and this can be done using the `settings` files.
|
||||
|
||||
This project is defining the concept of **profiles** (or configuration profiles).
|
||||
This mechanism, using your environment variables, is giving you the ability to easily switch between
|
||||
configuration you've made.
|
||||
|
||||
A typical use case of profile is to easily switch between LLM and embeddings.
|
||||
To be a bit more precise, you can change the language (to French, Spanish, Italian, English, etc) by simply changing
|
||||
the profile you've selected; no code changes required!
|
||||
|
||||
PrivateGPT is configured through *profiles* that are defined using yaml files, and selected through env variables.
|
||||
The full list of properties configurable can be found in `settings.yaml`.
|
||||
|
||||
## How to know which profiles exist
|
||||
Given that a profile `foo_bar` points to the file `settings-foo_bar.yaml` and vice-versa, you simply have to look
|
||||
at the files starting with `settings` and ending in `.yaml`.
|
||||
|
||||
## How to use an existing profiles
|
||||
**Please note that the syntax to set the value of an environment variables depends on your OS**.
|
||||
You have to set environment variable `PGPT_PROFILES` to the name of the profile you want to use.
|
||||
|
||||
For example, on **linux and macOS**, this gives:
|
||||
```bash
|
||||
export PGPT_PROFILES=my_profile_name_here
|
||||
```
|
||||
|
||||
Windows Powershell(s) have a different syntax, one of them being:
|
||||
```shell
|
||||
set PGPT_PROFILES=my_profile_name_here
|
||||
```
|
||||
If the above is not working, you might want to try other ways to set an env variable in your window's terminal.
|
||||
|
||||
---
|
||||
|
||||
Once you've set this environment variable to the desired profile, you can simply launch your privateGPT,
|
||||
and it will run using your profile on top of the default configuration.
|
||||
|
||||
## Reference
|
||||
Additional details on the profiles are described in this section
|
||||
|
||||
### Environment variable `PGPT_SETTINGS_FOLDER`
|
||||
|
||||
The location of the settings folder. Defaults to the root of the project.
|
||||
Should contain the default `settings.yaml` and any other `settings-{profile}.yaml`.
|
||||
|
||||
### Environment variable `PGPT_PROFILES`
|
||||
|
||||
By default, the profile definition in `settings.yaml` is loaded.
|
||||
Using this env var you can load additional profiles; format is a comma separated list of profile names.
|
||||
This will merge `settings-{profile}.yaml` on top of the base settings file.
|
||||
|
||||
For example:
|
||||
`PGPT_PROFILES=local,cuda` will load `settings-local.yaml`
|
||||
and `settings-cuda.yaml`, their contents will be merged with
|
||||
later profiles properties overriding values of earlier ones like `settings.yaml`.
|
||||
|
||||
During testing, the `test` profile will be active along with the default, therefore `settings-test.yaml`
|
||||
file is required.
|
||||
|
||||
### Environment variables expansion
|
||||
|
||||
Configuration files can contain environment variables,
|
||||
they will be expanded at runtime.
|
||||
|
||||
Expansion must follow the pattern `${VARIABLE_NAME:default_value}`.
|
||||
|
||||
For example, the following configuration will use the value of the `PORT`
|
||||
environment variable or `8001` if it's not set.
|
||||
Missing variables with no default will produce an error.
|
||||
|
||||
```yaml
|
||||
server:
|
||||
port: ${PORT:8001}
|
||||
```
|
||||
14
fern/docs/pages/manual/ingestion-reset.mdx
Normal file
14
fern/docs/pages/manual/ingestion-reset.mdx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Reset Local documents database
|
||||
|
||||
When running in a local setup, you can remove all ingested documents by simply
|
||||
deleting all contents of `local_data` folder (except .gitignore).
|
||||
|
||||
To simplify this process, you can use the command:
|
||||
```bash
|
||||
make wipe
|
||||
```
|
||||
|
||||
# Advanced usage
|
||||
|
||||
You can actually delete your documents from your storage by using the
|
||||
API endpoint `DELETE` in the Ingestion API.
|
||||
78
fern/docs/pages/manual/ingestion.mdx
Normal file
78
fern/docs/pages/manual/ingestion.mdx
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Ingesting & Managing Documents
|
||||
|
||||
The ingestion of documents can be done in different ways:
|
||||
|
||||
* Using the `/ingest` API
|
||||
* Using the Gradio UI
|
||||
* Using the Bulk Local Ingestion functionality (check next section)
|
||||
|
||||
## Bulk Local Ingestion
|
||||
|
||||
When you are running PrivateGPT in a fully local setup, you can ingest a complete folder for convenience (containing
|
||||
pdf, text files, etc.)
|
||||
and optionally watch changes on it with the command:
|
||||
|
||||
```bash
|
||||
make ingest /path/to/folder -- --watch
|
||||
```
|
||||
|
||||
To log the processed and failed files to an additional file, use:
|
||||
|
||||
```bash
|
||||
make ingest /path/to/folder -- --watch --log-file /path/to/log/file.log
|
||||
```
|
||||
|
||||
After ingestion is complete, you should be able to chat with your documents
|
||||
by navigating to http://localhost:8001 and using the option `Query documents`,
|
||||
or using the completions / chat API.
|
||||
|
||||
## Ingestion troubleshooting
|
||||
|
||||
Are you running out of memory when ingesting files?
|
||||
|
||||
To do not run out of memory, you should ingest your documents without the LLM loaded in your (video) memory.
|
||||
To do so, you should change your configuration to set `llm.mode: mock`.
|
||||
|
||||
In other words, you should update your `settings.yaml` (or your custom configuration file) to set the
|
||||
following **before** ingesting your documents:
|
||||
```yaml
|
||||
llm:
|
||||
mode: mock
|
||||
```
|
||||
|
||||
Once your documents are ingested, you can set the `llm.mode` value back to `local` (or your previous custom value).
|
||||
|
||||
You can also use the existing `PGPT_PROFILES=mock` that will set the `llm.mode` to `mock` for you.
|
||||
|
||||
## Supported file formats
|
||||
|
||||
privateGPT by default supports all the file formats that contains clear text (for example, `.txt` files, `.html`, etc.).
|
||||
However, these text based file formats as only considered as text files, and are not pre-processed in any other way.
|
||||
|
||||
It also supports the following file formats:
|
||||
* `.hwp`
|
||||
* `.pdf`
|
||||
* `.docx`
|
||||
* `.pptx`
|
||||
* `.ppt`
|
||||
* `.pptm`
|
||||
* `.jpg`
|
||||
* `.png`
|
||||
* `.jpeg`
|
||||
* `.mp3`
|
||||
* `.mp4`
|
||||
* `.csv`
|
||||
* `.epub`
|
||||
* `.md`
|
||||
* `.mbox`
|
||||
* `.ipynb`
|
||||
* `.json`
|
||||
|
||||
**Please note the following nuance**: while `privateGPT` supports these file formats, it **might** require additional
|
||||
dependencies to be installed in your python's virtual environment.
|
||||
For example, if you try to ingest `.epub` files, `privateGPT` might fail to do it, and will instead display an
|
||||
explanatory error asking you to download the necessary dependencies to install this file format.
|
||||
|
||||
|
||||
**Other file formats might work**, but they will be considered as plain text
|
||||
files (in other words, they will be ingested as `.txt` files).
|
||||
83
fern/docs/pages/manual/llms.mdx
Normal file
83
fern/docs/pages/manual/llms.mdx
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
## Running the Server
|
||||
|
||||
PrivateGPT supports running with different LLMs & setups.
|
||||
|
||||
### Local models
|
||||
|
||||
Both the LLM and the Embeddings model will run locally.
|
||||
|
||||
Make sure you have followed the *Local LLM requirements* section before moving on.
|
||||
|
||||
This command will start PrivateGPT using the `settings.yaml` (default profile) together with the `settings-local.yaml`
|
||||
configuration files. By default, it will enable both the API and the Gradio UI. Run:
|
||||
|
||||
```bash
|
||||
PGPT_PROFILES=local make run
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
PGPT_PROFILES=local poetry run python -m private_gpt
|
||||
```
|
||||
|
||||
When the server is started it will print a log *Application startup complete*.
|
||||
Navigate to http://localhost:8001 to use the Gradio UI or to http://localhost:8001/docs (API section) to try the API
|
||||
using Swagger UI.
|
||||
|
||||
### Using OpenAI
|
||||
|
||||
If you cannot run a local model (because you don't have a GPU, for example) or for testing purposes, you may
|
||||
decide to run PrivateGPT using OpenAI as the LLM and Embeddings model.
|
||||
|
||||
In order to do so, create a profile `settings-openai.yaml` with the following contents:
|
||||
|
||||
```yaml
|
||||
llm:
|
||||
mode: openai
|
||||
|
||||
openai:
|
||||
api_key: <your_openai_api_key> # You could skip this configuration and use the OPENAI_API_KEY env var instead
|
||||
```
|
||||
|
||||
And run PrivateGPT loading that profile you just created:
|
||||
|
||||
`PGPT_PROFILES=openai make run`
|
||||
|
||||
or
|
||||
|
||||
`PGPT_PROFILES=openai poetry run python -m private_gpt`
|
||||
|
||||
When the server is started it will print a log *Application startup complete*.
|
||||
Navigate to http://localhost:8001 to use the Gradio UI or to http://localhost:8001/docs (API section) to try the API.
|
||||
You'll notice the speed and quality of response is higher, given you are using OpenAI's servers for the heavy
|
||||
computations.
|
||||
|
||||
### Using AWS Sagemaker
|
||||
|
||||
For a fully private & performant setup, you can choose to have both your LLM and Embeddings model deployed using Sagemaker.
|
||||
|
||||
Note: how to deploy models on Sagemaker is out of the scope of this documentation.
|
||||
|
||||
In order to do so, create a profile `settings-sagemaker.yaml` with the following contents (remember to
|
||||
update the values of the llm_endpoint_name and embedding_endpoint_name to yours):
|
||||
|
||||
```yaml
|
||||
llm:
|
||||
mode: sagemaker
|
||||
|
||||
sagemaker:
|
||||
llm_endpoint_name: huggingface-pytorch-tgi-inference-2023-09-25-19-53-32-140
|
||||
embedding_endpoint_name: huggingface-pytorch-inference-2023-11-03-07-41-36-479
|
||||
```
|
||||
|
||||
And run PrivateGPT loading that profile you just created:
|
||||
|
||||
`PGPT_PROFILES=sagemaker make run`
|
||||
|
||||
or
|
||||
|
||||
`PGPT_PROFILES=sagemaker poetry run python -m private_gpt`
|
||||
|
||||
When the server is started it will print a log *Application startup complete*.
|
||||
Navigate to http://localhost:8001 to use the Gradio UI or to http://localhost:8001/docs (API section) to try the API.
|
||||
39
fern/docs/pages/manual/ui.mdx
Normal file
39
fern/docs/pages/manual/ui.mdx
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
## Gradio UI user manual
|
||||
|
||||
Gradio UI is a ready to use way of testing most of PrivateGPT API functionalities.
|
||||
|
||||

|
||||
|
||||
### Execution Modes
|
||||
|
||||
It has 3 modes of execution (you can select in the top-left):
|
||||
|
||||
* Query Docs: uses the context from the
|
||||
ingested documents to answer the questions posted in the chat. It also takes
|
||||
into account previous chat messages as context.
|
||||
* Makes use of `/chat/completions` API with `use_context=true` and no
|
||||
`context_filter`.
|
||||
* Search in Docs: fast search that returns the 4 most related text
|
||||
chunks, together with their source document and page.
|
||||
* Makes use of `/chunks` API with no `context_filter`, `limit=4` and
|
||||
`prev_next_chunks=0`.
|
||||
* LLM Chat: simple, non-contextual chat with the LLM. The ingested documents won't
|
||||
be taken into account, only the previous messages.
|
||||
* Makes use of `/chat/completions` API with `use_context=false`.
|
||||
|
||||
### Document Ingestion
|
||||
|
||||
Ingest documents by using the `Upload a File` button. You can check the progress of
|
||||
the ingestion in the console logs of the server.
|
||||
|
||||
The list of ingested files is shown below the button.
|
||||
|
||||
If you want to delete the ingested documents, refer to *Reset Local documents
|
||||
database* section in the documentation.
|
||||
|
||||
### Chat
|
||||
|
||||
Normal chat interface, self-explanatory ;)
|
||||
|
||||
You can check the actual prompt being passed to the LLM by looking at the logs of
|
||||
the server. We'll add better observability in future releases.
|
||||
30
fern/docs/pages/manual/vectordb.mdx
Normal file
30
fern/docs/pages/manual/vectordb.mdx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
## Vectorstores
|
||||
PrivateGPT supports [Chroma](https://www.trychroma.com/), [Qdrant](https://qdrant.tech/) as vectorstore providers. Chroma being the default.
|
||||
|
||||
### Qdrant configuration
|
||||
|
||||
To enable Qdrant, set the `vectorstore.database` property in the `settings.yaml` file to `qdrant` and install the `qdrant` extra.
|
||||
|
||||
```bash
|
||||
poetry install --extras qdrant
|
||||
```
|
||||
|
||||
By default Qdrant tries to connect to an instance at `http://localhost:3000`.
|
||||
|
||||
Qdrant settings can be configured by setting values to the `qdrant` property in the `settings.yaml` file.
|
||||
|
||||
The available configuration options are:
|
||||
| Field | Description |
|
||||
|--------------|-------------|
|
||||
| location | If `:memory:` - use in-memory Qdrant instance. If `str` - use it as a `url` parameter.|
|
||||
| url | Either host or str of 'Optional[scheme], host, Optional[port], Optional[prefix]'. Eg. `http://localhost:6333` |
|
||||
| port | Port of the REST API interface. Default: `6333` |
|
||||
| grpc_port | Port of the gRPC interface. Default: `6334` |
|
||||
| prefer_grpc | If `true` - use gRPC interface whenever possible in custom methods. |
|
||||
| https | If `true` - use HTTPS(SSL) protocol.|
|
||||
| api_key | API key for authentication in Qdrant Cloud.|
|
||||
| prefix | If set, add `prefix` to the REST URL path. Example: `service/v1` will result in `http://localhost:6333/service/v1/{qdrant-endpoint}` for REST API.|
|
||||
| timeout | Timeout for REST and gRPC API requests. Default: 5.0 seconds for REST and unlimited for gRPC |
|
||||
| host | Host name of Qdrant service. If url and host are not set, defaults to 'localhost'.|
|
||||
| path | Persistence path for QdrantLocal. Eg. `local_data/private_gpt/qdrant`|
|
||||
| force_disable_check_same_thread | Force disable check_same_thread for QdrantLocal sqlite connection, defaults to True.|
|
||||
Loading…
Add table
Add a link
Reference in a new issue