captain1221 commited on
Commit
444170b
·
verified ·
1 Parent(s): a28f8d6

모델 교

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -3,41 +3,53 @@ import gradio as gr
3
 
4
  pipe = pipeline(
5
  "text-generation",
6
- model="TinyLlama/TinyLlama-1.1B-Chat-v1.0"
7
  )
8
 
9
  def analyze_code(code):
10
  prompt = f"""
11
- 다음 코드를 분석해줘.
12
 
13
- 1. 코드 설명
14
- 2. 문제점
15
- 3. 개선 아이디어
 
 
 
16
 
17
  코드:
18
  {code}
 
 
19
  """
20
 
21
  result = pipe(
22
  prompt,
23
- max_new_tokens=300,
24
- temperature=0.7
 
25
  )
26
 
27
- return result[0]["generated_text"]
 
 
 
 
 
28
 
29
  demo = gr.Interface(
30
  fn=analyze_code,
31
  inputs=gr.Textbox(
32
  lines=15,
 
33
  label="코드 입력"
34
  ),
35
  outputs=gr.Textbox(
36
- lines=20,
37
  label="AI 분석 결과"
38
  ),
39
  title="AI 개발 도우미",
40
- description="코드를 분석하고 설명해주는 AI"
41
  )
42
 
43
  demo.launch()
 
3
 
4
  pipe = pipeline(
5
  "text-generation",
6
+ model="Qwen/Qwen2.5-1.5B-Instruct"
7
  )
8
 
9
  def analyze_code(code):
10
  prompt = f"""
11
+ 너는 숙련된 소프트웨어 개발자다.
12
 
13
+ 아래 코드 분석하고:
14
+ - 코드가 하는 일 설명
15
+ - 문제점
16
+ - 개선점
17
+
18
+ 을 간결하고 정확하게 작성해라.
19
 
20
  코드:
21
  {code}
22
+
23
+ 답변:
24
  """
25
 
26
  result = pipe(
27
  prompt,
28
+ max_new_tokens=200,
29
+ temperature=0.3,
30
+ do_sample=True
31
  )
32
 
33
+ output = result[0]["generated_text"]
34
+
35
+ # 프롬프트 제거
36
+ output = output.replace(prompt, "").strip()
37
+
38
+ return output
39
 
40
  demo = gr.Interface(
41
  fn=analyze_code,
42
  inputs=gr.Textbox(
43
  lines=15,
44
+ placeholder="코드를 입력하세요...",
45
  label="코드 입력"
46
  ),
47
  outputs=gr.Textbox(
48
+ lines=15,
49
  label="AI 분석 결과"
50
  ),
51
  title="AI 개발 도우미",
52
+ description="코드를 분석하고 설명해주는 AI 도우미"
53
  )
54
 
55
  demo.launch()