From b62a212374333e67713a802c92cd758d088ba518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gre=CC=81goire=20Compagnon?= Date: Tue, 26 Nov 2024 00:02:29 +0100 Subject: [PATCH] refactor(docs): update getDiff usage and add signal parameter in customization examples Updated the getDiff function calls in multiple documentation files to exclude unstaged changes by passing 'false'. Added comments to explain the parameter purpose. Introduced the AbortController signal in the streamComplete function to enhance handling of async operations. Changes apply to English and Chinese documentation. --- docs/docs/actions/how-to-customize.md | 6 ++++-- docs/docs/customize/deep-dives/configuration.md | 5 ++++- .../customize/tutorials/build-your-own-slash-command.md | 5 ++++- .../current/actions/how-to-customize.md | 5 ++++- .../customize/tutorials/build-your-own-slash-command.md | 5 ++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/docs/actions/how-to-customize.md b/docs/docs/actions/how-to-customize.md index 01cf2d064..81d33967b 100644 --- a/docs/docs/actions/how-to-customize.md +++ b/docs/docs/actions/how-to-customize.md @@ -33,9 +33,12 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + // The getDiff function takes a boolean parameter that indicates whether + // to include unstaged changes in the diff or not. + const diff = await sdk.ide.getDiff(false); // Pass false to exclude unstaged changes for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, + new AbortController().signal, { maxTokens: 20, }, @@ -47,7 +50,6 @@ export function modifyConfig(config: Config): Config { return config; } ``` - diff --git a/docs/docs/customize/deep-dives/configuration.md b/docs/docs/customize/deep-dives/configuration.md index dab15ac4c..2db1956fd 100644 --- a/docs/docs/customize/deep-dives/configuration.md +++ b/docs/docs/customize/deep-dives/configuration.md @@ -50,9 +50,12 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + // The getDiff function takes a boolean parameter that indicates whether + // to include unstaged changes in the diff or not. + const diff = await sdk.ide.getDiff(false); // Pass false to exclude unstaged changes for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, + new AbortController().signal, { maxTokens: 20, }, diff --git a/docs/docs/customize/tutorials/build-your-own-slash-command.md b/docs/docs/customize/tutorials/build-your-own-slash-command.md index b3fc25c3a..dc450cdd4 100644 --- a/docs/docs/customize/tutorials/build-your-own-slash-command.md +++ b/docs/docs/customize/tutorials/build-your-own-slash-command.md @@ -44,9 +44,12 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(true); + // The getDiff function takes a boolean parameter that indicates whether + // to include unstaged changes in the diff or not. + const diff = await sdk.ide.getDiff(false); // Pass false to exclude unstaged changes for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, + new AbortController().signal, { maxTokens: 20, }, diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md index 095d75918..2ffc4d0f2 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md @@ -33,9 +33,12 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + // getDiff 函数接受一个布尔参数,该参数指示是否 + // 在 diff 中包含未暂存的更改。 + const diff = await sdk.ide.getDiff(false); // 传递 false 以排除未暂存的更改 for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, + new AbortController().signal, { maxTokens: 20, }, diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md index 755bb2b14..ccf367094 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md @@ -44,9 +44,12 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + // getDiff 函数接受一个布尔参数,该参数指示是否 + // 在 diff 中包含未暂存的更改。 + const diff = await sdk.ide.getDiff(false); // 传递 false 以排除未暂存的更改 for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, + new AbortController().signal, { maxTokens: 20, },