Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
| import torch | |
| # โ ูู ูุฐุฌ ุฎููู ู ูุงุณุจ ูู CPU | |
| model_id = "bert-base-multilingual-cased" | |
| # โ ุชุญู ูู ุงููู ูุฐุฌ ูุงูุชููู | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_id, | |
| torch_dtype=torch.float32, | |
| #device_map="cpu" | |
| ) | |
| # โ ุฅุนุฏุงุฏ pipeline ุงููุตู | |
| generator = pipeline( | |
| "text-generation", | |
| model=model, | |
| tokenizer=tokenizer, | |
| max_new_tokens=256, | |
| temperature=0.7, | |
| return_full_text=False | |
| ) | |
| SYSTEM_PROMPT = """ | |
| You are an expert business analyst. Your task is to classify the business idea as either: | |
| 1. Startup: Innovative, scalable, tech-driven concept targeting rapid growth and unconventional funding. | |
| 2. Traditional Business: Conventional model focusing on local markets with traditional funding sources. | |
| Provide only: | |
| 1. Classification: "Startup" or "Traditional Business" | |
| 2. Reason: A brief 1-2 sentence explanation of your decision | |
| Focus specifically on whether the idea shows: | |
| - High innovation and scalability (Startup) | |
| - Conventional approach with local focus (Traditional Business) | |
| Example Response: | |
| "Classification: Startup | |
| Reason: This AI-powered platform demonstrates high innovation and scalability potential with its technology-driven solution targeting global markets." | |
| """ | |
| # โ ุฏุงูุฉ ุงูุชุญููู | |
| def analyze_idea(user_input): | |
| try: | |
| full_prompt = f"{SYSTEM_PROMPT}\n\nUser's idea: {user_input}" | |
| output = generator(full_prompt)[0]['generated_text'] | |
| return output.strip() | |
| except Exception as e: | |
| return f"โ Error analyzing idea:\n{str(e)}" | |
| # โ ูุงุฌูุฉ Gradio | |
| iface = gr.Interface( | |
| fn=analyze_idea, | |
| inputs=gr.Textbox(lines=5, label="๐ก Enter your business idea"), | |
| outputs=gr.Textbox(label="๐ Analysis & Classification"), | |
| title="๐ Is Your Idea a Startup or Traditional?", | |
| description="Describe your business idea. This smart assistant will classify it and give you insights based on growth, innovation, tech-dependency, and more.", | |
| theme="default", # ุจุฅู ูุงูู ุชุฌุฑุจุฉ "soft" ุฃู "huggingface" | |
| allow_flagging="never" | |
| ) | |
| iface.launch() | |