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
17e7b130
Commit
17e7b130
authored
Jun 03, 2024
by
周峻哲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
问答出现预设场景,历史不展示的情况
parent
7e960d29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
qa.py
src/server/qa.py
+6
-6
No files found.
src/server/qa.py
View file @
17e7b130
...
...
@@ -38,7 +38,7 @@ prompt1 = """'''
PROMPT1
=
PromptTemplate
(
input_variables
=
[
"context"
,
"question"
],
template
=
prompt1
)
# 预设的安全响应
SAFE_RESPONSE
=
"
抱歉,我无法回答这个问题
。"
SAFE_RESPONSE
=
"
您好,我不具备人类属性,因此没有名字。我可以协助您完成范围广泛的任务并提供有关各种主题的信息,比如回答问题,提是供定义和解释及建议。如果您有任何问题,请随时向我提问
。"
BLOCKED_KEYWORDS
=
[
"文心一言"
,
"百度"
,
"模型"
]
class
QA
:
...
...
@@ -88,10 +88,10 @@ class QA:
self
.
cur_oquestion
=
_question
history
=
self
.
get_history
()
if
self
.
contains_blocked_keywords
(
_question
):
self
.
cur_answer
=
SAFE_RESPONSE
yield
[(
self
.
cur_oquestion
,
self
.
cur_answer
)]
return
#
if self.contains_blocked_keywords(_question):
#
self.cur_answer = SAFE_RESPONSE
#
yield [(self.cur_oquestion, self.cur_answer)]
#
return
self
.
cur_similarity
=
self
.
get_similarity
(
_aquestion
=
self
.
cur_oquestion
)
self
.
cur_question
=
self
.
prompt
.
format
(
context
=
self
.
cur_similarity
,
question
=
self
.
cur_oquestion
)
...
...
@@ -115,7 +115,7 @@ class QA:
history
.
append
((
self
.
cur_oquestion
,
self
.
cur_answer
))
async
for
token
in
callback
.
aiter
():
self
.
cur_answer
+=
token
if
self
.
contains_blocked_keywords
(
self
.
cur_
answer
):
if
self
.
contains_blocked_keywords
(
self
.
cur_
oquestion
):
self
.
cur_answer
=
SAFE_RESPONSE
history
[
-
1
]
=
(
self
.
cur_oquestion
,
self
.
cur_answer
)
yield
history
...
...
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