import gradio as gr import requests import os ACCESS_TOKEN = os.getenv("HF_TOKEN") def respond(message, max_tokens=512, temperature=0.7, top_p=0.95): data = { "model": "command-r-plus:104b-fp16", "prompt": message, "max_tokens": max_tokens, "temperature": temperature, "top_p": top_p } response = requests.post("http://hugpu.ai:7877/api/generate", json=data) try: generated_text = response.json().get('generated_text', '') except json.JSONDecodeError as e: print("Failed to decode JSON from response:", response.text) generated_text = "An error occurred while processing your request." return generated_text demo = gr.Interface( fn=respond, inputs=[ gr.Textbox(label="Your Message", placeholder="Type your message here..."), gr.Slider(minimum=1, maximum=2048, value=512, label="Max Tokens"), gr.Slider(minimum=0.1, maximum=4.0, value=0.7, label="Temperature"), gr.Slider(minimum=0.1, maximum=1.0, value=0.95, label="Top-P") ], outputs=gr.Textbox(), title="Advanced AI Chatbot", description="Enter your message and receive a response generated by an advanced AI model.", theme="Nymbo/Nymbo_Theme" ) if __name__ == "__main__": demo.launch()