Download app.py from kkAIGC/SQLBot: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/spaces/kkAIGC/SQLBot/resolve/2e81bd8dfa7b03d31ef36aaee03da5f21a6b37e2/app.py
- Command line
-
hf download hf://spaces/kkAIGC/SQLBot@2e81bd8dfa7b03d31ef36aaee03da5f21a6b37e2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kkAIGC/SQLBot/resolve/2e81bd8dfa7b03d31ef36aaee03da5f21a6b37e2/app.py
1.75 kB
| import os | |
| import openai | |
| import gradio as gr | |
| from src.get_api_key import get_api_key | |
| from src.analysis.sql_observation import sql_explain, sql_translate, function_select | |
| #block构建界面 | |
| with gr.Blocks() as demo: | |
| gr.Markdown("本页面对SQL代码进行文字说明or翻译为自然语言") | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| sql_text = gr.Textbox(lines=21,label="输入SQL代码") | |
| sql_button = gr.Button('确认输入') | |
| with gr.Column(scale=2): | |
| output_text = gr.Textbox(lines=24,label="输出", | |
| show_label=True,show_copy_button=True, | |
| ) | |
| with gr.Column(scale=1): | |
| apikey_text = gr.Textbox(type='password',label='请输入api_key:') | |
| model_select = gr.Dropdown( | |
| choices=["gpt-3.5-turbo-16k","gpt-3.5-turbo"], | |
| value='gpt-3.5-turbo', | |
| label='选择模型' | |
| ) | |
| temperature = gr.Slider(minimum=0, maximum=1,value=0,label='temperature') | |
| maxtoken = gr.Slider(minimum=0, maximum=3000, value=300,label='max_token') | |
| translate_select = gr.Checkbox(label='需要详细解释') | |
| apikey_text.change(fn=get_api_key,inputs= apikey_text) | |
| sql_button.click(fn=function_select, | |
| inputs=[sql_text, | |
| model_select, | |
| temperature, | |
| maxtoken, | |
| translate_select | |
| ], | |
| outputs=output_text) | |
| demo.launch() |