""" Alloy Maintenance AI - Simplified Version Uses HuggingFace Inference API (no need to load full model) """ import gradio as gr from huggingface_hub import InferenceClient MODEL_NAME = "CodeMasterAbdul/alloy-phi3-steel-maintenance" client = InferenceClient(model=MODEL_NAME) def generate_response(prompt: str, max_tokens: int = 500, temperature: float = 0.3): try: response = client.text_generation( prompt, max_new_tokens=int(max_tokens), temperature=float(temperature), do_sample=temperature > 0, return_full_text=False ) return response except Exception as e: return f"Error: {str(e)}\n\nModel may be loading. Try again in 30 seconds." iface = gr.Interface( fn=generate_response, inputs=[ gr.Textbox(label="Maintenance Query", lines=5), gr.Slider(50, 1000, 500, label="Max Tokens"), gr.Slider(0.0, 1.0, 0.3, label="Temperature") ], outputs=gr.Textbox(label="AI Response", lines=15), title="🏭 Alloy Maintenance AI", examples=[ ["What causes bearing failure?", 500, 0.3], ["Explain vibration analysis", 500, 0.3], ] ) iface.launch(show_api=True)