Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
| model_name = "King-8/confidence-feedback" # Replace with your actual path if needed | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
| generator = pipeline("text2text-generation", model=model, tokenizer=tokenizer) | |
| def generate_feedback(prompt): | |
| result = generator(prompt, max_length=50, do_sample=False)[0]["generated_text"] | |
| return result | |
| examples = [ | |
| "I don't think I can do this.", | |
| "I'm proud of what I accomplished.", | |
| "I believe I'm ready for the challenge.", | |
| ] | |
| description = """ | |
| ## Confidence Feedback Generator β¨ | |
| Enter a statement β confident or not β and the model will give supportive, personalized feedback. | |
| Try examples like: | |
| - βI always doubt myself.β | |
| - βI'm proud of how I handled that.β | |
| - βI feel nervous before presenting.β | |
| """ | |
| iface = gr.Interface( | |
| fn=generate_feedback, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter your statement here..."), | |
| outputs="text", | |
| examples=examples, | |
| title="Confidence Feedback Generator", | |
| description=description | |
| ) | |
| iface.launch() | |