You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/ai-assistant.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ Go to Bytebase console, click **Settings > General**. Scroll down to **AI Assist
13
13
-**OpenAI API Key**. The Open API key you obtained [here](https://platform.openai.com/account/api-keys).
14
14
-**OpenAI API Endpoint**. If you use an OpenAPI compatible service or access OpenAPI via a proxy, you can optionally specify the custom endpoint.
15
15
16
-
## Integrate model with Ollama
16
+
## Use self-hosted model
17
17
18
-
If you have privacy concerns, you can self-host model and use Ollama which provides [OpenAI compatible Chat Completions API](https://ollama.com/blog/openai-compatibility).
18
+
<TutorialBlockurl="/docs/tutorials/one-api-ollama-sql-editor/"title="Self-host Llama3 for Bytebase AI Assistant" />
Copy file name to clipboardExpand all lines: content/docs/tutorials/one-api-ollama-sql-editor.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
-
title: 'Deploying llama3 to Bytebase SQL editor for text2SQL'
2
+
title: 'Self-host Llama3 for Bytebase AI Assistant'
3
3
author: Dec
4
4
tags: Tutorial
5
5
updated_at: 2024/12/27 18:15
6
6
integrations: General
7
7
level: Intermediate
8
8
estimated_time: '20 mins'
9
-
description: 'In this tutorial, we will demonstrate how to use One API to help deploy llama3 to Bytebase SQL editor'
9
+
description: 'In this tutorial, we will demonstrate how to use One API to help deploy Llama3 to Bytebase SQL editor'
10
10
---
11
11
12
-
With Open AI-compatible API, it is possible to query database using natural language in Bytebase SQL editor. For data security reasons, privately deploying a large language model is a good option - here we chose the powerful open source model llama3. Since OpenAI blocks outbound traffic by default, to simplify network configuration and further prevent token leakage, we used the open source project One API as a relay to convert between Bytebase's OpenAI API-compliant requests and llama3 API requests.
12
+
For data security reasons, you may want to enable [AI Assistant](/docs/ai-assistant/) with a self-deployed LLM. Here we chose the powerful open source model Llama3. We used [Ollama](https://ollama.com/)and [One API](https://github.com/songquanpeng/one-api/blob/main/README.en.md) as a relay to convert between Bytebase's OpenAI API-compliant requests and Llama3 API requests.
13
13
14
14
## Prerequisites
15
15
@@ -18,7 +18,7 @@ Before you begin, make sure you have:
Run the following command in terminal to get a Docker container running:
24
24
@@ -32,19 +32,19 @@ Container starts and returns id, then enter the container with the following com
32
32
docker exec -it ollama bash
33
33
```
34
34
35
-
Pull and run the llama3 model. Due to permission issues, the model needs to be renamed to gpt-3.5-turbo (or mapped in One-API). After renaming, the model name is gpt-3.5-turbo, but indeed it is still llama3.
35
+
Pull and run the Llama3 model. Due to mapping issues, the model needs to be renamed to `gpt-3.5-turbo` (or mapped in One-API). After renaming, the model name is `gpt-3.5-turbo`, but indeed it is still Llama3.
36
36
37
37
```bash
38
-
ollama pull llama3
39
-
ollama cp llama3 gpt-3.5-turbo
38
+
ollama pull Llama3
39
+
ollama cp Llama3 gpt-3.5-turbo
40
40
ollama run gpt-3.5-turbo
41
41
```
42
42
43
43
Now that the model is running, you can test if the API is working properly in a new terminal page:
44
44
45
45
```bash
46
46
curl http://localhost:11434/api/generate -d '{
47
-
"model": "gpt-3.5-turbo",
47
+
"model": "gpt-3.5-turbo",
48
48
"prompt":"Why is the sky blue?"
49
49
}'
50
50
```
@@ -76,7 +76,7 @@ The initial account username is `root`, password is `123456`.
76
76
Enter **channel page**, select **Add a new channel**. Fill in model information:
77
77
78
78
-**Type**: `ollama`
79
-
-**Name**: `llama3`
79
+
-**Name**: `Llama3`
80
80
-**Group**: `default`
81
81
-**Model**: `gpt-3.5-turbo`
82
82
-**Key**: Anything (for example `SSSS|sssss|1111`) with format `APPID|APISecret|APIKey` if ollama has not set up for key
@@ -86,7 +86,7 @@ Furthermore, we mentioned above that the model name can be mapped in One-API. Th
86
86
87
87
### Configure API Keys
88
88
89
-
In the **API keys** page, click **Add New Token**, and fill in the **Name** (for example `llama3`) and **Model scope** (for example `gpt-3.5-turbo`).
89
+
In the **API keys** page, click **Add New Token**, and fill in the **Name** (for example `Llama3`) and **Model scope** (for example `gpt-3.5-turbo`).
90
90
91
91
After clicking **Submit**, you will see the new API key in **My keys** list within **API keys** page. Click **Copy** to get a token starting with `sk-`, with witch you can repalce `YOUR_TOKEN` in the code below. If the code runs successfully in your terminal, it means that One API configuration is complete.
In Bytebase Workspace, go to **Settings** -> **General**, and scroll down to **AI Assistant** section. Fill `YOUR_TOKEN` we generated in One API into `OpenAI API Key` bar, and fill the `OpenAI API Endpoint` bar with `http://localhost:3000`. Click **Update**.
Enter **SQL Editor** from top of any page. You can see an OpenAI icon on top right corner. Click it to start conversation with AI assistant, ask questions in natural language and get SQL results.
0 commit comments