mirror of
https://github.com/hustcer/deepseek-review.git
synced 2026-05-13 05:16:05 +08:00
breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN (#50)
* breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN * breaking: Change DEEPSEEK_TOKEN to CHAT_TOKEN
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
# Usage: Copy this file to .env and replace the values with your own
|
# Usage: Copy this file to .env and replace the values with your own
|
||||||
# WARNING: Do not commit the actual .env file to version control as it may contain sensitive information.
|
# WARNING: Do not commit the actual .env file to version control as it may contain sensitive information.
|
||||||
|
|
||||||
# DEEPSEEK_TOKEN: Obtain this token from your Deepseek account settings
|
# CHAT_TOKEN: Obtain this token from your Deepseek account settings
|
||||||
DEEPSEEK_TOKEN='Your Deepseek API token'
|
CHAT_TOKEN='Your Deepseek API token'
|
||||||
# GITHUB_TOKEN: Your GitHub API token to query GitHub PR changes
|
# GITHUB_TOKEN: Your GitHub API token to query GitHub PR changes
|
||||||
# Generate this token from your GitHub account with the necessary permissions
|
# Generate this token from your GitHub account with the necessary permissions
|
||||||
GITHUB_TOKEN='Your GitHub API token'
|
GITHUB_TOKEN='Your GitHub API token'
|
||||||
|
|||||||
2
.github/workflows/basic.yml
vendored
2
.github/workflows/basic.yml
vendored
@@ -20,4 +20,4 @@ jobs:
|
|||||||
- name: Deepseek Code Review
|
- name: Deepseek Code Review
|
||||||
uses: hustcer/deepseek-review@develop
|
uses: hustcer/deepseek-review@develop
|
||||||
with:
|
with:
|
||||||
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
|
chat-token: ${{ secrets.CHAT_TOKEN }}
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ jobs:
|
|||||||
- name: Deepseek Code Review
|
- name: Deepseek Code Review
|
||||||
uses: hustcer/deepseek-review@v1
|
uses: hustcer/deepseek-review@v1
|
||||||
with:
|
with:
|
||||||
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
|
chat-token: ${{ secrets.CHAT_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Input Parameters
|
## Input Parameters
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| -------------- | ------ | ----------------------------------------------------------------------- |
|
| -------------- | ------ | ----------------------------------------------------------------------- |
|
||||||
| deepseek-token | String | Required, Deepseek API Token |
|
| chat-token | String | Required, Deepseek API Token |
|
||||||
| model | String | Optional, the model used for code review, defaults to `deepseek-chat` |
|
| model | String | Optional, the model used for code review, defaults to `deepseek-chat` |
|
||||||
| base-url | String | Optional, Deepseek API Base URL, defaults to `https://api.deepseek.com` |
|
| base-url | String | Optional, Deepseek API Base URL, defaults to `https://api.deepseek.com` |
|
||||||
| sys-prompt | String | Optional, system prompt corresponding to `$sys_prompt` in the payload, default value see note below |
|
| sys-prompt | String | Optional, system prompt corresponding to `$sys_prompt` in the payload, default value see note below |
|
||||||
@@ -99,7 +99,7 @@ Flags:
|
|||||||
-h, --help: Display the help message for this command
|
-h, --help: Display the help message for this command
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
token <string>: Your Deepseek API token, fallback to DEEPSEEK_TOKEN (optional)
|
token <string>: Your Deepseek API token, fallback to CHAT_TOKEN (optional)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ jobs:
|
|||||||
- name: Deepseek Code Review
|
- name: Deepseek Code Review
|
||||||
uses: hustcer/deepseek-review@v1
|
uses: hustcer/deepseek-review@v1
|
||||||
with:
|
with:
|
||||||
deepseek-token: ${{ secrets.DEEPSEEK_TOKEN }}
|
chat-token: ${{ secrets.CHAT_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 输入参数
|
## 输入参数
|
||||||
|
|
||||||
| 名称 | 类型 | 描述 |
|
| 名称 | 类型 | 描述 |
|
||||||
| -------------- | ------ | -------------------------------------------------------------- |
|
| -------------- | ------ | -------------------------------------------------------------- |
|
||||||
| deepseek-token | String | 必填,Deepseek API Token |
|
| chat-token | String | 必填,Deepseek API Token |
|
||||||
| model | String | 可选,配置代码审核选用的模型,默认为 `deepseek-chat` |
|
| model | String | 可选,配置代码审核选用的模型,默认为 `deepseek-chat` |
|
||||||
| base-url | String | 可选,Deepseek API Base URL, 默认为 `https://api.deepseek.com` |
|
| base-url | String | 可选,Deepseek API Base URL, 默认为 `https://api.deepseek.com` |
|
||||||
| sys-prompt | String | 可选,系统 Prompt 对应入参中的 `$sys_prompt`, 默认值见后文注释 |
|
| sys-prompt | String | 可选,系统 Prompt 对应入参中的 `$sys_prompt`, 默认值见后文注释 |
|
||||||
@@ -97,7 +97,7 @@ Flags:
|
|||||||
-h, --help: Display the help message for this command
|
-h, --help: Display the help message for this command
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
token <string>: Your Deepseek API token, fallback to DEEPSEEK_TOKEN (optional)
|
token <string>: Your Deepseek API token, fallback to CHAT_TOKEN (optional)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ branding:
|
|||||||
color: 'purple'
|
color: 'purple'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
deepseek-token:
|
chat-token:
|
||||||
required: true
|
required: true
|
||||||
description: 'Your deepseek API token.'
|
description: 'Your deepseek API token.'
|
||||||
model:
|
model:
|
||||||
@@ -52,7 +52,7 @@ runs:
|
|||||||
let ghToken = '${{ github.token }}'
|
let ghToken = '${{ github.token }}'
|
||||||
let baseUrl = '${{inputs.base-url}}'
|
let baseUrl = '${{inputs.base-url}}'
|
||||||
let repo = '${{ github.repository }}'
|
let repo = '${{ github.repository }}'
|
||||||
let token = '${{inputs.deepseek-token}}'
|
let token = '${{inputs.chat-token}}'
|
||||||
let sysPrompt = '${{inputs.sys-prompt}}'
|
let sysPrompt = '${{inputs.sys-prompt}}'
|
||||||
let userPrompt = '${{inputs.user-prompt}}'
|
let userPrompt = '${{inputs.user-prompt}}'
|
||||||
let pr = '${{ github.event.pull_request.number }}'
|
let pr = '${{ github.event.pull_request.number }}'
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ commit_parsers = [
|
|||||||
{ message = "^doc", group = "Documentation"},
|
{ message = "^doc", group = "Documentation"},
|
||||||
{ message = "^perf", group = "Performance"},
|
{ message = "^perf", group = "Performance"},
|
||||||
{ message = "^refactor", group = "Refactor"},
|
{ message = "^refactor", group = "Refactor"},
|
||||||
|
{ message = "^breaking", group = "Breaking Changes"},
|
||||||
{ message = "^style", group = "Styling"},
|
{ message = "^style", group = "Styling"},
|
||||||
{ message = "^test", group = "Testing"},
|
{ message = "^test", group = "Testing"},
|
||||||
{ message = "^chore\\(release\\): prepare for", skip = true},
|
{ message = "^chore\\(release\\): prepare for", skip = true},
|
||||||
|
|||||||
14
nu/review.nu
14
nu/review.nu
@@ -10,7 +10,7 @@
|
|||||||
# Description: A script to do code review by deepseek
|
# Description: A script to do code review by deepseek
|
||||||
# Env vars:
|
# Env vars:
|
||||||
# GITHUB_TOKEN: Your GitHub API token
|
# GITHUB_TOKEN: Your GitHub API token
|
||||||
# DEEPSEEK_TOKEN: Your Deepseek API token
|
# CHAT_TOKEN: Your Deepseek API token
|
||||||
# BASE_URL: Deepseek API base URL
|
# BASE_URL: Deepseek API base URL
|
||||||
# SYSTEM_PROMPT: System prompt message
|
# SYSTEM_PROMPT: System prompt message
|
||||||
# USER_PROMPT: User prompt message
|
# USER_PROMPT: User prompt message
|
||||||
@@ -40,7 +40,7 @@ const DEFAULT_OPTIONS = {
|
|||||||
|
|
||||||
# Use Deepseek AI to review code changes locally or in GitHub Actions
|
# Use Deepseek AI to review code changes locally or in GitHub Actions
|
||||||
export def --env deepseek-review [
|
export def --env deepseek-review [
|
||||||
token?: string, # Your Deepseek API token, fallback to DEEPSEEK_TOKEN env var
|
token?: string, # Your Deepseek API token, fallback to CHAT_TOKEN env var
|
||||||
--debug(-d), # Debug mode
|
--debug(-d), # Debug mode
|
||||||
--repo(-r): string, # GitHub repository name, e.g. hustcer/deepseek-review
|
--repo(-r): string, # GitHub repository name, e.g. hustcer/deepseek-review
|
||||||
--pr-number(-n): string, # GitHub PR number
|
--pr-number(-n): string, # GitHub PR number
|
||||||
@@ -54,7 +54,7 @@ export def --env deepseek-review [
|
|||||||
]: nothing -> nothing {
|
]: nothing -> nothing {
|
||||||
$env.config.table.mode = 'psql'
|
$env.config.table.mode = 'psql'
|
||||||
let is_action = ($env.GITHUB_ACTIONS? == 'true')
|
let is_action = ($env.GITHUB_ACTIONS? == 'true')
|
||||||
let token = $token | default $env.DEEPSEEK_TOKEN?
|
let token = $token | default $env.CHAT_TOKEN?
|
||||||
let repo = $repo | default $env.DEFAULT_GITHUB_REPO?
|
let repo = $repo | default $env.DEFAULT_GITHUB_REPO?
|
||||||
let header = [Authorization $'Bearer ($token)']
|
let header = [Authorization $'Bearer ($token)']
|
||||||
let url = $'($base_url)/chat/completions'
|
let url = $'($base_url)/chat/completions'
|
||||||
@@ -68,12 +68,12 @@ export def --env deepseek-review [
|
|||||||
}
|
}
|
||||||
$env.GH_TOKEN = $gh_token | default $env.GITHUB_TOKEN?
|
$env.GH_TOKEN = $gh_token | default $env.GITHUB_TOKEN?
|
||||||
if ($token | is-empty) {
|
if ($token | is-empty) {
|
||||||
print $'(ansi r)Please provide your Deepseek API token by setting `DEEPSEEK_TOKEN` or passing it as an argument.(ansi reset)'
|
print $'(ansi r)Please provide your Deepseek API token by setting `CHAT_TOKEN` or passing it as an argument.(ansi reset)'
|
||||||
return
|
exit $ECODE.INVALID_PARAMETER
|
||||||
}
|
}
|
||||||
if $is_action and not (is-installed gh) {
|
if $is_action and not (is-installed gh) {
|
||||||
print $'(ansi r)Please install GitHub CLI from https://cli.github.com (ansi reset)'
|
print $'(ansi r)Please install GitHub CLI from https://cli.github.com (ansi reset)'
|
||||||
return
|
exit $ECODE.MISSING_BINARY
|
||||||
}
|
}
|
||||||
let hint = if not $is_action and ($pr_number | is-empty) {
|
let hint = if not $is_action and ($pr_number | is-empty) {
|
||||||
$'🚀 Initiate the code review by Deepseek AI for local changes ...'
|
$'🚀 Initiate the code review by Deepseek AI for local changes ...'
|
||||||
@@ -98,13 +98,11 @@ export def --env deepseek-review [
|
|||||||
if ($response | is-empty) {
|
if ($response | is-empty) {
|
||||||
print $'(ansi r)Oops, No response returned from Deepseek API.(ansi reset)'
|
print $'(ansi r)Oops, No response returned from Deepseek API.(ansi reset)'
|
||||||
exit $ECODE.SERVER_ERROR
|
exit $ECODE.SERVER_ERROR
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if $debug { print $'Deepseek Response:'; hr-line; $response | table -e | print }
|
if $debug { print $'Deepseek Response:'; hr-line; $response | table -e | print }
|
||||||
if ($response | describe) == 'string' {
|
if ($response | describe) == 'string' {
|
||||||
print $'❌ Code review failed!Error: '; hr-line; print $response
|
print $'❌ Code review failed!Error: '; hr-line; print $response
|
||||||
exit $ECODE.SERVER_ERROR
|
exit $ECODE.SERVER_ERROR
|
||||||
return
|
|
||||||
}
|
}
|
||||||
let review = $response | get -i choices.0.message.content
|
let review = $response | get -i choices.0.message.content
|
||||||
if not $is_action {
|
if not $is_action {
|
||||||
|
|||||||
Reference in New Issue
Block a user