From 3e45f557578815c035454abc7b7d1195a71e3b75 Mon Sep 17 00:00:00 2001 From: zhihang Date: Tue, 15 Apr 2025 08:27:24 +0000 Subject: [PATCH] add README.md for OPEA codegen --- AI/opea/chatqna/README.md | 2 +- AI/opea/codegen/README.md | 118 ++++++++++++++++++++++++++++++++ AI/opea/codegen/doc/compose.yml | 66 ++++++++++++++++++ AI/opea/codegen/doc/set_env.sh | 11 +++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 AI/opea/codegen/README.md create mode 100644 AI/opea/codegen/doc/compose.yml create mode 100644 AI/opea/codegen/doc/set_env.sh diff --git a/AI/opea/chatqna/README.md b/AI/opea/chatqna/README.md index d594d773..9e4a583c 100644 --- a/AI/opea/chatqna/README.md +++ b/AI/opea/chatqna/README.md @@ -8,7 +8,7 @@ # OPEA | openEuler -Current Redis docker images are built on the [openEuler](https://repo.openeuler.org/)⁠. This repository is free to use and exempted from per-user rate limits. +Current OPEA docker images are built on the [openEuler](https://repo.openeuler.org/)⁠. This repository is free to use and exempted from per-user rate limits. OPEA is an open platform project that lets you create open, multi-provider, robust, and composable GenAI solutions that harness the best innovation across the ecosystem. diff --git a/AI/opea/codegen/README.md b/AI/opea/codegen/README.md new file mode 100644 index 00000000..aaec2535 --- /dev/null +++ b/AI/opea/codegen/README.md @@ -0,0 +1,118 @@ +# Quick reference + +- The offical OPEA docker images + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# OPEA | openEuler + +Current Redis docker images are built on the [openEuler](https://repo.openeuler.org/)⁠. This repository is free to use and exempted from per-user rate limits. + +OPEA is an open platform project that lets you create open, multi-provider, robust, and composable GenAI solutions that harness the best innovation across the ecosystem. + +The OPEA platform includes: + +- Detailed framework of composable building blocks for state-of-the-art generative AI systems including LLMs, data stores, and prompt engines + +- Architectural blueprints of retrieval-augmented generative AI component stack structure and end-to-end workflows + +- A four-step assessment for grading generative AI systems around performance, features, trustworthiness, and enterprise-grade readiness + +Read more about OPEA at [opea.dev](https://opea.dev/) and explore the OPEA technical documentation at [opea-project.github.io](https://opea-project.github.io/) + +# Supported tags and respective Dockerfile links + +The tag of each CodeGen docker image is consist of the version of CodeGen and the version of basic image. The details are as follows + +| Tags | Currently | Architectures| +|--|--|--| +|[1.0-oe2403lts](https://gitee.com/openeuler/openeuler-docker-images/blob/master/AI/opea/codegen/1.0/24.03-lts/Dockerfile)| CodeGen 1.0 on openEuler 24.03-LTS | amd64 | + +# Usage + +The CodeGen service can be effortlessly deployed on either Intel Gaudi2 or Intel Xeon Scalable Processor. + +Currently we support two ways of deploying CodeGen services with docker compose: + +1. Start services using the docker image on `docker hub`: + + ```bash + docker pull openeuler/codegen:latest + ``` + +2. Start services using the docker images built from source. + +### Required Models + +By default, the LLM model is set to a default value as listed below: + +| Service | Model | +| ------------ | ------------------------------------------------------------------------------- | +| LLM_MODEL_ID | [meta-llama/CodeLlama-7b-hf](https://huggingface.co/meta-llama/CodeLlama-7b-hf) | + +[meta-llama/CodeLlama-7b-hf](https://huggingface.co/meta-llama/CodeLlama-7b-hf) is a gated model that requires submitting an access request through Hugging Face. You can replace it with another model. +Change the `LLM_MODEL_ID` below for your needs, such as: [Qwen/CodeQwen1.5-7B-Chat](https://huggingface.co/Qwen/CodeQwen1.5-7B-Chat), [deepseek-ai/deepseek-coder-6.7b-instruct](https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-instruct) + +If you choose to use `meta-llama/CodeLlama-7b-hf` as LLM model, you will need to visit [here](https://huggingface.co/meta-llama/CodeLlama-7b-hf), click the `Expand to review and access` button to ask for model access. + +### Quick Start: 1.Setup Environment Variable + +To set up environment variables for deploying CodeGen services, follow these steps: + +1. Set the required environment variables: + + ```bash + # Example: host_ip="192.168.1.1" + export host_ip="External_Public_IP" + # Example: no_proxy="localhost, 127.0.0.1, 192.168.1.1" + export no_proxy="Your_No_Proxy" + export HUGGINGFACEHUB_API_TOKEN="Your_Huggingface_API_Token" + ``` + +2. If you are in a proxy environment, also set the proxy-related environment variables: + + ```bash + export http_proxy="Your_HTTP_Proxy" + export https_proxy="Your_HTTPs_Proxy" + ``` + +3. Set up other environment variables: + + > Get `set_env.sh` here: [set_env.sh](https://gitee.com/openeuler/openeuler-docker-images/tree/master/AI/opea/codegen/doc/set_env.sh) + + ```bash + source set_env.sh + ``` + +### Quick Start: 2.Run Docker Compose + +> Get `compose.yml` here: [compose.yml](https://gitee.com/openeuler/openeuler-docker-images/tree/master/AI/opea/codegen/doc/compose.yml) + +```bash +docker compose -f compose.yml up -d +``` + +It will automatically download the docker image on `docker hub`: + +```bash +docker pull openeuler/codegen:latest +docker pull openeuler/codegen-ui:latest +``` + +### QuickStart: 3.Consume the CodeGen Service + +1. Use cURL command on terminal + + ```bash + curl http://${host_ip}:7778/v1/codegen \ + -H "Content-Type: application/json" \ + -d '{"messages": "Implement a high-level API for a TODO list application. The API takes as input an operation request and updates the TODO list in place. If the request is invalid, raise an exception."}' + ``` + +2. Access via frontend + + To access the frontend, open the following URL in your browser: http://{host_ip}:5173. + + By default, the UI runs on port 5173 internally. diff --git a/AI/opea/codegen/doc/compose.yml b/AI/opea/codegen/doc/compose.yml new file mode 100644 index 00000000..67236a1a --- /dev/null +++ b/AI/opea/codegen/doc/compose.yml @@ -0,0 +1,66 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +services: + tgi-service: + image: openeuler/text-generation-inference-cpu:2.4.0-oe2403lts + container_name: tgi-service + ports: + - "8028:80" + volumes: + - "./data:/data" + shm_size: 1g + environment: + no_proxy: ${no_proxy} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + HF_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} + command: --model-id ${LLM_MODEL_ID} --cuda-graphs 0 + llm: + image: openeuler/llm-tgi:1.0-oe2403lts + container_name: llm-tgi-server + depends_on: + - tgi-service + ports: + - "9000:9000" + ipc: host + environment: + no_proxy: ${no_proxy} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + TGI_LLM_ENDPOINT: ${TGI_LLM_ENDPOINT} + HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN} + restart: unless-stopped + codegen-xeon-backend-server: + image: openeuler/codegen:1.0-oe2403lts + container_name: codegen-xeon-backend-server + depends_on: + - llm + ports: + - "7778:7778" + environment: + - no_proxy=${no_proxy} + - https_proxy=${https_proxy} + - http_proxy=${http_proxy} + - MEGA_SERVICE_HOST_IP=${MEGA_SERVICE_HOST_IP} + - LLM_SERVICE_HOST_IP=${LLM_SERVICE_HOST_IP} + ipc: host + restart: always + codegen-xeon-ui-server: + image: openeuler/codegen-ui:1.0-oe2403lts + container_name: codegen-xeon-ui-server + depends_on: + - codegen-xeon-backend-server + ports: + - "5173:5173" + environment: + - no_proxy=${no_proxy} + - https_proxy=${https_proxy} + - http_proxy=${http_proxy} + - BASIC_URL=${BACKEND_SERVICE_ENDPOINT} + ipc: host + restart: always + +networks: + default: + driver: bridge diff --git a/AI/opea/codegen/doc/set_env.sh b/AI/opea/codegen/doc/set_env.sh new file mode 100644 index 00000000..cf48abf5 --- /dev/null +++ b/AI/opea/codegen/doc/set_env.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + + +export LLM_MODEL_ID="meta-llama/CodeLlama-7b-hf" +export TGI_LLM_ENDPOINT="http://${host_ip}:8028" +export MEGA_SERVICE_HOST_IP=${host_ip} +export LLM_SERVICE_HOST_IP=${host_ip} +export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:7778/v1/codegen" \ No newline at end of file -- Gitee