Best,
At the moment I'm experimenting with the dialogflow_v2 package and I've to say, It is extremely slow in most of the cases.
So slow that i'm doubting to abandon this ship and search for another chatbot-api.
Basically what i'm doing is:
I load in the packages:
import dialogflow_v2
from google.oauth2 import service_account
I create my credentials from my service account json file
cred_loc = 'first-planet-****************.json'
cred = service_account.Credentials.from_service_account_file(cred_loc)
I create the, agents_client, intents_client, entity_types_client
agents_client = dialogflow_v2.AgentsClient(credentials = cred)
agents_parent = agents_client.project_path(cred._project_id)
intents_client = dialogflow_v2.IntentsClient(credentials = cred)
intents_parent = intents_client.project_agent_path(cred.project_id)
entity_types_client = dialogflow_v2.EntityTypesClient(credentials = cred)
entity_types_parent = entity_types_client.project_agent_path(cred.project_id)
And then the misery starts:
Search agents takes 24 seconds
agents = []
for s in agents_client.search_agents(agents_parent).pages:
try:
agents.append(s.next())
except:
pass
List intents takes 36 seconds
intents_name_to_id = {}
for element in intents_client.list_intents(intents_parent, intent_view='INTENT_VIEW_FULL'):
intents_name_to_id[element.display_name] = element.name
List entity types takes 33 seconds
entity_name_to_id = {}
for element in entity_types_client.list_entity_types(entity_types_parent):
entity_name_to_id[element.display_name] = element.name
And it is not that it is a large project, in contrary, it is a new project with 1 agent, 2 intents and 2 entity types...
Thus my question is:
For me, it seems to be that I can't do that much wrong...
Also, when i do the same thing via the cloud...dialogflow.docs website:
then it works, very well ... (I get a response back within 1-2 seconds)
Kind regards
EDIT/EXTRA:
When i do the same thing without the dialogflow_v2, then it is equally slow ...
from google.oauth2 import service_account
import google.auth.transport.requests
cred_loc = 'first-planet-****.json'
SCOPES = ['https://www.googleapis.com/auth/dialogflow']
cred = service_account.Credentials.from_service_account_file(cred_loc,scopes=SCOPES)
cred.refresh(google.auth.transport.requests.Request())
parent = f'projects/{cred.project_id}'
header = {'Authorization': 'Bearer ' + cred.token}
search = requests.get(f'https://content-dialogflow.googleapis.com/v2/{parent}/agent:search', headers=header)
json.loads(search.content)
thus, the common factor of dialogflow_v2 and via request is the service account file (both method are slow) while the cloud...dialogflow.docs website uses oauth2 method ...