Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| pipe = pipeline( | |
| "text-generation", | |
| model="Qwen/Qwen2.5-1.5B-Instruct" | |
| ) | |
| def analyze_code(code): | |
| prompt = f""" | |
| 너는 숙련된 소프트웨어 개발자다. | |
| 아래 코드를 분석하고: | |
| - 코드가 하는 일 설명 | |
| - 문제점 | |
| - 개선점 | |
| 을 간결하고 정확하게 작성해라. | |
| 코드: | |
| {code} | |
| 답변: | |
| """ | |
| result = pipe( | |
| prompt, | |
| max_new_tokens=200, | |
| temperature=0.3, | |
| do_sample=True | |
| ) | |
| output = result[0]["generated_text"] | |
| # 프롬프트 제거 | |
| output = output.replace(prompt, "").strip() | |
| return output | |
| demo = gr.Interface( | |
| fn=analyze_code, | |
| inputs=gr.Textbox( | |
| lines=15, | |
| placeholder="코드를 입력하세요...", | |
| label="코드 입력" | |
| ), | |
| outputs=gr.Textbox( | |
| lines=15, | |
| label="AI 분석 결과" | |
| ), | |
| title="AI 개발 도우미", | |
| description="코드를 분석하고 설명해주는 AI 도우미" | |
| ) | |
| demo.launch() |