diva.chat package¶
Submodules¶
diva.chat.interface_chatbot_scopes module¶
diva.chat.interface_classification module¶
diva.chat.interface_disclaimer module¶
diva.chat.interface_gen_text_answer module¶
diva.chat.interface_memory_rephrasing module¶
diva.chat.module_chat module¶
- class diva.chat.module_chat.ModuleChat[source]¶
Bases:
object
This module manages everything related to the chat between the user and chatbot, including Large Language Model (LLM) interactions.
- add_disclaimer(types: list[str])[source]¶
Adds warning about frequency of data update and differences between climate predictions and weather forecast
- property chat: Chat¶
- property chatbot_scope_strategy: ChatbotScopes¶
- create_user_prompt(prompt: str)[source]¶
Creates the Prompt instance containing the user prompt. The text string of the user prompt should not be empty. The Prompt instance is stored in a Chat instance, itself stored in a ModuleChat instance.
Parameters¶
- prompt: str
the text written by the user.
- generate_text_answer()[source]¶
Generates a text answer in response to the user prompt.
The answer may vary depending on whether the prompt asks something within the chatbot scopes, depending on the given context, toxicity of the prompt, type of prompt (visualisation or discussion)…
- is_memory_needed(last_prompt: Prompt | None = None, prompt: Prompt | None = None)[source]¶
Determines if memory (of the previous answer or of the previous prompt) is needed to answer the current prompt.
Parameters¶
- last_prompt: Union[‘Prompt’, None], optional, default to None.
the Prompt instance containing the last user prompt. If None, it retrieves the Prompt instance directly from the chat history
- prompt: Union[‘Prompt’, None], optional, default to None.
the Prompt instance, containing the current user prompt. If None, it retrieves the Prompt instance directly from the chat history.
- is_prompt_in_scope()[source]¶
Verifies if the prompt corresponds to a task that is in the scope of the chatbot. If not in scope, the chatbot may not answer.
- property memory_needed: bool¶
- property prompt: Prompt¶
- prompt_classification() str [source]¶
Classifies the prompt (intention) as either “discussion” or “visualisation”. If “discussion”, the chatbot response is only text. If “visualisation”, the chatbot response is text + graph. Returns a word, either “discussion” or “visualisation”
- property prompt_history: list[Prompt]¶