Skip to content

Commit

Permalink
Merge pull request #187 from windsonsea/encl
Browse files Browse the repository at this point in the history
[en] Add models pages
  • Loading branch information
windsonsea authored Dec 26, 2024
2 parents 560ddde + 6dab135 commit 50638dd
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 7 deletions.
68 changes: 68 additions & 0 deletions docs/zh/docs/en/models/apikey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# API Key Management

API Key is the core credential for calling model services, used to verify user identity and protect data security.

## Description

- Purpose of API Key:

- API Key is a necessary credential for calling model services, used for identity verification.
- With the API Key, you can securely call deployed model services.

- Security Tips:

- Please keep the API Key safe and avoid exposing it in client code or public environments.
- If the API Key is leaked, please delete it promptly and regenerate a new Key.

## Creating an API Key

1. On the **API Key Management** page, click the **Create** button at the top right corner.
2. In the pop-up window, fill in the name of the API Key (e.g., test-key) to identify its purpose or associated project.
3. Click **Confirm**, and the system will generate a new API Key.

!!! note

After creation, please save the API Key when it is first displayed, as the complete key will not be shown again.

## Viewing API Keys

- The API Key list will display all created API Keys:
- Name: The identifying name for the API Key, helping users differentiate between Keys for different purposes.
- API Key: Partially displays the key content, for reference only.
- Creation Time: The time the API Key was generated.
- Click the refresh button at the top right corner to update the Key list.

## Deleting an API Key

1. Find the API Key you wish to delete in the list.
2. Click on the row to perform the delete operation.
3. Confirm the delete operation in the pop-up window.
4. After deletion, the API Key will immediately become invalid, and all service calls relying on this Key will be rejected.

## Using API Key to Call Services

When calling model services, you need to add the following field in the HTTP request header:

```http
Authorization: Bearer {API_KEY}
```

Example:

```shell
curl 'https://sh-02.d.run/v1/chat/completions' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-x1VDTAFB7Ra1hldATbncOa_dddVttDvRHQibTA-Oi7ucU" \
-d '{
"model": "u-8105f7322477/test",
"messages": [{"role": "user", "content": "Hello, model!"}],
"temperature": 0.7
}'
```

## Notes

- API Key Quantity Limit: Each account is allowed to create a limited number of API Keys, please allocate them reasonably as needed.
- Key Leak Handling: If you discover a key leak, please immediately delete the old key and recreate a new key.
- Key Permission Management: Different API Keys can be used for different projects or services, facilitating permission isolation.
- Regularly Update Keys: For security reasons, it is recommended to periodically delete old Keys and generate new Keys.
36 changes: 36 additions & 0 deletions docs/zh/docs/en/models/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
hide:
- toc
---

# Model Deployment

You can deploy models from the **Model Square** or **Model Services**. The parameters are explained as follows:

- Select the model to deploy (e.g., Qwen2-0.5B-Instruct), ensuring the chosen model meets your business needs and task scenarios.
- Model service name must meet the following requirements:
- Length limit: 2-64 characters
- Character limit: Only lowercase letters, numbers, and hyphens (-) are supported, and it must start and end with a lowercase letter or number.
- Example: text-gen-service or model-01
- Region
- Select the region for service deployment (e.g., "Shanghai Area 2").
- The region selection should be based on business coverage and latency requirements.
- Number of instances
- Configure the number of instances to deploy. Default value: 1
- Instance explanation: The more instances, the stronger the service's concurrency capability, but costs will increase accordingly.
- Billing method. d.run offers two billing modes:

1. Pay-as-you-go:
- Real-time billing based on usage, suitable for short-term use or dynamic demand users.
- Cost formula: Number of instances × hourly cost.
- Example: 1 instance × 3 Yuan/hour = 3 Yuan/hour.

2. Annual or monthly subscription (not currently supported):
- Purchase service instances in advance at a relatively discounted price, suitable for long-term users.
- After choosing this mode, the system will prompt the corresponding annual or monthly fee.

- View configuration costs:
- The bottom of the page will automatically display the calculation formula for configuration costs and the estimated costs.
- Example:
- Configuration cost: 3 Yuan/hour
- Calculation formula: 1 (number of instances) × 3 Yuan/hour.
Binary file added docs/zh/docs/en/models/images/models01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/zh/docs/en/models/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
hide:
- toc
---

# Model Plaza

The Model Plaza offers a diverse selection of models covering areas such as text generation, image understanding, and speech synthesis. It integrates hundreds of models from providers like Tongyi Qianwen, Mistral, Meta, Cohere, and more. Users can flexibly deploy models according to their business needs to achieve efficient real-time inference.

After logging into d.run, you can select **Model Plaza** from the left navigation bar to view a list of preset model cards.

Using the tags in the Model Plaza, you can quickly search the model list, supporting multiple tag selections, and you can clear the filter conditions at any time.

- Supported filter tags include:
- Providers: such as Baichuan Intelligence, GLM, Meta, etc.
- Model types: such as text generation, visual understanding, video generation, etc.
- You can also enter keywords to quickly locate a specific model.

![model plaza](./images/models01.png)
155 changes: 155 additions & 0 deletions docs/zh/docs/en/models/service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Model Services

Model services are a solution for quickly deploying open-source or fine-tuned large language models as callable services. With one-click deployment, the complex management of models is simplified into a standardized service format, compatible with mainstream model service API call capabilities, meeting the demand for immediate use.

- Model services allow users to call selected models to perform tasks such as text generation, dialogue processing, image generation, etc.
- Supports online experience of models.

