update gradio
Browse files
    	
        controllers/gra_07_html/__init__.py
    ADDED
    
    | 
            File without changes
         | 
    	
        controllers/gra_07_html/gradio.py
    ADDED
    
    | @@ -0,0 +1,58 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            import gradio as gr
         | 
| 2 | 
            +
            def display_html():
         | 
| 3 | 
            +
                html_content = """
         | 
| 4 | 
            +
                <h1>Hello, Gradio!</h1>
         | 
| 5 | 
            +
                <p>This is an example of displaying HTML content using Gradio.</p>
         | 
| 6 | 
            +
                <ul>
         | 
| 7 | 
            +
                    <li>Item 11</li>
         | 
| 8 | 
            +
                    <li>Item 22</li>
         | 
| 9 | 
            +
                    <li>Item 33</li>
         | 
| 10 | 
            +
                    <a href="test">aaa</a>
         | 
| 11 | 
            +
                </ul>
         | 
| 12 | 
            +
                <script type="module">
         | 
| 13 | 
            +
            	import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/chat.bundle.es.js';
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            	createChat({
         | 
| 16 | 
            +
            	webhookUrl: 'https://kenken999-nodex-n8n-domain.hf.space/webhook/6264497c-6231-4023-abef-82b86f8e298b/chat',
         | 
| 17 | 
            +
            	webhookConfig: {
         | 
| 18 | 
            +
            		method: 'POST',
         | 
| 19 | 
            +
            		headers: {}
         | 
| 20 | 
            +
            	},
         | 
| 21 | 
            +
            	target: '#n8n-chat',
         | 
| 22 | 
            +
            	mode: 'window',
         | 
| 23 | 
            +
            	chatInputKey: 'chatInput',
         | 
| 24 | 
            +
            	chatSessionKey: 'sessionId',
         | 
| 25 | 
            +
            	metadata: {},
         | 
| 26 | 
            +
            	showWelcomeScreen: false,
         | 
| 27 | 
            +
            	defaultLanguage: 'en',
         | 
| 28 | 
            +
            	initialMessages: [
         | 
| 29 | 
            +
            		'質問をどうぞ Hi there! 👋',
         | 
| 30 | 
            +
            		'私の名前はリファスタアシスタントです今日は何の御用ですか??'
         | 
| 31 | 
            +
            	],
         | 
| 32 | 
            +
            	i18n: {
         | 
| 33 | 
            +
            		en: {
         | 
| 34 | 
            +
            			title: 'こんにちわリファスタアシスタントです! 👋',
         | 
| 35 | 
            +
            			subtitle: "Start a chat. We're here to help you 24/7.",
         | 
| 36 | 
            +
            			footer: '',
         | 
| 37 | 
            +
            			getStarted: 'New Conversation',
         | 
| 38 | 
            +
            			inputPlaceholder: 'Type your question..',
         | 
| 39 | 
            +
            		},
         | 
| 40 | 
            +
            	},
         | 
| 41 | 
            +
            });
         | 
| 42 | 
            +
            </script>
         | 
| 43 | 
            +
                """
         | 
| 44 | 
            +
                return html_content
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            # Gradioのインターフェースを作成
         | 
| 47 | 
            +
            gradio_interfaces = gr.Interface(
         | 
| 48 | 
            +
                fn=display_html,  # HTMLコンテンツを返す関数
         | 
| 49 | 
            +
                inputs=[],  # 入力なし
         | 
| 50 | 
            +
                outputs=gr.Markdown()  # HTMLコンテンツを表示
         | 
| 51 | 
            +
            )
         | 
| 52 | 
            +
             | 
| 53 | 
            +
             | 
| 54 | 
            +
            # Gradioのインターフェースを作成
         | 
| 55 | 
            +
            with gr.Blocks() as gradio_interface:
         | 
| 56 | 
            +
                gr.Markdown(display_html())
         | 
| 57 | 
            +
            # インターフェースを起動
         | 
| 58 | 
            +
            #iface.launch()
         |