File size: 938 Bytes
7a01de3
c25b2b8
 
23cc739
d6a4b5c
 
c25b2b8
 
 
 
23cc739
d6a4b5c
c25b2b8
 
23cc739
d6a4b5c
6b6c12c
 
 
c25b2b8
6b6c12c
c25b2b8
 
 
d6a4b5c
 
c25b2b8
d6a4b5c
c25b2b8
 
6b6c12c
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
import logging
import gradio as gr
import asyncio
from codette_agent import CodetteAgent, load_json_config, setup_logging


class HuggingFaceChatbot:
    def __init__(self):
        config = load_json_config("config.json")
        setup_logging(config)
        self.codette = CodetteAgent(config)

    def setup_interface(self):
        async def chatbot_logic(user_input: str) -> str:
            return await self.codette.generate_response(user_input)

        def sync_chatbot(user_input: str) -> str:
            return asyncio.run(chatbot_logic(user_input))

        text_interface = gr.Interface(
            fn=sync_chatbot,
            inputs=gr.Textbox(label="Ask Codette Anything"),
            outputs=gr.Textbox(label="Codette's Thoughts"),
            title="🧠 Codette: Multimodal Reasoning Chatbot"
        )

        return text_interface

    def launch(self):
        app = self.setup_interface()
        app.launch()