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