Spaces:
Runtime error
Runtime error
File size: 1,143 Bytes
a2d6aac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
from huggingface_hub import InferenceApi
# 初始化 Inference API 客戶端
model_id = "dingckc/FineLlama-3.1-8B"
api_token = "hf_rhrXnUPYwsSCgmhidDnEXNXOkELWHLTr"
inference = InferenceApi(repo_id=model_id, token=api_token, task="text-generation")
# 定義推理函數
def evaluate_essay(title, essay):
input_text = f"""
Essay Title: {title}
Essay Rubric: Evaluate the argument based on clarity, coherence, lexical resource, and grammatical accuracy.
Essay: {essay}
Please generate a detailed evaluation based on the rubric provided above.
"""
response = inference(inputs=input_text)
return response.get("generated_text", "No evaluation available.")
# 使用 Gradio 構建界面
title_input = gr.inputs.Textbox(label="Essay Title")
essay_input = gr.inputs.Textbox(label="Essay Content", lines=10)
output_text = gr.outputs.Textbox(label="Evaluation Result")
gr.Interface(
fn=evaluate_essay,
inputs=[title_input, essay_input],
outputs=output_text,
title="Essay Evaluation",
description="Enter the title and content of your essay to receive an evaluation."
).launch()
|