Spaces:
Sleeping
Sleeping
import gradio as gr | |
from src.model.him_model import HIMModel | |
from config.model_config import HIMConfig | |
from config.environment_config import EnvironmentConfig | |
def initialize_model(): | |
model_config = HIMConfig() | |
env_config = EnvironmentConfig() | |
return HIMModel(model_config) | |
def chat( | |
message: str, | |
system_message: str = "You are a friendly Chatbot.", | |
max_tokens: int = 512, | |
temperature: float = 0.7, | |
top_p: float = 0.95 | |
): | |
input_data = { | |
"message": message, | |
"system_message": system_message, | |
"parameters": { | |
"max_tokens": max_tokens, | |
"temperature": temperature, | |
"top_p": top_p | |
} | |
} | |
result = model.generate_response(input_data) | |
return result["response"] | |
model = initialize_model() | |
interface = gr.Interface( | |
fn=chat, | |
inputs=[ | |
gr.Textbox(label="Message"), | |
gr.Textbox(label="System Message", value="You are a friendly Chatbot."), | |
gr.Slider(minimum=1, maximum=2048, value=512, label="Max Tokens"), | |
gr.Slider(minimum=0.1, maximum=1.0, value=0.7, label="Temperature"), | |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, label="Top P") | |
], | |
outputs=gr.Textbox(label="HIM Response"), | |
title="Hybrid Intelligence Matrix (HIM)", | |
description="Interact with the HIM system for advanced cognitive processing" | |
) | |
if __name__ == "__main__": | |
env_config = EnvironmentConfig() | |
interface.launch( | |
server_name=env_config.api_host, | |
server_port=env_config.api_port, | |
enable_cors=env_config.enable_cors | |
) | |