1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 04:04:58 +03:00

fix(server): handle exception on NLU

This commit is contained in:
louistiti 2024-05-22 17:32:13 +08:00
parent 0ff26739e7
commit c172f2d6af
No known key found for this signature in database
GPG Key ID: 92CD6A2E497E1669
3 changed files with 233 additions and 227 deletions

View File

@ -173,8 +173,8 @@ SPACY_MODELS.set('fr', {
// There is no CUDA support on macOS
const commandToExecute =
osType === OSTypes.MacOS
? 'pipenv run pip install --ignore-installed torch==2.3.0'
: 'pipenv run pip install --ignore-installed torch==2.3.0 --index-url https://download.pytorch.org/whl/cu121'
? 'pipenv run pip install --ignore-installed --force-reinstall torch==2.3.0'
: 'pipenv run pip install --ignore-installed --force-reinstall torch==2.3.0 --index-url https://download.pytorch.org/whl/cu121'
await command(commandToExecute, {
shell: true,

View File

@ -157,6 +157,7 @@ export default class NLU {
const processingTimeStart = Date.now()
return new Promise(async (resolve, reject) => {
try {
LogHelper.title('NLU')
LogHelper.info('Processing...')
@ -293,7 +294,9 @@ export default class NLU {
this._nluResult.classification.action
} (domain: ${
this._nluResult.classification.domain
}); Confidence: ${this._nluResult.classification.confidence.toFixed(2)}`
}); Confidence: ${this._nluResult.classification.confidence.toFixed(
2
)}`
)
const skillConfigPath = join(
@ -398,6 +401,10 @@ export default class NLU {
return reject(new Error(errorMessage))
}
} catch (e) {
LogHelper.title('NLU')
LogHelper.error(`Failed to process the utterance: ${e}`)
}
})
}

View File

@ -1,5 +1,4 @@
from cx_Freeze import setup, Executable
import sysconfig
import sys
import os
@ -47,11 +46,11 @@ options = {
}
# Include private libraries from the tokenizers package for Linux
if 'linux' in sysconfig.get_platform():
options['build_exe']['include_files'] = [
*options['build_exe']['include_files'],
('tcp_server/src/.venv/lib/python3.9/site-packages/tokenizers.libs', 'lib/tokenizers.libs')
]
# if 'linux' in sysconfig.get_platform():
# options['build_exe']['include_files'] = [
# *options['build_exe']['include_files'],
# ('tcp_server/src/.venv/lib/python3.9/site-packages/tokenizers.libs', 'lib/tokenizers.libs')
# ]
executables = [
Executable(