@things-factory/codelingua 7.0.6 → 7.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.development.js +3 -0
- package/config/config.production.js +3 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/codereview-completion.d.ts +1 -0
- package/dist-server/controllers/codereview-completion.js +40 -0
- package/dist-server/controllers/codereview-completion.js.map +1 -0
- package/dist-server/controllers/index.d.ts +1 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/controllers/codereview-completion.ts +36 -0
- package/server/controllers/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/codelingua",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.7",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@things-factory/shell": "^7.0.6",
|
|
35
35
|
"openai": "^3.3.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6c9d22d79abfb199bd741f6504b29add846b46a9"
|
|
38
38
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { client } from './openai-connection'
|
|
2
|
+
|
|
3
|
+
const SYSTEM_MESSAGE = `You are an expert software engineer with a deep understanding of multiple programming languages, including Python, JavaScript, Java, and C++. Your role is to analyze, review, and provide insights on code snippets, highlighting potential issues, suggesting improvements, and explaining complex parts of the code. Respond in a clear, concise, and professional manner.
|
|
4
|
+
|
|
5
|
+
Here's the code for analysis:
|
|
6
|
+
|
|
7
|
+
<code snippet>
|
|
8
|
+
|
|
9
|
+
Please provide:
|
|
10
|
+
1. An overall assessment of the code quality.
|
|
11
|
+
2. Identification of any potential bugs or issues.
|
|
12
|
+
3. Suggestions for improving the code.
|
|
13
|
+
4. An explanation of any complex or non-obvious parts of the code.
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
export const codereviewCompletion = async (codeDiff: string): Promise<string> => {
|
|
17
|
+
try {
|
|
18
|
+
const completion = await client.createChatCompletion({
|
|
19
|
+
model: 'gpt-3.5-turbo',
|
|
20
|
+
messages: [
|
|
21
|
+
{
|
|
22
|
+
role: 'system',
|
|
23
|
+
content: SYSTEM_MESSAGE
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
role: 'user',
|
|
27
|
+
content: `Review the following code:\n\n${codeDiff}`
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
})
|
|
31
|
+
return completion.data.choices[0].message.content
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error fetching OpenAI review:', error)
|
|
34
|
+
return 'The Code Lingua service is currently unavailable. Please contact your system administrator.'
|
|
35
|
+
}
|
|
36
|
+
}
|