captain1221 commited on
Commit
a28f8d6
·
verified ·
1 Parent(s): 842c13d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ 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()