-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from windsonsea/encl
[en] Add models pages
- Loading branch information
Showing
9 changed files
with
286 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ hide: | |
- 提供商:如百川智能、GLM、Meta 等 | ||
- 模型类型:如文本生成、视觉理解、视频生成等 | ||
- 也可以输入关键词快速定位某一种模型 | ||
|
||
![model plaza](./images/models01.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters