The Agent class¶
-
class
agent.Agent[source]¶ The
Agentclass provides the methods to connect to DialogFlow APIs and perform basic intent queries.-
language¶ Agent’s language code (e.g.
"en-US").Type: string
-
project_id¶ DialogFlow’s API project ID.
Type: string
-
session_client¶ SessionsClient class to manage API sessions.
Type: dialogflow.SessionsClient
-
get_intent_score(sentence)[source]¶ Given a sentence, detects a related intent with a certain confidence score.
Parameters: sentence (string) – Input sentence to be processed Returns: A string containing the detected intent and the correspondent confidence score. Return type: string, float Examples
>>> agent = Agent() >>> agent.get_intent_score("It's hot") ("overheat", 0.8965118527412415)
-
The Client class¶
-
class
client.Client[source]¶ The
Clientclass is the backends which receives the User input and performs situation identification and reaction selection through an abductive inference process (given contextual data).To start interacting with the client, run the following command:
An example interaction is:
-
context¶ Dictionary containing context table and reactions information. For example:
{ "reactions": [ "I'll open the window", "I'll bring you a bottle of water", "I'll turn on the TV" ], "queries": [ "Should I open the window?", "Should I bring you a bottle of water?", "Should I turn on the TV?" ], "default": ["I am sorry, I can't do a lot for you."], "r1": { "overheat": 0.1, "bug-in-room": 0.07, "boredom": 0 }, "r2": { "overheat": 0.02, "bug-in-room": 0.02, "boredom": 0 }, "r3": { "overheat": 0, "bug-in-room": 0, "boredom": 0.07 } }
Type: dict
-
ask_question(question)[source]¶ Poses a Y/N question to the user.
Note
This function loops until the user does not give a Y/N answer.
Parameters: question (string) – The question to be displayed. Returns: Returns the answer as ‘y’ or ‘n’. Return type: string
-
deep_situation_analysis(sentence)[source]¶ Given a sentence, breaks it and send the single words to DialogFlow. Then, it returns the intent of the word with the maximum score.
Parameters: sentence (string) – Input sentence to be processed Returns: A string containing the detected situation. Return type: string
-
std_situation_analysis(sentence)[source]¶ Given a sentence, simply returns DialogFlow identified intent
Parameters: sentence (string) – Input sentence to be processed Returns: A string containing the detected situation. Return type: string Examples
>>> client = Client() >>> client.std_situation_analysis("It's hot") "overheat"
-