import gradio as gr from huggingface_hub import InferenceClient # Initialize the inference client client = InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO") def generate_response(prompt, max_length=512, temperature=0.7): """Generate a response from the model and check metadata.""" response = client.text_generation( prompt, max_new_tokens=max_length, temperature=temperature, details=True # This may provide extra model info ) print(f"Response Metadata: {response}") # Check if model details are in the response return response["generated_text"] if isinstance(response, dict) else response print(f"Using model: {client.model_id}") # Define the Gradio interface iface = gr.Interface( fn=generate_response, inputs=[ gr.Textbox(label="Input Prompt"), gr.Slider(minimum=50, maximum=1024, value=512, step=50, label="Max Length"), gr.Slider(minimum=0.1, maximum=1.5, value=0.7, step=0.1, label="Temperature"), ], outputs=gr.Textbox(label="Generated Response"), title="Nous Hermes 2 Mixtral AI Chatbot", description="An interactive chatbot powered by Nous Hermes 2 Mixtral 8x7B DPO.", ) # Launch the app if __name__ == "__main__": iface.launch()