Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: prepare 0.3 release notes #404

Merged
merged 11 commits into from
Dec 5, 2024
16 changes: 8 additions & 8 deletions backend/app/rag/embed_model_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class EmbeddingModelOption(BaseModel):
provider_description="The OpenAI API provides a simple interface for developers to create an intelligence layer in their applications, powered by OpenAI's state of the art models.",
provider_url="https://platform.openai.com",
default_embedding_model="text-embedding-3-small",
embedding_model_description=f"Please select a text embedding model with {settings.EMBEDDING_DIMS} dimensions.",
embedding_model_description=f"Find more information about OpenAI Embedding at https://platform.openai.com/docs/guides/embeddings",
credentials_display_name="OpenAI API Key",
credentials_description="The API key of OpenAI, you can find it in https://platform.openai.com/api-keys",
credentials_type="str",
default_credentials="sk-****",
),
EmbeddingModelOption(
provider=EmbeddingProvider.JINA,
provider_display_name="Jina",
provider_display_name="JinaAI",
provider_description="Jina AI provides multimodal, bilingual long-context embeddings for search and RAG",
provider_url="https://jina.ai/embeddings/",
default_embedding_model="jina-embeddings-v2-base-en",
embedding_model_description=f"Find more information about Jina AI Embeddings at https://jina.ai/embeddings/, we need a model with {settings.EMBEDDING_DIMS} dimensions.",
embedding_model_description=f"Find more information about Jina AI Embeddings at https://jina.ai/embeddings/",
credentials_display_name="Jina API Key",
credentials_description="The API key of Jina, you can find it in https://jina.ai/embeddings/",
credentials_type="str",
Expand All @@ -51,7 +51,7 @@ class EmbeddingModelOption(BaseModel):
provider_description="Cohere provides industry-leading large language models (LLMs) and RAG capabilities tailored to meet the needs of enterprise use cases that solve real-world problems.",
provider_url="https://cohere.com/embeddings",
default_embedding_model="embed-multilingual-v3.0",
embedding_model_description=f"Documentation: https://docs.cohere.com/docs/cohere-embed, we need a model with {settings.EMBEDDING_DIMS} dimensions.",
embedding_model_description=f"Documentation: https://docs.cohere.com/docs/cohere-embed",
credentials_display_name="Cohere API Key",
credentials_description="You can get one from https://dashboard.cohere.com/api-keys",
credentials_type="str",
Expand All @@ -63,7 +63,7 @@ class EmbeddingModelOption(BaseModel):
provider_description="Ollama is a lightweight framework for building and running large language models and embed models.",
provider_url="https://ollama.com",
default_embedding_model="nomic-embed-text",
embedding_model_description=f"https://ollama.com/blog/embedding-models, we need a model with {settings.EMBEDDING_DIMS} dimensions.",
embedding_model_description=f"Documentation: https://ollama.com/blog/embedding-models",
default_config={
"api_base": "http://localhost:11434",
},
Expand All @@ -76,13 +76,13 @@ class EmbeddingModelOption(BaseModel):
EmbeddingModelOption(
provider=EmbeddingProvider.LOCAL,
provider_display_name="Local Embedding",
provider_description="TIDB.AI's local embedding server, deployed on your own infrastructure and powered by sentence-transformers.",
provider_description="Autoflow's local embedding server, deployed on your own infrastructure and powered by sentence-transformers.",
default_embedding_model="BAAI/bge-m3",
embedding_model_description="Find more models in huggingface.",
default_config={
"api_url": "http://local-embedding-reranker:5001/api/v1/embedding",
},
config_description="api_url is the url of the tidb ai local embedding server.",
config_description="api_url is the embedding endpoint url serviced by the autoflow local embedding server.",
credentials_display_name="Local Embedding API Key",
credentials_description="Local Embedding server doesn't require an API key, set a dummy string here is ok.",
credentials_type="str",
Expand All @@ -94,7 +94,7 @@ class EmbeddingModelOption(BaseModel):
provider_description="OpenAI-Like is a set of platforms that provide text embeddings similar to OpenAI. Such as ZhiPuAI.",
provider_url="https://open.bigmodel.cn/dev/api/vector/embedding-3",
default_embedding_model="embedding-3",
embedding_model_description=f"Please select a text embedding model with {settings.EMBEDDING_DIMS} dimensions.",
embedding_model_description="",
credentials_display_name="OpenAI Like API Key",
credentials_description="The API key of OpenAI Like. For ZhipuAI, you can find it in https://open.bigmodel.cn/usercenter/apikeys",
credentials_type="str",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function NewKnowledgeBaseDataSourcePage ({ params }: { params: {
<>
<AdminPageHeading
breadcrumbs={[
{ title: 'Knowledge Bases', url: '/knowledge-bases' },
{ title: 'Knowledge Bases', url: '/knowledge-bases', docsUrl: '/docs/knowledge-base' },
{ title: knowledgeBase?.name ?? <Loader2Icon className="size-4 animate-spin repeat-infinite" />, url: `/knowledge-bases/${id}` },
{ title: 'DataSources', url: `/knowledge-bases/${id}/data-sources` },
{ title: 'New' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function DocumentChunksPage ({ params }: { params: { id: string,
<>
<AdminPageHeading
breadcrumbs={[
{ title: 'Knowledge Bases', url: '/knowledge-bases' },
{ title: 'Knowledge Bases', url: '/knowledge-bases', docsUrl: '/docs/knowledge-base' },
{ title: knowledgeBase?.name ?? <Loader2Icon className="size-4 animate-spin repeat-infinite" />, url: `/knowledge-bases/${kbId}` },
{ title: document?.name ?? <Loader2Icon className="size-4 animate-spin repeat-infinite" /> },
{ title: 'Chunks' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function KnowledgeBaseLayout ({ params, children }: { params: { i
<>
<AdminPageHeading
breadcrumbs={[
{ title: 'Knowledge Bases', url: '/knowledge-bases' },
{ title: 'Knowledge Bases', url: '/knowledge-bases', docsUrl: '/docs/knowledge-base' },
{
alert: knowledgeBase?.data_sources_total === 0 ? {
variant: 'warning',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function KnowledgeBasesPage () {
<>
<AdminPageHeading
breadcrumbs={[
{ title: 'Knowledge Bases' },
{ title: 'Knowledge Bases', docsUrl: '/docs/knowledge-base' },
]}
/>
<NextLink href="/knowledge-bases/new">
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ const SidebarMenuBadge = React.forwardRef<
"peer-data-[size=default]/menu-button:top-1.5",
"peer-data-[size=lg]/menu-button:top-2.5",
"group-data-[collapsible=icon]:hidden",
"peer-data-[size=md]/menu-sub-button:top-1",
className
)}
{...props}
Expand Down Expand Up @@ -722,6 +723,7 @@ const SidebarMenuSubButton = React.forwardRef<
data-size={size}
data-active={isActive}
className={cn(
"peer/menu-sub-button",
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
size === "sm" && "text-xs",
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/src/pages/docs/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export default {
"reranker-model": {
"title": "Reranker Model"
},
"knowledge-base": {
"title": "Knowledge Base"
},
"data-source": {
"title": "Data Source"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/app/src/pages/docs/data-source.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Callout } from "nextra/components";

<Callout type='error'>
This page was deprecated. Please refer to [Knowledge Base document](/docs/knowledge-base)
</Callout>

# Add Data Source

In order to provide answers to users, you need to add data source to the tool. The data source can be your own docs, knowledge base, etc.
Expand Down
107 changes: 25 additions & 82 deletions frontend/app/src/pages/docs/deploy-with-docker.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Deploy with Docker Compose

This document provides instructions for deploying the entire RAG using Docker Compose.
import { Callout } from 'nextra/components'

## Deploy
This document provides instructions for deploying the entire Autoflow application using Docker Compose.

## Prerequisites

1. Set up a [TiDB Serverless cluster](https://docs.pingcap.com/tidbcloud/tidb-cloud-quickstart).

> **Prerequisites:**
>
> 1. Set up a [TiDB Serverless cluster](https://docs.pingcap.com/tidbcloud/tidb-cloud-quickstart).
> 2. Install [Docker Compose](https://docs.docker.com/compose/install/).
> **Note**
>
> TiDB Vector Search is only available for TiDB Self-Managed (TiDB >= v8.4) and [TiDB Cloud Serverless](https://ai.pingcap.com/).

2. Install [Docker Compose](https://docs.docker.com/compose/install/).

## Deploy

1. Clone the repository:

Expand All @@ -16,72 +23,7 @@ This document provides instructions for deploying the entire RAG using Docker Co
cd autoflow/;
```

2. Select an embedding model for pingcap/autoflow.

We recommend using the OpenAI `text-embedding-3-small` model for Autoflow due to its performance and compatibility. However, other supported embedding models can also be utilized.

- OpenAI
- **Model:** `text-embedding-3-small`
- **Embedding Dimensions (EMBEDDING_DIMS):** 1536
- **Maximum Tokens (EMBEDDING_MAX_TOKENS):** 8191
- JinaAI
- **Model:** `jina-clip-v1`
- **Embedding Dimensions (EMBEDDING_DIMS):** 768
- **Maximum Tokens (EMBEDDING_MAX_TOKENS):** 8192
- Additional models can be found at [JinaAI Embeddings](https://jina.ai/embeddings/).
- Local Embedding Server
- **Model:** `BAAI/bge-m3`
- **Embedding Dimensions (EMBEDDING_DIMS):** 1024
- **Maximum Tokens (EMBEDDING_MAX_TOKENS):** 8192

We also support embedding models that conform to the OpenAI API format. You can select the "OpenAI-Like" option to use your own embedding model. Details for specific models are provided below:

- ZhipuAI (Default Option for OpenAI-Like)
- **Model:** `embedding-3`
- **Embedding Dimensions (EMBEDDING_DIMS):** 2048
- **Maximum Tokens (EMBEDDING_MAX_TOKENS):** 8192
- More information is available at [ZhipuAI API Documentation](https://open.bigmodel.cn/dev/api/vector/embedding-3).
- **Configuration Note:** Since ZhipuAI is the default option for OpenAI-Like models, no additional configuration is required in the "Advanced Settings".
- Other OpenAI-Like Models
- **Set EMBEDDING_DIMS and EMBEDDING_MAX_TOKENS**: Refer to the model's API documentation to find the correct values for `EMBEDDING_DIMS` and `EMBEDDING_MAX_TOKENS`.
- **Configure API Base in "Advanced Settings"**:

Add the following configuration in JSON format:

```json
{
"api_base": "{api_base}",
}
```

<Callout>
OpenAI and ZhipuAI models have predefined configurations in their types. These examples are provided for reference when integrating other models.
</Callout>

- Example 1: For OpenAI's embedding API (`https://api.openai.com/v1/embeddings`), the `api_base` should be set to `https://api.openai.com/v1`, resulting in the following configuration:

```json
{
"api_base": "https://api.openai.com/v1"
}
```

- Example 2: For ZhipuAI's embedding API (`https://open.bigmodel.cn/api/paas/v4/embeddings`), the `api_base` should be set to `https://open.bigmodel.cn/api/paas/v4`, resulting in the following configuration:

```json
{
"api_base": "https://open.bigmodel.cn/api/paas/v4"
}
```

import { Callout } from 'nextra/components'

<Callout>
Note: You cannot change the embedding model after deployment because different models have varying vector dimensions and generate different vectors for the same input text.
If you want to use a different embedding model after deployment, you need to recreate the app and database.
</Callout>

3. Copy and edit the `.env` file:
2. Copy and edit the `.env` file:

```bash
cp .env.example .env
Expand All @@ -93,23 +35,23 @@ If you want to use a different embedding model after deployment, you need to rec
- `TIDB_HOST`, `TIDB_USER`, `TIDB_PASSWORD` and `TIDB_DATABASE`: get them from your [TiDB Serverless cluster](https://tidbcloud.com/)
- Note: TiDB Serverless will provide a default database name called `test`, if you want to use another database name, you need to create a new database in the TiDB Serverless console.
- Note: Don't use '#' in the password, it will cause an error when connecting to the database. See [issue](https://github.com/pydantic/pydantic/issues/8061).
- `EMBEDDING_DIMS` and `EMBEDDING_MAX_TOKENS`: set them according to the embedding model you choose before, it can not be changed after the deployment.
- `EMBEDDING_MAX_TOKENS`: set them according to the embedding model you choose before, it can not be changed after the deployment.

4. Migrate the database schema:
3. Migrate the database schema:

```bash
docker compose run backend /bin/sh -c "alembic upgrade head"
```

5. Bootstrap the database with initial data:
4. Bootstrap the database with initial data:

```bash
docker compose run backend /bin/sh -c "python bootstrap.py"
```

Running the bootstrap script creates an admin user. You can find the username and password in the output.

6. Start the services:
5. Start the services:

```bash
docker compose up
Expand All @@ -121,21 +63,22 @@ If you want to use a different embedding model after deployment, you need to rec
docker compose --profile local-embedding-reranker up
```

7. Open your browser and visit `http://localhost:3000` to access the web interface.
6. Open your browser and visit `http://localhost:3000` to access the web interface.

That's it! You can now use pingcap/autoflow locally. You can also go to https://tidb.ai to experience the live demo.


## Configuration

After you deploy the tool, you need to initialize the tool by following the popup wizard. The wizard will guide you through the following steps:
After you deploy the application, you need to initialize the application by following [quick start guide](/quick-start).

1. Set up the default LLM model in the **Models > LLMs** page.

* Set up the default LLM model.
* Set up the default Embedding model.
* Set up `Data Source` to index the data.
2. Set up the default Embedding model in the **Models > Embedding Models** page.

![initialization](https://github.com/user-attachments/assets/7f9253da-3d6f-4ccd-838d-feed3f0b6f05 "Initialization")
3. Add a new Knowledge Base in the **Knowledge Bases** page.

4. Configure default Chat Engine and set up the new knowledge base as the retrieval database.

## Upgrade

Expand Down
Loading
Loading