Spaces:
Sleeping
Sleeping
Update analyzer.py
Browse files- analyzer.py +5 -3
analyzer.py
CHANGED
@@ -6,9 +6,11 @@ def analyze_code(code: str) -> str:
|
|
6 |
Uses OpenAI's GPT-4.1 mini model to analyze the given code.
|
7 |
Returns the analysis as a string.
|
8 |
"""
|
|
|
|
|
9 |
system_prompt = "You are a helpful assistant. Analyze the code given to you. Provide insights, strengths, weaknesses, and suggestions for improvement."
|
10 |
-
response =
|
11 |
-
model="gpt-4
|
12 |
messages=[
|
13 |
{"role": "system", "content": system_prompt},
|
14 |
{"role": "user", "content": code}
|
@@ -16,7 +18,7 @@ def analyze_code(code: str) -> str:
|
|
16 |
max_tokens=512,
|
17 |
temperature=0.7
|
18 |
)
|
19 |
-
return response.choices[0].message
|
20 |
|
21 |
def combine_repo_files_for_llm(repo_dir="repo_files", output_file="combined_repo.txt"):
|
22 |
"""
|
|
|
6 |
Uses OpenAI's GPT-4.1 mini model to analyze the given code.
|
7 |
Returns the analysis as a string.
|
8 |
"""
|
9 |
+
from openai import OpenAI
|
10 |
+
client = OpenAI()
|
11 |
system_prompt = "You are a helpful assistant. Analyze the code given to you. Provide insights, strengths, weaknesses, and suggestions for improvement."
|
12 |
+
response = client.chat.completions.create(
|
13 |
+
model="gpt-4-1106-preview", # GPT-4.1 mini
|
14 |
messages=[
|
15 |
{"role": "system", "content": system_prompt},
|
16 |
{"role": "user", "content": code}
|
|
|
18 |
max_tokens=512,
|
19 |
temperature=0.7
|
20 |
)
|
21 |
+
return response.choices[0].message.content
|
22 |
|
23 |
def combine_repo_files_for_llm(repo_dir="repo_files", output_file="combined_repo.txt"):
|
24 |
"""
|