Bol-mini / app.py
Vivek7311's picture
Create app.py
f5558c0 verified
import gradio as gr
from transformers import pipeline
# Model aani files HF space chya main folder madhech ahet mhanun path "./" thevlay
model_path = "./"
print("Model load hot ahe, kripaya thamba...")
# Text-generation saathi pipeline banavli ahe
try:
# Jar tujha model text-classification kiva dusra asel tar "text-generation" badlu shaktos
pipe = pipeline("text-generation", model=model_path)
except Exception as e:
print(f"Model load kartana error aala: {e}")
def generate_text(prompt):
if not prompt:
return "Kripaya kahi tari text type kara."
try:
# Prompt model la deun output kadhne (max_length tu tujhya hishobane badlu shaktos)
output = pipe(prompt, max_length=150, do_sample=True, temperature=0.7)
return output[0]['generated_text']
except Exception as e:
return f"Kahitari chukla ahe (Error): {str(e)}"
# Gradio cha UI (User Interface)
demo = gr.Interface(
fn=generate_text,
inputs=gr.Textbox(lines=4, placeholder="Tula je vicharaychay te ithe type kar..."),
outputs=gr.Textbox(label="AI Model che Uttar:"),
title="🤖 Majha Swatacha AI Model",
description="Ha majha custom text AI model ahe jo Hugging Face var deploy kela ahe. Type kara aani test kara!",
theme="default"
)
# App chalu karne
if __name__ == "__main__":
demo.launch()