-
Notifications
You must be signed in to change notification settings - Fork 1
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 #40 from GuoXiCheng/dev-c
add ai
- Loading branch information
Showing
7 changed files
with
60 additions
and
14 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
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
Empty file.
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,32 @@ | ||
# OpenAI API | ||
|
||
## 基本用法 | ||
|
||
可以使用POST请求向OpenAI API提交内容,其中**content**字段包含提问与回答的内容。 | ||
|
||
**temperature**用于控制生成文本的创造性,值越高,生成的文本越有创造性。 | ||
|
||
::: code-group | ||
|
||
<<< @/../projects/javascript-sandbox/src/openai/basic-usage.ts [Request] | ||
|
||
<<< @/../projects/javascript-sandbox/src/openai/basic-usage-output.json [Response] | ||
|
||
::: | ||
|
||
## 连续对话 | ||
|
||
连续对话需要把每一次的提问和回答都追加到`messages`数组中,以便OpenAI能够理解对话的上下文。 | ||
|
||
**role**可用于指定对话的角色: | ||
- `user`:表示用户的提问 | ||
- `assistant`:表示助手的回答 | ||
- `system`:用于定义整个对话的行为,通常放在`messages`数组的第一个元素 | ||
|
||
::: code-group | ||
|
||
<<< @/../projects/javascript-sandbox/src/openai/chat-usage.ts [Request] | ||
|
||
<<< @/../projects/javascript-sandbox/src/openai/chat-usage-output.json [Response] | ||
|
||
::: |
Empty file.
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
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