Skip to content

Commit d8e71ae

Browse files
committed
chore: tweak ollama
1 parent 4962023 commit d8e71ae

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

content/docs/ai-assistant.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Go to Bytebase console, click **Settings > General**. Scroll down to **AI Assist
1313
- **OpenAI API Key**. The Open API key you obtained [here](https://platform.openai.com/account/api-keys).
1414
- **OpenAI API Endpoint**. If you use an OpenAPI compatible service or access OpenAPI via a proxy, you can optionally specify the custom endpoint.
1515

16-
## Integrate model with Ollama
16+
## Use self-hosted model
1717

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+
<TutorialBlock url="/docs/tutorials/one-api-ollama-sql-editor/" title="Self-host Llama3 for Bytebase AI Assistant" />
1919

2020
## Features
2121

content/docs/tutorials/one-api-ollama-sql-editor.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
title: 'Deploying llama3 to Bytebase SQL editor for text2SQL'
2+
title: 'Self-host Llama3 for Bytebase AI Assistant'
33
author: Dec
44
tags: Tutorial
55
updated_at: 2024/12/27 18:15
66
integrations: General
77
level: Intermediate
88
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'
1010
---
1111

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.
1313

1414
## Prerequisites
1515

@@ -18,7 +18,7 @@ Before you begin, make sure you have:
1818
- [Docker](https://www.docker.com/) installed
1919
- [Bytebase](https://www.bytebase.com/docs/get-started/step-by-step/deploy-with-docker/) instance running
2020

21-
## Get llama3 running in Docker
21+
## Get Llama3 running in Docker
2222

2323
Run the following command in terminal to get a Docker container running:
2424

@@ -32,19 +32,19 @@ Container starts and returns id, then enter the container with the following com
3232
docker exec -it ollama bash
3333
```
3434

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.
3636

3737
```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
4040
ollama run gpt-3.5-turbo
4141
```
4242

4343
Now that the model is running, you can test if the API is working properly in a new terminal page:
4444

4545
```bash
4646
curl http://localhost:11434/api/generate -d '{
47-
"model": "gpt-3.5-turbo",
47+
"model": "gpt-3.5-turbo",
4848
"prompt":"Why is the sky blue?"
4949
}'
5050
```
@@ -76,7 +76,7 @@ The initial account username is `root`, password is `123456`.
7676
Enter **channel page**, select **Add a new channel**. Fill in model information:
7777

7878
- **Type**: `ollama`
79-
- **Name**: `llama3`
79+
- **Name**: `Llama3`
8080
- **Group**: `default`
8181
- **Model**: `gpt-3.5-turbo`
8282
- **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
8686

8787
### Configure API Keys
8888

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`).
9090

9191
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.
9292

@@ -110,7 +110,7 @@ curl http://localhost:3000/v1/chat/completions \
110110

111111
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**.
112112

113-
![bytebase-ai-assistant-config](/content/docs/tutorials/one-api-ollama-sql-editor/bytebase-ai-assistant-config.webp)
113+
![bytebase-ai-assistant-config](/content/docs/tutorials/one-api-ollama-sql-editor/ai-assistant-config.webp)
114114

115115
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.
116116

0 commit comments

Comments
 (0)