naman1102 commited on
Commit
e0b6f12
·
1 Parent(s): 6245b3b
Files changed (3) hide show
  1. analyzer.py +19 -0
  2. app.py +1 -1
  3. requirements.txt +1 -2
analyzer.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import os
3
+
4
+ def analyze_code(code: str) -> str:
5
+ """
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 = openai.ChatCompletion.create(
11
+ model="gpt-4.1-mini", # GPT-4.1 mini
12
+ messages=[
13
+ {"role": "system", "content": system_prompt},
14
+ {"role": "user", "content": code}
15
+ ],
16
+ max_tokens=512,
17
+ temperature=0.7
18
+ )
19
+ return response.choices[0].message["content"]
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import regex as re
3
  import csv
4
  import pandas as pd
5
-
6
 
7
  def process_repo_input(text):
8
  if not text:
 
2
  import regex as re
3
  import csv
4
  import pandas as pd
5
+ # from hf_utils import download_space_repo
6
 
7
  def process_repo_input(text):
8
  if not text:
requirements.txt CHANGED
@@ -1,4 +1,3 @@
1
  gradio
2
  pandas
3
- csv
4
- regex
 
1
  gradio
2
  pandas
3
+