Skip to content

Commit d0fa8a7

Browse files
authored
CodeTranslation: simplify instructions and env setup (#101)
* update CodeTranslation instructions, use /tmp paths for output dirs Signed-off-by: alexsin368 <alex.sin@intel.com> * undo changes for other sample solutions Signed-off-by: alexsin368 <alex.sin@intel.com> * change back to original Signed-off-by: alexsin368 <alex.sin@intel.com> * update validated configs tables Signed-off-by: alexsin368 <alex.sin@intel.com> * fix tables Signed-off-by: alexsin368 <alex.sin@intel.com> * center boxes Signed-off-by: alexsin368 <alex.sin@intel.com> * fix text Signed-off-by: alexsin368 <alex.sin@intel.com> * change table format Signed-off-by: alexsin368 <alex.sin@intel.com> * update table Signed-off-by: alexsin368 <alex.sin@intel.com> * update table, INFERENCE_MODEL_NAME note Signed-off-by: alexsin368 <alex.sin@intel.com> * update table Signed-off-by: alexsin368 <alex.sin@intel.com> --------- Signed-off-by: alexsin368 <alex.sin@intel.com>
1 parent f29d703 commit d0fa8a7

2 files changed

Lines changed: 37 additions & 126 deletions

File tree

sample_solutions/CodeTranslation/.env.example

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
BACKEND_PORT=5001
33

44
# Inference API Configuration
5-
# INFERENCE_API_ENDPOINT: URL to your inference service (without /v1 suffix)
6-
# - For GenAI Gateway: https://genai-gateway.example.com
7-
# - For APISIX Gateway: https://apisix-gateway.example.com/CodeLlama-34b-Instruct-hf
8-
# Note: APISIX Gateway requires the model name in the URL path
9-
#
5+
# Note: model names must match one of the deployed models with Enterprise Inference.
6+
# INFERENCE_API_ENDPOINT: URL to your inference service (without /v1 suffix). Uncomment ONE of the below.
7+
# - For GenAI Gateway:
8+
#INFERENCE_API_ENDPOINT=https://api.example.com
9+
# - For APISIX Gateway (default), requires the model name in the URL path:
10+
INFERENCE_API_ENDPOINT=https://api.example.com/CodeLlama-34b-Instruct-hf
11+
1012
# INFERENCE_API_TOKEN: Authentication token/API key for the inference service
1113
# - For GenAI Gateway: Your GenAI Gateway API key
1214
# - For APISIX Gateway: Your APISIX authentication token
13-
INFERENCE_API_ENDPOINT=https://your-api-endpoint.com/deployment
1415
INFERENCE_API_TOKEN=your-pre-generated-token-here
16+
17+
# Model Configuration
18+
# IMPORTANT: Use the full model name i.e. model card
1519
INFERENCE_MODEL_NAME=codellama/CodeLlama-34b-Instruct-hf
1620

1721
# LLM Settings

sample_solutions/CodeTranslation/README.md

Lines changed: 27 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -125,38 +125,34 @@ This application is built with enterprise inference capabilities using token-bas
125125
Before you begin, ensure you have the following installed:
126126

127127
- **Docker and Docker Compose**
128-
- **Enterprise inference endpoint access** (token-based authentication)
128+
- **Enterprise Inference endpoint access** (token-based authentication, see below for models and configs)
129+
130+
#### Deploy Required Models
131+
132+
See the table below for supported models, hardware, and gateway configuration.
133+
134+
| Model | Xeon w/APISIX/Keycloak | Xeon w/GenAI Gateway | Gaudi w/APISIX/Keycloak | Gaudi w/GenAI Gateway |
135+
|---|:---:|:---:|:---:|:---:|
136+
| **codellama/CodeLlama-34b-Instruct-hf** ||| ✅ Validated on Dell XE7740 | ✅ Validated on Dell XE7740 |
137+
| **Qwen/Qwen3-4B-Instruct-2507** | ✅ Validated on Dell XE7740 | ✅ Validated on Dell XE7740 |||
129138

130139
### Required API Configuration
131140

132141
**For Inference Service (Code Translation):**
133142

134143
This application supports multiple inference deployment patterns:
135144

136-
- **GenAI Gateway**: Provide your GenAI Gateway URL and API key
145+
**GenAI Gateway**: Provide your GenAI Gateway URL and API key
146+
- URL format: https://api.example.com
137147
- To generate the GenAI Gateway API key, use the [generate-vault-secrets.sh](https://github.com/opea-project/Enterprise-Inference/blob/main/core/scripts/generate-vault-secrets.sh) script
138-
- The API key is the `litellm_master_key` value from the generated `vault.yml` file
139-
140-
- **APISIX Gateway**: Provide your APISIX Gateway URL and authentication token
148+
- The API key is the litellm_master_key value from the generated vault.yml file
149+
150+
**APISIX Gateway**: Provide your APISIX Gateway URL and authentication token
151+
- URL format: https://api.example.com/Llama-3.1-8B-Instruct
152+
- Note: APISIX requires the model name in the URL path
141153
- To generate the APISIX authentication token, use the [generate-token.sh](https://github.com/opea-project/Enterprise-Inference/blob/main/core/scripts/generate-token.sh) script
142154
- The token is generated using Keycloak client credentials
143155

144-
### Local Development Configuration
145-
146-
**For Local Testing Only (Optional)**
147-
148-
If you're testing with a local inference endpoint using a custom domain (e.g., `api.example.com` mapped to localhost in your hosts file):
149-
150-
1. Edit `.env` and set:
151-
```bash
152-
LOCAL_URL_ENDPOINT=api.example.com
153-
```
154-
(Use the domain name from your INFERENCE_API_ENDPOINT without `https://`)
155-
156-
2. This allows Docker containers to resolve your local domain correctly.
157-
158-
**Note:** For public domains or cloud-hosted endpoints, leave the default value `not-needed`.
159-
160156
### Verify Docker Installation
161157

162158
```bash
@@ -182,101 +178,23 @@ cd Enterprise-Inference/sample_solutions/CodeTranslation
182178

183179
### Set up the Environment
184180

185-
This application requires an `.env` file in the root directory for proper configuration. Create it with the commands below:
181+
This application requires an `.env` file in the root directory for proper configuration. Create it using [.env.example](./.env.example) with the commands below:
186182

187183
```bash
188-
# Create the .env file
189-
cat > .env << EOF
190-
# Backend API Configuration
191-
BACKEND_PORT=5001
192-
193-
# Inference API Configuration
194-
# INFERENCE_API_ENDPOINT: URL to your inference service (without /v1 suffix)
195-
# - For GenAI Gateway: https://genai-gateway.example.com
196-
# - For APISIX Gateway: https://apisix-gateway.example.com/CodeLlama-34b-Instruct-hf
197-
# Note: APISIX Gateway requires the model name in the URL path
198-
#
199-
# INFERENCE_API_TOKEN: Authentication token/API key for the inference service
200-
# - For GenAI Gateway: Your GenAI Gateway API key
201-
# - For APISIX Gateway: Your APISIX authentication token
202-
INFERENCE_API_ENDPOINT=https://your-api-endpoint.com/deployment
203-
INFERENCE_API_TOKEN=your-pre-generated-token-here
204-
INFERENCE_MODEL_NAME=codellama/CodeLlama-34b-Instruct-hf
205-
206-
# LLM Settings
207-
LLM_TEMPERATURE=0.2
208-
LLM_MAX_TOKENS=4096
209-
210-
# Code Translation Settings
211-
# MAX_CODE_LENGTH: Maximum input code length in characters
212-
# Note: For Enterprise Inference with CodeLlama-34b (max tokens: 5196)
213-
# Set to 4000 characters to stay safely under the token limit with prompt overhead
214-
MAX_CODE_LENGTH=4000
215-
MAX_FILE_SIZE=10485760
216-
217-
# CORS Configuration
218-
CORS_ALLOW_ORIGINS=["http://localhost:5173", "http://localhost:3000"]
219-
220-
# Local URL Endpoint (only needed for non-public domains)
221-
# If using a local domain like api.example.com mapped to localhost, set to the domain without https://
222-
# Otherwise, set to: not-needed
223-
LOCAL_URL_ENDPOINT=not-needed
224-
225-
# SSL Verification Settings
226-
# Set to false only for dev with self-signed certs
227-
VERIFY_SSL=true
228-
EOF
229-
```
230-
231-
Or manually create `.env` with:
232-
233-
```bash
234-
# Backend API Configuration
235-
BACKEND_PORT=5001
236-
237-
# Inference API Configuration
238-
# INFERENCE_API_ENDPOINT: URL to your inference service (without /v1 suffix)
239-
# - For GenAI Gateway: https://genai-gateway.example.com
240-
# - For APISIX Gateway: https://apisix-gateway.example.com/CodeLlama-34b-Instruct-hf
241-
# Note: APISIX Gateway requires the model name in the URL path
242-
#
243-
# INFERENCE_API_TOKEN: Authentication token/API key for the inference service
244-
# - For GenAI Gateway: Your GenAI Gateway API key
245-
# - For APISIX Gateway: Your APISIX authentication token
246-
INFERENCE_API_ENDPOINT=https://your-api-endpoint.com/deployment
247-
INFERENCE_API_TOKEN=your-pre-generated-token-here
248-
INFERENCE_MODEL_NAME=codellama/CodeLlama-34b-Instruct-hf
249-
250-
# LLM Settings
251-
LLM_TEMPERATURE=0.2
252-
LLM_MAX_TOKENS=4096
253-
254-
# Code Translation Settings
255-
# MAX_CODE_LENGTH: Maximum input code length in characters
256-
# Note: For Enterprise Inference with CodeLlama-34b (max tokens: 5196)
257-
# Set to 4000 characters to stay safely under the token limit with prompt overhead
258-
MAX_CODE_LENGTH=4000
259-
MAX_FILE_SIZE=10485760
260-
261-
# CORS Configuration
262-
CORS_ALLOW_ORIGINS=["http://localhost:5173", "http://localhost:3000"]
263-
264-
# Local URL Endpoint (only needed for non-public domains)
265-
# If using a local domain like api.example.com mapped to localhost, set to the domain without https://
266-
# Otherwise, set to: not-needed
267-
LOCAL_URL_ENDPOINT=not-needed
268-
269-
# SSL Verification Settings
270-
# Set to false only for dev with self-signed certs
271-
VERIFY_SSL=true
184+
cp .env.example .env
272185
```
186+
Then modify it as needed, with special consideration to certain environment variables mentioned below. Read through the .env file for full instructions.
273187

274188
**Important Configuration Notes:**
275189

276-
- **INFERENCE_API_ENDPOINT**: Your actual inference service URL (replace `https://your-api-endpoint.com/deployment`)
277-
- For APISIX/Keycloak deployments, the model name must be included in the endpoint URL (e.g., `https://apisix-gateway.example.com/CodeLlama-34b-Instruct-hf`)
190+
- **INFERENCE_API_ENDPOINT**: Your actual inference service URL (replace `https://api.example.com`)
191+
- For APISIX/Keycloak deployments, the model name must be included in the endpoint URL (e.g., `https://api.example.com/CodeLlama-34b-Instruct-hf`)
278192
- **INFERENCE_API_TOKEN**: Your actual pre-generated authentication token
279-
- **LOCAL_URL_ENDPOINT**: Only needed if using local domain mapping (see [Local Development Configuration](#local-development-configuration))
193+
- **INFERENCE_MODEL_NAME**: Use the exact model name from your inference service
194+
- To check available models: `curl https://api.example.com/v1/models -H "Authorization: Bearer your-token"`
195+
- **LOCAL_URL_ENDPOINT**: Only needed if using local domain mapping (i.e. `api.example.com` mapped to localhost) for Docker containers to resolve correctly.
196+
- Use the domain name from INFERENCE_API_ENDPOINT without `https://`
197+
- For public domains or cloud-hosted endpoints, leave the default value `not-needed`
280198
- **VERIFY_SSL**: Controls SSL certificate verification (default: `true`)
281199
- Set to `false` only for development environments with self-signed certificates
282200
- Keep as `true` for production environments
@@ -371,14 +289,3 @@ docker compose down
371289
For comprehensive troubleshooting guidance, common issues, and solutions, refer to:
372290

373291
[Troubleshooting Guide - TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
374-
375-
---
376-
377-
## Additional Info
378-
379-
The following models have been validated with code-translation:
380-
381-
| Model | Hardware |
382-
|-------|----------|
383-
| **codellama/CodeLlama-34b-Instruct-hf** | Gaudi |
384-
| **Qwen/Qwen3-4B-Instruct-2507** | Xeon |

0 commit comments

Comments
 (0)