The details of the model service include basic information about the service, authorization methods, and call examples.

## Basic Information

- Model Service Name: The name of the current service, used to identify this model service.
- Access Path Name: Each model service has a unique path name.
- Model Type: The model being used by the current service.
- Status: The current status of the service.
- Billing Method: The billing method for the current service.

## Authorization Methods

- API-Key Authorization:

- All API requests need to include an Authorization field in the HTTP Header for identity verification.
- Format: Authorization: Bearer {API_KEY}
- You can obtain the key through the "View My API-Key" link on the page.

- Security Advice: Store the API-Key on the backend server to avoid exposing the key in client-side code and prevent leakage.

## API Call Example

- Request URL: The POST request URL is `https://sh-02.d.run/v1/chat/completions`

### Request Example: Calling the API with curl

```shell
curl 'https://sh-02.d.run/v1/chat/completions' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Your API Key here>" \
-d '{
"model": "u-8105f7322477/test",
"messages": [{"role": "user", "content": "Say this is a test!"}],
"temperature": 0.7
}'
```

Parameter Explanation:

- model: The access path name of the model service (e.g., u-8105f7322477/test).
- messages: A list of dialogue history containing user input, for example:

```json
[{"role": "user", "content": "Say this is a test!"}]
```

- temperature: Controls the randomness of the generated results; a higher value results in more creative outputs, while a lower value yields more stable outputs.

### Response Example

```json
{
"id": "cmp-1d033c426254417b7b0675303b1d300",
"object": "chat.completion",
"created": 1733724462,
"model": "u-8105f7322477/test",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am a large language model. How can I assist you today?"
},
"tool_calls": []
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 15,
"total_tokens": 40
}
}
```

Response Field Explanation:

- id: A unique identifier for the generated result.
- model: The ID of the model service being called.
- choices: An array of results generated by the model.
- message: The generated content.
- content: The text content generated by the model.
- usage: Token usage for this call:
- prompt_tokens: The number of tokens for user input.
- completion_tokens: The number of tokens for the generated result.
- total_tokens: The total usage.

- Integration Development Examples

### Python Example Code

```python
# Compatible with OpenAI Python library v1.0.0 and above

from openai import OpenAI

client = OpenAI(
base_url="https://sh-02.d.run/v1/",
api_key="<Your API Key here>"
)

messages = [
{"role": "user", "content": "hello!"},
{"role": "user", "content": "Say this is a test?"}
]

response = client.chat.completions.create(
model="u-8105f7322477/test",
messages=messages
)

content = response.choices[0].message.content

print(content)
```

### Node.js Example Code

```js
const OpenAI = require('openai');

const openai = new OpenAI({
baseURL: 'https://sh-02.d.run/v1',
apiKey: '<Your API Key here>',
});

async function getData() {
try {
const chatCompletion = await openai.chat.completions.create({
model: 'u-8105f7322477/test',
messages: [
{ role: 'user', content: 'hello!' },
{ role: 'user', content: 'how are you?' },
],
});

console.log(chatCompletion.choices[0].message.content);
} catch (error) {
if (error instanceof OpenAI.APIError) {
console.error('API Error:', error.status, error.message);
console.error('Error details:', error.error);
} else {
console.error('Unexpected error:', error);
}
}
}

getData();
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ aiding in efficient algorithm research and inference tasks.

2. Fill in the basic information according to the requirements below and click **OK**

![Create Container Instance 2](../zestu/images/createpod2.png)
![Create Container Instance 2](images/createpod2.png)

| Name | Description |
|------|------------- |
Expand Down
Binary file added docs/zh/docs/models/images/models01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/zh/docs/models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ hide:
- 提供商:如百川智能、GLM、Meta 等
- 模型类型:如文本生成、视觉理解、视频生成等
- 也可以输入关键词快速定位某一种模型

![model plaza](./images/models01.png)
11 changes: 5 additions & 6 deletions docs/zh/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ plugins:
首页: Home
d.run 文档: d.run Documentation
注册账号: Register Account
算力云: Compute Clou
算力云: Compute Cloud
算力市场: Compute Market
容器实例: Container Instances
文件存储: File Storage
Expand Down Expand Up @@ -150,16 +150,15 @@ plugins:
d.run 是支撑生成式 AI 的理想平台: d.run is the Ideal Platform for Generative AI
K8s 与生成式 AI 珠联璧合: K8s and Generative AI Make a Perfect Match
OpenAI GPT-4o 完全免费: OpenAI GPT-4o is Completely Free
OpenAI 大型语言模型规范: OpenAI Large Language Model Specifications
OpenAI 大型语言模型规范: OpenAI LLM Specifications
2024大规模AI基础设施形势调研: 2024 Large-scale AI Infrastructure Survey
云原生人工智能白皮书: Cloud-native Artificial Intelligence White Paper
Kimi火了后国内其他大模型: Kimi Success and Other Domestic Large Models
Kimi火了后国内其他大模型: Kimi Success and Other Domestic LLM
DBRX 开源 LLM 介绍: Introduction to DBRX Open Source LLM
AI 流程编排化算力为算利: Transforms Compute into Profit
谁将替代 Transformer: Who Will Replace the Transformer
金融行业迎来大模型时代: Financial Industry Welcomes the Era of Large Models
智海拾贝: Wisdom from AI Industry
索引: Index
金融行业迎来大模型时代: Financial Industry Welcomes the LLM Era
智海拾贝: Knowledge from AI Industry
大模型: LLM
OpenAI: OpenAI
Hugging Face: Hugging Face
Expand Down

0 comments on commit 50638dd

Please sign in to comment.