Spaces:
Sleeping
Sleeping
File size: 1,596 Bytes
fbebf66 70f8d75 fbebf66 70f8d75 fbebf66 70f8d75 fbebf66 70f8d75 cb9d075 fbebf66 70f8d75 fbebf66 70f8d75 fbebf66 70f8d75 fbebf66 70f8d75 fbebf66 70f8d75 b19dc43 67e38fa 70f8d75 |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
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
)
|