|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
model_name = "microsoft/codebert-base" |
|
qa_pipeline = pipeline("question-answering", model=model_name, tokenizer=model_name) |
|
|
|
|
|
def answer_java_question(question, context): |
|
result = qa_pipeline({ |
|
"question": question, |
|
"context": context |
|
}) |
|
return result["answer"] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("<h1 style='text-align: center;'>Java Q&A Assistant</h1>") |
|
with gr.Row(): |
|
question = gr.Textbox(label="Sorunuz", placeholder="Java ile ilgili sorunuz...") |
|
context = gr.Textbox(label="Bağlam", placeholder="Java kodunuzu veya bağlamı buraya yapıştırabilirsiniz...", lines=5) |
|
btn = gr.Button("Cevapla") |
|
answer = gr.Textbox(label="Yanıt") |
|
|
|
btn.click(answer_java_question, inputs=[question, context], outputs=answer) |
|
|
|
demo.launch() |
|
|