Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
LAE
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
文靖昊
LAE
Commits
f9380e0a
Commit
f9380e0a
authored
9 months ago
by
陈正乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加新建对话功能
parent
77a22b17
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
73 deletions
+52
-73
gradio_test.py
test/gradio_test.py
+13
-21
index(1).css
test/index(1).css
+22
-0
lk_test.py
test/lk_test.py
+17
-52
No files found.
test/gradio_test.py
View file @
f9380e0a
...
@@ -41,11 +41,8 @@ prompt1 = """'''
...
@@ -41,11 +41,8 @@ prompt1 = """'''
PROMPT1
=
PromptTemplate
(
input_variables
=
[
"context"
,
"question"
],
template
=
prompt1
)
PROMPT1
=
PromptTemplate
(
input_variables
=
[
"context"
,
"question"
],
template
=
prompt1
)
global
o_users
,
users_l
,
o_chats
,
chats_l
def
main
():
def
main
():
c_db
=
UPostgresDB
(
host
=
CHAT_DB_HOST
,
database
=
CHAT_DB_DBNAME
,
user
=
CHAT_DB_USER
,
password
=
CHAT_DB_PASSWORD
,
c_db
=
UPostgresDB
(
host
=
CHAT_DB_HOST
,
database
=
CHAT_DB_DBNAME
,
user
=
CHAT_DB_USER
,
password
=
CHAT_DB_PASSWORD
,
port
=
CHAT_DB_PORT
,
)
port
=
CHAT_DB_PORT
,
)
vecstore_faiss
=
VectorStore_FAISS
(
vecstore_faiss
=
VectorStore_FAISS
(
...
@@ -76,16 +73,15 @@ def main():
...
@@ -76,16 +73,15 @@ def main():
return
gr
.
Button
(
interactive
=
True
)
return
gr
.
Button
(
interactive
=
True
)
def
get_users
():
def
get_users
():
return
my_chat
.
get_users
()
o_users
=
my_chat
.
get_users
()
users_l
=
[
item
[
0
]
for
item
in
o_users
]
return
gr
.
components
.
Radio
(
choices
=
users_l
,
label
=
"选择一个用户"
,
value
=
users_l
[
0
],
interactive
=
True
),
users_l
[
0
]
def
create_chat
(
user_account
):
def
create_chat
(
user_account
):
my_chat
.
create_chat
(
user_account
)
my_chat
.
create_chat
(
user_account
)
def
get_chats
(
user_account
):
def
get_chats
(
user_account
):
global
o_users
,
users_l
,
o_chats
,
chats_l
print
(
chats_l
)
o_chats
=
my_chat
.
get_chats
(
user_account
)
o_chats
=
my_chat
.
get_chats
(
user_account
)
print
(
o_chats
)
chats_l
=
[
item
[
0
]
+
':'
+
item
[
1
]
for
item
in
o_chats
]
chats_l
=
[
item
[
0
]
+
':'
+
item
[
1
]
for
item
in
o_chats
]
return
gr
.
components
.
Radio
(
choices
=
chats_l
,
label
=
"选择一个对话"
,
value
=
chats_l
[
0
],
interactive
=
True
)
return
gr
.
components
.
Radio
(
choices
=
chats_l
,
label
=
"选择一个对话"
,
value
=
chats_l
[
0
],
interactive
=
True
)
...
@@ -96,24 +92,18 @@ def main():
...
@@ -96,24 +92,18 @@ def main():
chat_id
=
chat_id_info
.
split
(
':'
)[
0
]
chat_id
=
chat_id_info
.
split
(
':'
)[
0
]
my_chat
.
set_chat_id
(
chat_id
)
my_chat
.
set_chat_id
(
chat_id
)
global
o_users
,
users_l
,
o_chats
,
chats_l
def
load
():
o_users
=
get_users
()
l_users
,
t_user
=
get_users
()
users_l
=
[
item
[
0
]
for
item
in
o_users
]
l_chats
=
get_chats
(
t_user
)
o_chats
=
my_chat
.
get_chats
(
users_l
[
0
])
return
l_users
,
l_chats
chats_l
=
[
item
[
0
]
+
':'
+
item
[
1
]
for
item
in
o_chats
]
set_chat_id
(
chats_l
[
0
])
print
(
my_chat
.
chat_id
)
with
gr
.
Blocks
(
css
=
'index(1).css'
)
as
demo
:
print
(
type
(
my_chat
.
chat_id
))
a
=
my_chat
.
get_history
()
print
(
a
)
with
gr
.
Blocks
()
as
demo
:
gr
.
HTML
(
"""<h1 align="center">低空经济知识问答</h1>"""
)
gr
.
HTML
(
"""<h1 align="center">低空经济知识问答</h1>"""
)
with
gr
.
Row
():
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
2
):
with
gr
.
Column
(
scale
=
2
):
users
=
gr
.
components
.
Radio
(
choices
=
users_l
,
label
=
"选择一个用户"
,
value
=
users_l
[
0
]
,
interactive
=
True
,
users
=
gr
.
components
.
Radio
(
choices
=
[],
label
=
"选择一个用户"
,
interactive
=
True
,
visible
=
False
,
show_label
=
False
)
visible
=
False
,
show_label
=
False
)
chats
=
gr
.
components
.
Radio
(
choices
=
chats_l
,
label
=
"选择一个对话"
,
value
=
chats_l
[
0
]
,
interactive
=
True
,
chats
=
gr
.
components
.
Radio
(
choices
=
[],
label
=
"选择一个对话"
,
interactive
=
True
,
show_label
=
False
)
show_label
=
False
)
new_chat_btn
=
gr
.
Button
(
"新建对话"
)
new_chat_btn
=
gr
.
Button
(
"新建对话"
)
with
gr
.
Column
(
scale
=
8
):
with
gr
.
Column
(
scale
=
8
):
...
@@ -122,9 +112,11 @@ def main():
...
@@ -122,9 +112,11 @@ def main():
value
=
show_history
(),
height
=
400
,
show_copy_button
=
True
,
value
=
show_history
(),
height
=
400
,
show_copy_button
=
True
,
show_label
=
False
,
line_breaks
=
True
)
show_label
=
False
,
line_breaks
=
True
)
with
gr
.
Row
():
with
gr
.
Row
():
input_text
=
gr
.
Textbox
(
show_label
=
False
,
lines
=
1
,
label
=
"文本输入"
,
scale
=
9
)
input_text
=
gr
.
Textbox
(
show_label
=
False
,
lines
=
1
,
label
=
"文本输入"
,
scale
=
9
,
container
=
False
)
sub_btn
=
gr
.
Button
(
"提交"
,
scale
=
1
)
sub_btn
=
gr
.
Button
(
"提交"
,
scale
=
1
)
demo
.
load
(
load
,
[],
[
users
,
chats
])
new_chat_btn
.
click
(
create_chat
,
[
users
],
[])
.
then
(
new_chat_btn
.
click
(
create_chat
,
[
users
],
[])
.
then
(
get_chats
,
[
users
],
[
chats
]
get_chats
,
[
users
],
[
chats
]
)
)
...
...
This diff is collapsed.
Click to expand it.
test/index(1).css
0 → 100644
View file @
f9380e0a
#component-5
{
height
:
70vh
!important
;
overflow
:
hidden
;
}
wrap
.svelte-vm32wk
lable
{
margin-bottom
:
10px
!important
;
}
#component-9
{
height
:
70vh
!important
;
}
footer
{
opacity
:
0
;
}
@media
screen
and
(
max-width
:
768px
)
{
#component-3
{
display
:
none
;
}
#component-5
{
display
:
none
!important
;
}
}
This diff is collapsed.
Click to expand it.
test/lk_test.py
View file @
f9380e0a
"""给定三个字符串 s1、s2、s3,请你帮忙验证 s3 是否是由 s1 和 s2 交错 组成的。
import
gradio
as
gr
两个字符串 s 和 t 交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空
chats_l
=
[
1
,
1
,
2
,
3
]
子字符串
:
s = s1 + s2 + ... + sn
t = t1 + t2 + ... + tm
|n - m| <= 1
交错 是 s1 + t1 + s2 + t2 + s3 + t3 + ... 或者 t1 + s1 + t2 + s2 + t3 + s3 + ...
注意:a + b 意味着字符串 a 和 b 连接。
def
get_latest_chats
():
print
(
"get_latest_chats"
)
global
chats_l
chats_l
=
chats_l
+
[
2
]
return
chats_l
示例 1:
with
gr
.
Blocks
()
as
demo
:
a
=
gr
.
Radio
(
choices
=
get_latest_chats
(),
value
=
chats_l
[
0
])
value
=
gr
.
State
({
"chats"
:
chats_l
})
# gr.Dataset(components=a, samples=[chats_l])
demo
.
load
(
get_latest_chats
,
None
,
[
a
])
btn
=
gr
.
Button
(
"submit"
)
btn
.
click
(
get_latest_chats
,
None
,
[
a
])
输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
输出:true
示例 2:
输入:s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
demo
.
queue
()
.
launch
(
share
=
False
,
inbrowser
=
True
,
server_name
=
'192.168.22.80'
,
server_port
=
8889
)
输出:false
示例 3:
输入:s1 = "", s2 = "", s3 = ""
输出:true
提示:
0 <= s1.length, s2.length <= 100
0 <= s3.length <= 200
s1、s2、和 s3 都由小写英文字母组成"""
# Definition for a binary tree node.
class
TreeNode
(
object
):
def
__init__
(
self
,
val
=
0
,
left
=
None
,
right
=
None
):
self
.
val
=
val
self
.
left
=
left
self
.
right
=
right
class
Solution
(
object
):
def
isValidBST
(
self
,
root
):
"""
:type root: TreeNode
:rtype: bool
"""
if
root
is
None
:
return
True
if
root
.
left
is
None
and
root
.
right
is
None
:
return
True
if
root
.
left
is
None
:
return
self
.
isValidBST
(
root
.
right
)
and
root
.
val
<
root
.
right
.
val
if
root
.
right
is
None
:
return
self
.
isValidBST
(
root
.
left
)
and
root
.
val
>
root
.
left
.
val
return
self
.
isValidBST
(
root
.
left
)
and
self
.
isValidBST
(
root
.
right
)
and
root
.
val
>
root
.
left
.
val
and
root
.
val
<
root
.
right
.
val
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment