Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache llm chain to avoid loading the model at every utterance [ENG 437] #12728

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions rasa/cdu/command_generator/llm_command_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(
self.prompt_template = self.config["prompt"]
self._model_storage = model_storage
self._resource = resource
self.llm = llm_factory(self.config.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG)

@classmethod
def create(
Expand Down Expand Up @@ -122,10 +123,8 @@ def _generate_action_list_using_llm(self, prompt: str) -> Optional[str]:
Returns:
generated text
"""
llm = llm_factory(self.config.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG)

try:
return llm(prompt)
return self.llm(prompt)
except Exception as e:
# unfortunately, langchain does not wrap LLM exceptions which means
# we have to catch all exceptions here
Expand Down
Loading