Spaces:
Runtime error
Runtime error
File size: 1,168 Bytes
a2d6aac 0fef5af a2d6aac c46b079 0fef5af a2d6aac 26a99da a2d6aac 0fef5af 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 33 |
import gradio as gr
from huggingface_hub import InferenceClient
# 初始化 Inference API 客戶端
model_id = "dingckc/FineLlama-3.1-8B"
api_token = ACCESS_KEY
inference = InferenceClient(model=model_id, token=api_token)
# 定義推理函數
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.
"""
# 使用 text_generation 方法進行推理
response = inference.text_generation(input_text)
return response[0]["generated_text"] if "generated_text" in response[0] else "No evaluation available."
# 使用 Gradio 構建界面
title_input = gr.Textbox(label="Essay Title")
essay_input = gr.Textbox(label="Essay Content", lines=10)
output_text = gr.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()
|