0

我创建了一个管道,在其中我使用 Rasa 作为 python 库,如果意图是预测响应/意图,out_of_scope然后我使用带有 elmo 嵌入的深度学习模型处理请求。

因此,要为此加载 TF 图,我需要禁用急切执行,所以我使用了

import tensorflow.compat.v1 as tf

tf.compat.v1.disable_eager_execution() 

但是通过禁用这个我的 rasa 模型停止工作,现在当我尝试使用

queryResponseList = await agent.handle_text(query)

表明

Traceback (most recent call last):
  File "C:\MyRasaProj\env37\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 371, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "C:\MyRasaProj\env37\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 59, in __call__   
    return await self.app(scope, receive, send)
  File "C:\MyRasaProj\env37\lib\site-packages\uvicorn\middleware\debug.py", line 96, in __call__
    raise exc from None
  File "C:\MyRasaProj\env37\lib\site-packages\uvicorn\middleware\debug.py", line 93, in __call__
    await self.app(scope, receive, inner_send)
  File "C:\MyRasaProj\env37\lib\site-packages\fastapi\applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__       
    raise exc from None
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__       
    await self.app(scope, receive, _send)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\exceptions.py", line 82, in __call__
    raise exc from None
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\routing.py", line 580, in __call__
    await route.handle(scope, receive, send)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\routing.py", line 241, in handle
    await self.app(scope, receive, send)
  File "C:\MyRasaProj\env37\lib\site-packages\starlette\routing.py", line 52, in app
    response = await func(request)
  File "C:\MyRasaProj\env37\lib\site-packages\fastapi\routing.py", line 215, in app
    dependant=dependant, values=values, is_coroutine=is_coroutine
  File "C:\MyRasaProj\env37\lib\site-packages\fastapi\routing.py", line 149, in run_endpoint_function      
    return await dependant.call(**values)
  File "C:\MyRasaProj\api\chat_service.py", line 61, in process
    botResponse = await RasaBot.process(query, clientId)
  File "C:\MyRasaProj\bots\rasa_bot.py", line 66, in process
    queryResponseList = await agent.handle_text(query)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\agent.py", line 623, in handle_text
    return await self.handle_message(msg, message_preprocessor)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\agent.py", line 536, in handle_message
    return await processor.handle_message(message)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\processor.py", line 91, in handle_message
    tracker = await self.log_message(message, should_save_tracker=False)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\processor.py", line 322, in log_message
    await self._handle_message_with_tracker(message, tracker)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\processor.py", line 587, in _handle_message_with_tracker
    parse_data = await self.parse_message(message, tracker)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\processor.py", line 566, in parse_message
    text, message.message_id, tracker, metadata=message.metadata
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\core\interpreter.py", line 145, in parse
    result = self.interpreter.parse(text)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\nlu\model.py", line 453, in parse
    component.process(message, **self.context)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\nlu\classifiers\diet_classifier.py", line 963, in process
    out = self._predict(message)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\nlu\classifiers\diet_classifier.py", line 878, in _predict
    return self.model.rasa_predict(model_data)
  File "C:\MyRasaProj\env37\lib\site-packages\rasa\utils\tensorflow\models.py", line 270, in rasa_predict  
    return tf_utils.to_numpy_or_python_type(self._tf_predict_step(batch_in))
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\def_function.py", line 780, in __call__
    result = self._call(*args, **kwds)
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\def_function.py", line 814, in _call 
    results = self._stateful_fn(*args, **kwds)
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\function.py", line 2829, in __call__ 
    return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\function.py", line 1848, in _filtered_call
    cancellation_manager=cancellation_manager)
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\function.py", line 1938, in _call_flat
    flat_outputs = forward_function.call(ctx, args_with_tangents)
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\eager\function.py", line 579, in call      
    executor_type=executor_type)
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\ops\functional_ops.py", line 1175, in partitioned_call
    args = [ops.convert_to_tensor(x) for x in args]
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\ops\functional_ops.py", line 1175, in <listcomp>
    args = [ops.convert_to_tensor(x) for x in args]
  File "C:\MyRasaProj\env37\lib\site-packages\tensorflow\python\framework\ops.py", line 1465, in convert_to_tensor
    raise RuntimeError("Attempting to capture an EagerTensor without "
RuntimeError: Attempting to capture an EagerTensor without building a function.

我该如何解决这个问题?

https://forum.rasa.com/t/disable-eager-execution-with-rasa-not-working/46462

4

0 回答 0