Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat_fin_report
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-ckt committed Jul 25, 2024
2 parents befc740 + 22e0680 commit 21460e4
Show file tree
Hide file tree
Showing 35 changed files with 3,256 additions and 1,998 deletions.
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ models/
plugins/
pilot/data
pilot/message
logs/
logs/
venv/
web/node_modules/
docs/node_modules/
build/
docs/build/
docs/Dockerfile-deploy
39 changes: 39 additions & 0 deletions .github/workflows/doc-image-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and push docs image

on:
push:
branches:
- main
paths:
- 'docs/**'
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
build-image:
runs-on: ubuntu-latest
# run unless event type is pull_request
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./docs/Dockerfile-deploy
platforms: linux/amd64
push: true
tags: eosphorosai/dbgpt-docs:${{ github.ref_name }},eosphorosai/dbgpt-docs:latest
3 changes: 3 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ DB-GPTのアーキテクチャは以下の図に示されています:
私たちは、LLaMA/LLaMA2、Baichuan、ChatGLM、Wenxin、Tongyi、Zhipuなど、オープンソースおよびAPIエージェントからの数十の大規模言語モデル(LLM)を含む幅広いモデルをサポートしています。

- ニュース
- 🔥🔥🔥 [Meta-Llama-3.1-405B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct)
- 🔥🔥🔥 [gemma-2-27b-it](https://huggingface.co/google/gemma-2-27b-it)
- 🔥🔥🔥 [gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it)
- 🔥🔥🔥 [DeepSeek-Coder-V2-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ At present, we have introduced several key features to showcase our current capa
We offer extensive model support, including dozens of large language models (LLMs) from both open-source and API agents, such as LLaMA/LLaMA2, Baichuan, ChatGLM, Wenxin, Tongyi, Zhipu, and many more.

- News
- 🔥🔥🔥 [Meta-Llama-3.1-405B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct)
- 🔥🔥🔥 [gemma-2-27b-it](https://huggingface.co/google/gemma-2-27b-it)
- 🔥🔥🔥 [gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it)
- 🔥🔥🔥 [DeepSeek-Coder-V2-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct)
Expand Down
3 changes: 3 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
海量模型支持,包括开源、API代理等几十种大语言模型。如LLaMA/LLaMA2、Baichuan、ChatGLM、文心、通义、智谱等。当前已支持如下模型:

- 新增支持模型
- 🔥🔥🔥 [Meta-Llama-3.1-405B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-405B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct)
- 🔥🔥🔥 [Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct)
- 🔥🔥🔥 [gemma-2-27b-it](https://huggingface.co/google/gemma-2-27b-it)
- 🔥🔥🔥 [gemma-2-9b-it](https://huggingface.co/google/gemma-2-9b-it)
- 🔥🔥🔥 [DeepSeek-Coder-V2-Instruct](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct)
Expand Down
Binary file modified assets/wechat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dbgpt/agent/expand/resources/search_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def baidu_search(
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) "
"Gecko/20100101 Firefox/112.0"
}
num_results = int(num_results)
if num_results < 8:
num_results = 8
url = f"https://www.baidu.com/s?wd={query}&rn={num_results}"
Expand Down
5 changes: 5 additions & 0 deletions dbgpt/app/knowledge/service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import re
from datetime import datetime

from dbgpt._private.config import Config
Expand Down Expand Up @@ -80,6 +81,10 @@ def create_knowledge_space(self, request: KnowledgeSpaceRequest):
)
if request.vector_type == "VectorStore":
request.vector_type = CFG.VECTOR_STORE_TYPE
if request.vector_type == "KnowledgeGraph":
knowledge_space_name_pattern = r"^[a-zA-Z0-9\u4e00-\u9fa5]+$"
if not re.match(knowledge_space_name_pattern, request.name):
raise Exception(f"space name:{request.name} invalid")
spaces = knowledge_space_dao.get_knowledge_space(query)
if len(spaces) > 0:
raise Exception(f"space name:{request.name} have already named")
Expand Down
9 changes: 9 additions & 0 deletions dbgpt/configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def get_device() -> str:
"meta-llama-3-8b-instruct": os.path.join(MODEL_PATH, "Meta-Llama-3-8B-Instruct"),
# https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct
"meta-llama-3-70b-instruct": os.path.join(MODEL_PATH, "Meta-Llama-3-70B-Instruct"),
"meta-llama-3.1-8b-instruct": os.path.join(
MODEL_PATH, "Meta-Llama-3.1-8B-Instruct"
),
"meta-llama-3.1-70b-instruct": os.path.join(
MODEL_PATH, "Meta-Llama-3.1-70B-Instruct"
),
"meta-llama-3.1-405b-instruct": os.path.join(
MODEL_PATH, "Meta-Llama-3.1-405B-Instruct"
),
"baichuan-13b": os.path.join(MODEL_PATH, "Baichuan-13B-Chat"),
# please rename "fireballoon/baichuan-vicuna-chinese-7b" to "baichuan-7b"
"baichuan-7b": os.path.join(MODEL_PATH, "baichuan-7b"),
Expand Down
24 changes: 23 additions & 1 deletion dbgpt/model/adapter/hf_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,12 @@ class Llama3Adapter(NewHFChatModelAdapter):
support_8bit: bool = True

def do_match(self, lower_model_name_or_path: Optional[str] = None):
return lower_model_name_or_path and "llama-3" in lower_model_name_or_path
return (
lower_model_name_or_path
and "llama-3" in lower_model_name_or_path
and "instruct" in lower_model_name_or_path
and "3.1" not in lower_model_name_or_path
)

def get_str_prompt(
self,
Expand Down Expand Up @@ -431,6 +436,22 @@ def get_str_prompt(
return str_prompt


class Llama31Adapter(Llama3Adapter):
def check_transformer_version(self, current_version: str) -> None:
logger.info(f"Checking transformers version: Current version {current_version}")
if not current_version >= "4.43.0":
raise ValueError(
"Llama-3.1 require transformers.__version__>=4.43.0, please upgrade your transformers package."
)

def do_match(self, lower_model_name_or_path: Optional[str] = None):
return (
lower_model_name_or_path
and "llama-3.1" in lower_model_name_or_path
and "instruct" in lower_model_name_or_path
)


class DeepseekV2Adapter(NewHFChatModelAdapter):
support_4bit: bool = False
support_8bit: bool = False
Expand Down Expand Up @@ -613,6 +634,7 @@ def load(self, model_path: str, from_pretrained_kwargs: dict):
register_model_adapter(QwenAdapter)
register_model_adapter(QwenMoeAdapter)
register_model_adapter(Llama3Adapter)
register_model_adapter(Llama31Adapter)
register_model_adapter(DeepseekV2Adapter)
register_model_adapter(DeepseekCoderV2Adapter)
register_model_adapter(SailorAdapter)
Expand Down
95 changes: 95 additions & 0 deletions docs/Dockerfile-deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
FROM node:lts-alpine as build

RUN apk add --no-cache git

ARG NPM_REGISTRY=https://registry.npmjs.org
ENV NPM_REGISTRY=$NPM_REGISTRY

# Set github CI environment variable
ARG CI=true
ENV CI=$CI

WORKDIR /app

# Copy package.json and package-lock.json to a separate build directory
COPY docs/package*.json /app-build/docs/

# Install dependencies in the separate build directory
RUN cd /app-build/docs && \
npm config set registry $NPM_REGISTRY && \
npm ci

# Copy the rest of the application to /app and /app-build
COPY . /app-build
COPY . /app

# Make sure we have the latest version of the repository
RUN if [ "$CI" = "true" ]; then \
git fetch --prune --unshallow; \
fi

ARG NUM_VERSION=2
ENV NUM_VERSION=$NUM_VERSION

# Commit the changes to the repository, just for local testing
# Sometimes, we just want to test the changes in the Dockerfile
RUN git config --global user.email "[email protected]" && \
git config --global user.name "DB-GPT" && \
git add . && git commit --no-verify -m "Commit message"

# New logic for building versions directly in Dockerfile
RUN git config --global --add safe.directory /app && \
# Record the current position
CURRENT_POSITION=$(git rev-parse --abbrev-ref HEAD) && \
# Get the latest tags
TAGS=$(git tag --sort=-creatordate | head -n $NUM_VERSION | tac) && \
# If there are no tags, get the latest commits
if [ -z "$TAGS" ]; then \
TAGS=$(git log --format="%h" -n $NUM_VERSION | tac); \
fi && \
for TAG in $TAGS; do \
echo "Creating version $TAG"; \
cd /app/docs && git checkout $TAG; \
echo "Checked out to tag: $TAG"; \
# Copy the necessary files to the build directory for each tag
rm -rf /app-build/docs/docs /app-build/docs/sidebars.js /app-build/docs/static /app-build/docs/src && \
cp -r /app/docs/docs /app-build/docs/ && \
cp /app/docs/sidebars.js /app-build/docs/ && \
cp -r /app/docs/static /app-build/docs/ && \
cp -r /app/docs/src /app-build/docs/; \
# Create a new version
cd /app-build/docs && npm run docusaurus docs:version $TAG || exit 1; \
done && \
# Return to the original position, build dev version
cd /app/docs && git checkout $CURRENT_POSITION && \
rm -rf /app-build/docs/docs /app-build/docs/sidebars.js /app-build/docs/static /app-build/docs/src && \
cp -r /app/docs/docs /app-build/docs/ && \
cp /app/docs/sidebars.js /app-build/docs/ && \
cp -r /app/docs/static /app-build/docs/ && \
cp -r /app/docs/src /app-build/docs/; \
cd /app-build/docs && npm run build && \
echo $TAGS | tr ' ' '\n' | tac > /app-build/docs/build/versions.txt && \
echo "latest" >> /app-build/docs/build/versions.txt && \
echo "Built versions:" && \
cat /app-build/docs/build/versions.txt

# For production
FROM nginx:alpine

# Copy the nginx configuration file
# COPY nginx.conf /etc/nginx/nginx.conf

# Copy the build output to replace the default nginx contents.
COPY --from=build /app-build/docs/build /usr/share/nginx/html
COPY --from=build /app-build/docs/versioned_docs/ /usr/share/nginx/html/versioned_docs/
COPY --from=build /app-build/docs/versioned_sidebars/ /usr/share/nginx/html/versioned_sidebars/

RUN echo '#!/bin/sh' > /usr/share/nginx/html/versions.sh && \
echo 'echo "Available versions:"' >> /usr/share/nginx/html/versions.sh && \
echo 'cat /usr/share/nginx/html/versions.txt' >> /usr/share/nginx/html/versions.sh && \
chmod +x /usr/share/nginx/html/versions.sh

EXPOSE 80

# Start Nginx server
CMD ["nginx", "-g", "daemon off;"]
30 changes: 30 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,33 @@ yarn start

The default service starts on port `3000`, visit `localhost:3000`

## Deploy Multi-Version Documentation

We can deploy multiple versions of the documentation by docker.

### Build Docker Image

Firstly, build the docker image in `DB-GPT` project root directory.

```bash
# Use the default NPM_REGISTRY=https://registry.npmjs.org
# Use https://www.npmmirror.com/
NPM_REGISTRY=https://registry.npmmirror.com
docker build -f docs/Dockerfile-deploy \
-t eosphorosai/dbgpt-docs \
--build-arg NPM_REGISTRY=$NPM_REGISTRY \
--build-arg CI=false \
--build-arg NUM_VERSION=2 .
```

### Run Docker Container

Run the docker container with the following command:
```bash
docker run -it --rm -p 8089:8089 \
--name my-dbgpt-docs \
-v $(pwd)/docs/nginx/nginx-docs.conf:/etc/nginx/nginx.conf \
eosphorosai/dbgpt-docs
```

Open the browser and visit `localhost:8089` to see the documentation.
66 changes: 66 additions & 0 deletions docs/blog/2024-07-24-db-gpt-llama-3.1-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
slug: db-gpt-llama-3.1-support
title: DB-GPT Now Supports Meta Llama 3.1 Series Models
authors: fangyinc
tags: [llama, LLM]
---

We are thrilled to announce that DB-GPT now supports inference with the Meta Llama 3.1 series models!

## Introducing Meta Llama 3.1

Meta Llama 3.1 is a state-of-the-art series of language models developed by Meta AI. Designed with cutting-edge techniques, the Llama 3.1 models offer unparalleled performance and versatility. Here are some of the key highlights:

- **Variety of Models**: Meta Llama 3.1 is available in 8B, 70B, and 405B versions, each with both instruction-tuned and base models, supporting contexts up to 128k tokens.
- **Multilingual Support**: Supports 8 languages, including English, German, and French.
- **Extensive Training**: Trained on over 1.5 trillion tokens, utilizing 250 million human and synthetic samples for fine-tuning.
- **Flexible Licensing**: Permissive model output usage allows for adaptation into other large language models (LLMs).
- **Quantization Support**: Available in FP8, AWQ, and GPTQ quantized versions for efficient inference.
- **Performance**: The Llama 3 405B version has outperformed GPT-4 in several benchmarks.
- **Enhanced Efficiency**: The 8B and 70B models have seen a 12% improvement in coding and instruction-following capabilities.
- **Tool and Function Call Support**: Supports tool usage and function calling.

## How to Access Meta Llama 3.1

Your can access the Meta Llama 3.1 models according to [Access to Hugging Face](https://github.com/meta-llama/llama-models?tab=readme-ov-file#access-to-hugging-face).

For comprehensive documentation and additional details, please refer to the [model card](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/MODEL_CARD.md).

## Using Meta Llama 3.1 in DB-GPT

Please read the [Source Code Deployment](../docs/installation/sourcecode) to learn how to install DB-GPT from source code.

Llama 3.1 needs upgrade your transformers >= 4.43.0, please upgrade your transformers:
```bash
pip install --upgrade "transformers>=4.43.0"
```

Please cd to the DB-GPT root directory:
```bash
cd DB-GPT
```

We assume that your models are stored in the `models` directory, e.g., `models/Meta-Llama-3.1-8B-Instruct`.

Then modify your `.env` file:
```env
LLM_MODEL=meta-llama-3.1-8b-instruct
# LLM_MODEL=meta-llama-3.1-70b-instruct
# LLM_MODEL=meta-llama-3.1-405b-instruct
## you can also specify the model path
# LLM_MODEL_PATH=models/Meta-Llama-3.1-8B-Instruct
## Quantization settings
# QUANTIZE_8bit=False
# QUANTIZE_4bit=True
## You can configure the maximum memory used by each GPU.
# MAX_GPU_MEMORY=16Gib
```

Then you can run the following command to start the server:
```bash
dbgpt start webserver
```

Open your browser and visit `http://localhost:5670` to use the Meta Llama 3.1 models in DB-GPT.

Enjoy the power of Meta Llama 3.1 in DB-GPT!
5 changes: 5 additions & 0 deletions docs/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fangyinc:
name: Fangyin Cheng
title: DB-GPT Core Team
url: https://github.com/fangyinc
image_url: https://avatars.githubusercontent.com/u/22972572?v=4
8 changes: 8 additions & 0 deletions docs/blog/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
llama:
label: LLama
permalink: /llama
description: A series of language models developed by Meta AI
LLM:
label: LLM
permalink: /llm
description: Large Language Models
2 changes: 1 addition & 1 deletion docs/docs/agents/introduction/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ In the above code, we use the `ToolAssistantAgent` to select and call the approp
In the above code, we use the `tool` decorator to define the tool function. It will wrap the function to a
`FunctionTool` object. And `FunctionTool` is a subclass of `BaseTool`, which is a base class of all tools.

Actually, **tool** is a special **resource** in the `DB-GPT` agent. You will see more details in the [Resource](./resource.md) section.
Actually, **tool** is a special **resource** in the `DB-GPT` agent. You will see more details in the [Resource](../modules/resource/resource.md) section.
Loading

0 comments on commit 21460e4

Please sign in to comment.