Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add deepseek #378

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: add deepseek #378

wants to merge 1 commit into from

Conversation

wChenonly
Copy link
Contributor

@wChenonly wChenonly commented Jan 24, 2025

hi @mattzcarey ,I am having some problems with deepseek.
I get the response data, but I get an error when I use parseJson.

DEBUG Unparsed JSON json { "fileName": "/Users/wchenonly/work/gitHub/f/code-review-gpt/src/common/model/AIModel.ts", "riskScore": 2, "feedbackDetails": "1. The `temperature` parameter in `createDeepSeekModel` is being destructured with a default value of `0.0`, but this default value is not documented or explained. This could lead to confusion or unintended behavior if the default is not appropriate for all use cases. Consider adding a comment or documentation to clarify the default value.\n\n2. The `callStructuredModel` method in `createDeepSeekModel` does not handle potential errors during JSON parsing. If the API response is malformed, this could lead to runtime errors. Consider wrapping the `parseJson` call in a try-catch block to handle such cases gracefully.\n\ntypescript\ncallStructuredModel: async (prompt: string): Promise<IFeedback[]> => {\n try {\n const completion = await client.chat.completions.create({\n messages: [{ role: 'user', content: prompt }],\n model,\n temperature,\n });\n const content = completion.choices[0].message.content;\n return parseJson(content as string);\n } catch (error) {\n logger.error('Failed to parse JSON response', error);\n throw new Error('Failed to parse JSON response');\n }\n},\n```"
}

DEBUG   Escaped JSON \\`\\`\\`\bjson\b\\bn\b{\\bn\b  \"\bfileName\b\": \"/\bUsers\b/\bwchenonly\b/\bwork\b/\bgitHub\b/\bf\b/\bcode\b-\breview\b-\bgpt\b/\bsrc\b/\bcommon\b/\bmodel\b/\bAIModel\b.\bts\b\",\\bn\b  \"\briskScore\b\": \b2\b,\\bn\b  \"\bfeedbackDetails\b\": \"\b1\b. \bThe\b \`\btemperature\b\` \bparameter\b \bin\b \`\bcreateDeepSeekModel\b\` \bis\b \bbeing\b \bdestructured\b \bwith\b \ba\b \bdefault\b \bvalue\b \bof\b \`\b0\b.\b0\b\`, \bbut\b \bthis\b \bdefault\b \bvalue\b \bis\b \bnot\b \bdocumented\b \bor\b \bexplained\b. \bThis\b \bcould\b \blead\b \bto\b \bconfusion\b \bor\b \bunintended\b \bbehavior\b \bif\b \bthe\b \bdefault\b \bis\b \bnot\b \bappropriate\b \bfor\b \ball\b \buse\b \bcases\b. \bConsider\b \badding\b \ba\b \bcomment\b \bor\b \bdocumentation\b \bto\b \bclarify\b \bthe\b \bdefault\b \bvalue\b.\\\bn\b\\\bn2\b. \bThe\b \`\bcallStructuredModel\b\` \bmethod\b \bin\b \`\bcreateDeepSeekModel\b\` \bdoes\b \bnot\b \bhandle\b \bpotential\b \berrors\b \bduring\b \bJSON\b \bparsing\b. \bIf\b \bthe\b \bAPI\b \bresponse\b \bis\b \bmalformed\b, \bthis\b \bcould\b \blead\b \bto\b \bruntime\b \berrors\b. \bConsider\b \bwrapping\b \bthe\b \`\bparseJson\b\` \bcall\b \bin\b \ba\b \btry\b-\bcatch\b \bblock\b \bto\b \bhandle\b \bsuch\b \bcases\b \bgracefully\b.\\\bn\b\\\bn\b\\`\\`\\`\btypescript\b\\\bncallStructuredModel\b: \basync\b (\bprompt\b: \bstring\b): \bPromise\b<\bIFeedback\b[]> => {\\\bn\b  \btry\b {\\\bn\b    \bconst\b \bcompletion\b = \bawait\b \bclient\b.\bchat\b.\bcompletions\b.\bcreate\b({\\\bn\b      \bmessages\b: [{ \brole\b: '\buser\b', \bcontent\b: \bprompt\b }],\\\bn\b      \bmodel\b,\\\bn\b      \btemperature\b,\\\bn\b    });\\\bn\b    \bconst\b \bcontent\b = \bcompletion\b.\bchoices\b[\b0\b].\bmessage\b.\bcontent\b;\\\bn\b    \breturn\b \bparseJson\b(\bcontent\b \bas\b \bstring\b);\\\bn\b  } \bcatch\b (\berror\b) {\\\bn\b    \blogger\b.\berror\b('\bFailed\b \bto\b \bparse\b \bJSON\b \bresponse\b', \berror\b);\\\bn\b    \bthrow\b \bnew\b \bError\b('\bFailed\b \bto\b \bparse\b \bJSON\b \bresponse\b');\\\bn\b  }\\\bn\b},\\\bn\b\\`\\`\\`\"\\bn\b}\\bn\b\\`\\`\\`
ERROR   Error in processing prompt

 SyntaxError  JSON Parse error: Unrecognized token '\', 7, 39
error stack:
  • 

  • 

  • native      processTicksAndRejections
        native:7
DEBUG   Markdown report:



and I don't know how to use test:llm.

Hope to get your help and advice.

@@ -103,7 +103,7 @@ You can now run `code-review-gpt review` in the root directory of any git-enable

### Options

- `--ci` - Used with the `review` command. Options are --ci=("github" | "gitlab"). Defaults to "github" if no option is specified. Runs the application in CI mode. This will use the BASE_SHA and GITHUB_SHA environment variables to determine which files to review. It will also use the GITHUB_TOKEN environment variable to create a comment on the pull request with the review results.
- `--ci` - Used with the `review` command. Options are --ci=("github" | "gitlab" | "azdev"). Defaults to "github" if no option is specified. Runs the application in CI mode. This will use the BASE_SHA and GITHUB_SHA environment variables to determine which files to review. It will also use the GITHUB_TOKEN environment variable to create a comment on the pull request with the review results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this DeepSeek related?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants