Spaces:
Runtime error
Runtime error
File size: 1,264 Bytes
84b71aa f1c573d 0b975a5 84b71aa f1c573d 4a14dde f1c573d 84b71aa 4a14dde f1c573d 4a14dde f1c573d 84b71aa f1c573d 84b71aa f1c573d 84b71aa f1c573d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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()
|