Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,47 @@ from presets import *
|
|
7 |
|
8 |
os.environ['OPENAI_API_KEY'] = ""
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
with gr.Blocks() as llama_difu:
|
11 |
chat_context = gr.State([])
|
12 |
new_google_chat_context = gr.State([])
|
|
|
|
|
|
|
13 |
|
14 |
with gr.Row():
|
15 |
with gr.Column(scale=1):
|
@@ -82,6 +120,9 @@ with gr.Blocks() as llama_difu:
|
|
82 |
json_confirm_btn = gr.Button("🔎")
|
83 |
json_display = gr.JSON(label="View index json")
|
84 |
|
|
|
|
|
|
|
85 |
index_refresh_btn.click(refresh_json_list, None, [index_select])
|
86 |
query_btn.click(ask_ai, [api_key, index_select, query_box, prompt_tmpl, sim_k, tempurature], [answer])
|
87 |
tmpl_select.change(change_prompt_tmpl, [tmpl_select], [prompt_tmpl])
|
|
|
7 |
|
8 |
os.environ['OPENAI_API_KEY'] = ""
|
9 |
|
10 |
+
title = """<h1 align="center">🦙Llama_Difu</h1><br/><h3 align="center">Llama Do it for you —— 让Llama来帮你读代码、论文、书籍</h3>"""
|
11 |
+
description = """<div align=center>
|
12 |
+
|
13 |
+
由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发
|
14 |
+
|
15 |
+
</div>
|
16 |
+
"""
|
17 |
+
|
18 |
+
customCSS = """
|
19 |
+
code {
|
20 |
+
display: inline;
|
21 |
+
white-space: break-spaces;
|
22 |
+
border-radius: 6px;
|
23 |
+
margin: 0 2px 0 2px;
|
24 |
+
padding: .2em .4em .1em .4em;
|
25 |
+
background-color: rgba(175,184,193,0.2);
|
26 |
+
}
|
27 |
+
pre {
|
28 |
+
display: block;
|
29 |
+
white-space: pre;
|
30 |
+
background-color: hsla(0, 0%, 0%, 72%);
|
31 |
+
border: solid 5px var(--color-border-primary) !important;
|
32 |
+
border-radius: 8px;
|
33 |
+
padding: 0 1.2rem 1.2rem;
|
34 |
+
margin-top: 1em !important;
|
35 |
+
color: #FFF;
|
36 |
+
box-shadow: inset 0px 8px 16px hsla(0, 0%, 0%, .2)
|
37 |
+
}
|
38 |
+
pre code, pre code code {
|
39 |
+
background-color: transparent !important;
|
40 |
+
margin: 0;
|
41 |
+
padding: 0;
|
42 |
+
}
|
43 |
+
"""
|
44 |
+
|
45 |
with gr.Blocks() as llama_difu:
|
46 |
chat_context = gr.State([])
|
47 |
new_google_chat_context = gr.State([])
|
48 |
+
|
49 |
+
gr.HTML(title)
|
50 |
+
gr.HTML('''<center><a href="https://huggingface.co/spaces/MZhaovo/Llama_Difu?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="复制 Space"></a>强烈建议点击上面的按钮复制一份这个Space,在你自己的Space里运行,响应更迅速、也更安全👆</center>''')
|
51 |
|
52 |
with gr.Row():
|
53 |
with gr.Column(scale=1):
|
|
|
120 |
json_confirm_btn = gr.Button("🔎")
|
121 |
json_display = gr.JSON(label="View index json")
|
122 |
|
123 |
+
|
124 |
+
gr.Markdown(description)
|
125 |
+
|
126 |
index_refresh_btn.click(refresh_json_list, None, [index_select])
|
127 |
query_btn.click(ask_ai, [api_key, index_select, query_box, prompt_tmpl, sim_k, tempurature], [answer])
|
128 |
tmpl_select.change(change_prompt_tmpl, [tmpl_select], [prompt_tmpl])
|