Skip to content

Commit 089afdc

Browse files
committed
docs: update docs/customize/custom-llm-server.md with Moonshot AI example
- Refactor JSON structure to use array format for "messages". - Add an official Moonshot AI example to the customization guide. - Include a Python code snippet demonstrating how to interact with the Moonshot AI API. This change improves the readability of the JSON configuration and provides a practical example for users to understand how to customize their LLM server with Moonshot AI integration. The Python code snippet serves as a clear guide for users to follow when setting up their API calls.
1 parent 6b9707a commit 089afdc

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

docs/customize/custom-llm-server.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,41 @@ And the request body will be:
114114

115115
```json
116116
{
117-
"user": "12345",
118-
"model": "gpt-4",
119-
"messages": [{"role": "user", "message": "..."}]
120-
}
117+
"user": "12345",
118+
"model": "gpt-4",
119+
"messages": [
120+
{
121+
"role": "user",
122+
"message": "..."
123+
}
124+
]
125+
}
121126
```
122127

123128
### Moonshot AI example
124129

130+
Official Moonshot AI doc: https://platform.moonshot.cn/docs/api-reference
131+
132+
```
133+
from openai import OpenAI
134+
135+
client = OpenAI(
136+
api_key="MOONSHOT_API_KEY",
137+
base_url="https://api.moonshot.cn/v1",
138+
)
139+
140+
completion = client.chat.completions.create(
141+
model="moonshot-v1-8k",
142+
messages=[
143+
{"role": "system", "content": "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一些涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"},
144+
{"role": "user", "content": "你好,我叫李雷,1+1等于多少?"}
145+
],
146+
temperature=0.3,
147+
)
148+
149+
print(completion.choices[0].message)
150+
```
151+
125152
Engine Server:
126153

127154
```

0 commit comments

Comments
 (0)