Support all status codes.
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
||||
html {
|
||||
background: repeating-linear-gradient(45deg, rgb(0 0 0) 0px, rgb(0 0 0) 20px, #211200 20px, #211200 40px);
|
||||
background: repeating-linear-gradient(45deg, rgb(0 0 0) 0px, rgb(0 0 0) 20px, #140b02 20px, #140b02 40px);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ body {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.input-container > input {
|
||||
background: #211200;
|
||||
.input-container>input {
|
||||
background: #1f1203;
|
||||
border: 2px solid #ff8d00;
|
||||
color: #ff8d00;
|
||||
}
|
||||
@@ -13,6 +13,9 @@ function getStatusText(status) {
|
||||
if (status === 'conditional')
|
||||
return '状 態';
|
||||
|
||||
if (status === 'error')
|
||||
return '誤 差'
|
||||
|
||||
throw new Error('Invalid status: ' + status);
|
||||
}
|
||||
|
||||
@@ -29,6 +32,9 @@ function getStatusColor(status) {
|
||||
if (status === 'conditional')
|
||||
return '#ff8d00';
|
||||
|
||||
if (status === 'error')
|
||||
return 'gray';
|
||||
|
||||
throw new Error('Invalid status: ' + status);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,5 +39,13 @@ export default function WiseMan(props) {
|
||||
}
|
||||
|
||||
WiseMan.defaultProps = {
|
||||
n_clicks: 0
|
||||
n_clicks: 0,
|
||||
question_id: 0,
|
||||
answer: {
|
||||
id: 0,
|
||||
status: 'info',
|
||||
error: '',
|
||||
conditions: '',
|
||||
response: 'Waiting for query...'
|
||||
}
|
||||
};
|
||||
@@ -46,23 +46,17 @@ app.layout = html.Div(
|
||||
id={'type': 'wise-man', 'name': 'melchior'},
|
||||
name='melchior',
|
||||
order_number=1,
|
||||
personality='You are a scientist. Your goal is to further our understanding of the universe and advance our technological progress.',
|
||||
question_id=0,
|
||||
answer={'id': 0, 'response': 'yes', 'status': 'yes'}),
|
||||
personality='You are a scientist. Your goal is to further our understanding of the universe and advance our technological progress.'),
|
||||
WiseMan(
|
||||
id={'type': 'wise-man', 'name': 'balthasar'},
|
||||
name='balthasar',
|
||||
order_number=2,
|
||||
personality='You are a mother. Your goal is to protect your children and ensure their well-being.',
|
||||
question_id=0,
|
||||
answer={'id': 0, 'response': 'yes', 'status': 'yes'}),
|
||||
personality='You are a mother. Your goal is to protect your children and ensure their well-being.'),
|
||||
WiseMan(
|
||||
id={'type': 'wise-man', 'name': 'casper'},
|
||||
name='casper',
|
||||
order_number=3,
|
||||
personality='You are a woman. Your goal is to pursue love, dreams and desires.',
|
||||
question_id=0,
|
||||
answer={'id': 0, 'response': 'yes', 'status': 'yes'}),
|
||||
personality='You are a woman. Your goal is to pursue love, dreams and desires.'),
|
||||
Response(id='response', status='info'),
|
||||
html.Div(className='title', children='MAGI')
|
||||
]),
|
||||
@@ -174,14 +168,19 @@ def question_id(question: dict):
|
||||
|
||||
@callback(
|
||||
Output('response', 'status'),
|
||||
Input({'type': 'wise-man', 'name': ALL}, 'answer'))
|
||||
Input({'type': 'wise-man', 'name': ALL}, 'answer'),
|
||||
prevent_initial_call=True)
|
||||
def response_status(answers: list):
|
||||
if any([answer['status'] == 'error' for answer in answers]):
|
||||
return 'error'
|
||||
if any([answer['status'] == 'no' for answer in answers]):
|
||||
return 'no'
|
||||
if any([answer['status'] == 'conditional' for answer in answers]):
|
||||
return 'conditional'
|
||||
if all([answer['status'] == 'yes' for answer in answers]):
|
||||
return 'yes'
|
||||
elif any([answer['status'] == 'no' for answer in answers]):
|
||||
return 'no'
|
||||
else:
|
||||
return 'info'
|
||||
|
||||
return 'info'
|
||||
|
||||
|
||||
@callback(
|
||||
|
||||
Reference in New Issue
Block a user