kenken999 commited on
Commit
07716a4
·
1 Parent(s): c0e49c1
controllers/gra_01_chatddd/Chat.py DELETED
@@ -1,115 +0,0 @@
1
- import shutil
2
- import gradio as gr
3
- from mysite.libs.utilities import chat_with_interpreter, completion, process_file
4
- from interpreter import interpreter
5
- import mysite.interpreter.interpreter_config # インポートするだけで設定が適用されます
6
- import importlib
7
- import os
8
- import pkgutil
9
- import async_timeout
10
- import asyncio
11
-
12
-
13
- DESCRIPTION = """
14
- <div>
15
- <h1 style="text-align: center;">develop site</h1>
16
- <p>🦕 共同開発 AIシステム設定 LINE開発 CHATGPTS CHATGPTアシスタント設定 AI自動開発設定 APPSHEET GAS PYTHON</p>
17
- </div>
18
- <!-- Start of HubSpot Embed Code -->
19
- <script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/46277896.js"></script>
20
- <!-- End of HubSpot Embed Code -->
21
- """
22
-
23
- LICENSE = """
24
- <p/>
25
- <!-- Start of HubSpot Embed Code -->
26
- <script type="text/javascript" id="hs-script-loader" async defer src="//js-na1.hs-scripts.com/46277896.js"></script>
27
- <!-- End of HubSpot Embed Code -->
28
- ---
29
- Built with Meta Llama 3
30
- """
31
-
32
- PLACEHOLDER = """
33
- <div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;">
34
- <img src="https://ysharma-dummy-chat-app.hf.space/file=/tmp/gradio/8e75e61cc9bab22b7ce3dec85ab0e6db1da5d107/Meta_lockup_positive%20primary_RGB.jpg" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; ">
35
- <h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">Meta llama3</h1>
36
- <p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Ask me anything...</p>
37
- </div>
38
- """
39
-
40
-
41
- # チャットインターフェースの関数定義
42
- # def chat_with_interpreter(message):
43
- # return "Response: " + message
44
-
45
-
46
- # カスタムCSSの定義
47
- css = """
48
- .gradio-container {
49
- height: 100vh; /* 全体の高さを100vhに設定 */
50
- display: flex;
51
- flex-direction: column;
52
- }
53
- .gradio-tabs {
54
- flex: 1; /* タブ全体の高さを最大に設定 */
55
- display: flex;
56
- flex-direction: column;
57
- }
58
- .gradio-tab-item {
59
- flex: 1; /* 各タブの高さを最大に設定 */
60
- display: flex;
61
- flex-direction: column;
62
- overflow: hidden; /* オーバーフローを隠す */
63
- }
64
- .gradio-block {
65
- flex: 1; /* ブロックの高さを最大に設定 */
66
- display: flex;
67
- flex-direction: column;
68
- }
69
- .gradio-chatbot {
70
- height: 100vh; /* チャットボットの高さを100vhに設定 */
71
- overflow-y: auto; /* 縦スクロールを有効にする */
72
- }
73
- """
74
- GENERATION_TIMEOUT_SEC = 60
75
- # Gradio block
76
- chatbot2 = gr.Chatbot(height=450, placeholder=PLACEHOLDER, label="Gradio ChatInterface")
77
-
78
- with gr.Blocks(fill_height=True, css=css) as gradio_interface:
79
- # gr.Markdown(DESCRIPTION)
80
- # gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
81
- gr.ChatInterface(
82
- fn=completion,
83
- chatbot=chatbot2,
84
- fill_height=True,
85
- additional_inputs_accordion=gr.Accordion(
86
- label="⚙️ Parameters", open=False, render=False
87
- ),
88
- additional_inputs=[
89
- gr.Slider(
90
- minimum=0,
91
- maximum=1,
92
- step=0.1,
93
- value=0.95,
94
- label="Temperature",
95
- render=False,
96
- ),
97
- gr.Slider(
98
- minimum=128,
99
- maximum=4096,
100
- step=1,
101
- value=512,
102
- label="Max new tokens",
103
- render=False,
104
- ),
105
- ],
106
- examples=[
107
- ["HTMLのサンプルを作成して"],
108
- [
109
- "CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_sft.yaml"
110
- ],
111
- ],
112
- cache_examples=False,
113
- )
114
-
115
- gr.Markdown(LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
controllers/gra_api/Chat.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # API で呼び出す関数
4
+ def chat_api(message, username, temperature):
5
+ response = f"User: {username}, Message: {message}, Temperature: {temperature}"
6
+ return response
7
+
8
+ # Gradio のインターフェース
9
+ gradio_interface = gr.Interface(
10
+ fn=chat_api, # 関数
11
+ inputs=["text", "text", "number"], # 入力タイプ
12
+ outputs="text" # 出力タイプ
13
+ )
14
+
controllers/{gra_01_chatddd → gra_api}/__init__.py RENAMED
File without changes