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
6ce5d9e1
Commit
6ce5d9e1
authored
May 06, 2024
by
陈正乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试gradio配置
parent
14a6b87b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
consts.py
src/config/consts.py
+7
-0
get_similarity.py
src/server/get_similarity.py
+1
-1
gradio_text.py
test/gradio_text.py
+10
-7
No files found.
src/config/consts.py
View file @
6ce5d9e1
...
@@ -42,3 +42,9 @@ INDEX_NAME = 'know'
...
@@ -42,3 +42,9 @@ INDEX_NAME = 'know'
# 知识相关资料配置
# 知识相关资料配置
# =============================
# =============================
KNOWLEDGE_PATH
=
'C:
\\
Users
\\
15663
\\
Desktop
\\
低空经济数据库'
KNOWLEDGE_PATH
=
'C:
\\
Users
\\
15663
\\
Desktop
\\
低空经济数据库'
# =============================
# gradio服务相关配置
# =============================
GR_SERVER_NAME
=
'localhost'
GR_PORT
=
8888
\ No newline at end of file
src/server/get_similarity.py
View file @
6ce5d9e1
...
@@ -5,7 +5,7 @@ class GetSimilarity:
...
@@ -5,7 +5,7 @@ class GetSimilarity:
def
__init__
(
self
,
_question
,
_faiss_db
:
VectorStore_FAISS
):
def
__init__
(
self
,
_question
,
_faiss_db
:
VectorStore_FAISS
):
self
.
question
=
_question
self
.
question
=
_question
self
.
faiss_db
=
_faiss_db
self
.
faiss_db
=
_faiss_db
self
.
similarity_doc
=
self
.
faiss_db
.
join_document
(
self
.
faiss_db
.
get_text_similarity
(
"什么是低空飞行"
))
self
.
similarity_doc
=
self
.
faiss_db
.
join_document
(
self
.
faiss_db
.
get_text_similarity
(
self
.
question
))
def
get_similarity_doc
(
self
):
def
get_similarity_doc
(
self
):
return
self
.
similarity_doc
return
self
.
similarity_doc
...
...
test/gradio_text.py
View file @
6ce5d9e1
...
@@ -20,7 +20,9 @@ from src.config.consts import (
...
@@ -20,7 +20,9 @@ from src.config.consts import (
VEC_DB_PORT
,
VEC_DB_PORT
,
VEC_DB_USER
,
VEC_DB_USER
,
VEC_DB_DBNAME
,
VEC_DB_DBNAME
,
SIMILARITY_SHOW_NUMBER
SIMILARITY_SHOW_NUMBER
,
GR_PORT
,
GR_SERVER_NAME
)
)
from
src.server.qa
import
QA
from
src.server.qa
import
QA
...
@@ -31,8 +33,9 @@ prompt1 = """'''
...
@@ -31,8 +33,9 @@ prompt1 = """'''
{question}"""
{question}"""
PROMPT1
=
PromptTemplate
(
input_variables
=
[
"context"
,
"question"
],
template
=
prompt1
)
PROMPT1
=
PromptTemplate
(
input_variables
=
[
"context"
,
"question"
],
template
=
prompt1
)
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
(
...
@@ -45,16 +48,16 @@ def main():
...
@@ -45,16 +48,16 @@ def main():
reset
=
False
)
reset
=
False
)
base_llm
=
ChatERNIESerLLM
(
base_llm
=
ChatERNIESerLLM
(
chat_completion
=
ChatCompletion
(
ak
=
"pT7sV1smp4AeDl0LjyZuHBV9"
,
sk
=
"b3N0ibo1IKTLZlSs7weZc8jdR0oHjyMu"
))
chat_completion
=
ChatCompletion
(
ak
=
"pT7sV1smp4AeDl0LjyZuHBV9"
,
sk
=
"b3N0ibo1IKTLZlSs7weZc8jdR0oHjyMu"
))
my_chat
=
QA
(
PROMPT1
,
base_llm
,
{
"temperature"
:
0.9
},
[
'context'
,
'question'
],
_db
=
c_db
,
_chat_id
=
'2'
,
_faiss_db
=
vecstore_faiss
)
my_chat
=
QA
(
PROMPT1
,
base_llm
,
{
"temperature"
:
0.9
},
[
'context'
,
'question'
],
_db
=
c_db
,
_chat_id
=
'2'
,
_faiss_db
=
vecstore_faiss
)
with
gr
.
Blocks
()
as
demo
:
with
gr
.
Blocks
()
as
demo
:
with
gr
.
Row
():
with
gr
.
Row
():
in1
=
gr
.
Textbox
(
show_label
=
True
,
lines
=
10
,
visible
=
False
)
inn
=
gr
.
Textbox
(
show_label
=
True
,
lines
=
10
)
in2
=
gr
.
Textbox
(
show_label
=
True
,
lines
=
10
)
with
gr
.
Row
():
with
gr
.
Row
():
qabtn
=
gr
.
Button
(
"SUBMIT"
)
qabtn
=
gr
.
Button
(
"SUBMIT"
)
out
=
gr
.
Textbox
(
show_label
=
True
,
lines
=
10
)
out
=
gr
.
Textbox
(
show_label
=
True
,
lines
=
10
)
qabtn
.
click
(
my_chat
.
async_chat
,
[
in
2
],
[
out
])
qabtn
.
click
(
my_chat
.
async_chat
,
[
in
n
],
[
out
])
demo
.
queue
()
.
launch
(
share
=
False
,
inbrowser
=
True
,
server_name
=
"192.168.100.76"
,
server_port
=
8888
)
demo
.
queue
()
.
launch
(
share
=
False
,
inbrowser
=
True
,
server_name
=
GR_SERVER_NAME
,
server_port
=
GR_PORT
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
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