質問編集履歴
2
文言の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
■APIのコード
|
25
|
+
■APIのコード
|
26
26
|
|
27
|
-
```
|
27
|
+
```local.py
|
28
28
|
|
29
29
|
project_id = "プロジェクトのID"
|
30
30
|
|
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
DialogflowのAPIにv2が出たということなので、v1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
|
1
|
+
DialogflowのAPIにv2が出たということなので、ローカル環境で動作するようにv1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
|
2
2
|
|
3
3
|
どのように対処したらよいのでしょうか。
|
4
4
|
|
@@ -14,35 +14,43 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
■参考にしたサイト
|
18
|
+
|
19
|
+
https://dialogflow-python-client-v2.readthedocs.io/en/latest/
|
20
|
+
|
21
|
+
こちらのDetecting Intent (Texts)を参考にしています。
|
22
|
+
|
23
|
+
|
24
|
+
|
17
25
|
■APIのコード(local.py)
|
18
26
|
|
19
27
|
```ここに言語を入力
|
20
28
|
|
21
|
-
|
29
|
+
project_id = "プロジェクトのID"
|
22
30
|
|
23
|
-
|
31
|
+
session_id = ""
|
24
32
|
|
25
|
-
|
33
|
+
language_code = "ja"
|
26
34
|
|
27
|
-
|
35
|
+
session_client = dialogflow.SessionsClient()
|
28
36
|
|
29
37
|
|
30
38
|
|
31
|
-
|
39
|
+
session = session_client.session_path(project_id, session_id)
|
32
40
|
|
33
41
|
|
34
42
|
|
35
|
-
|
43
|
+
text_input = dialogflow.types.TextInput(text=query, language_code=language_code)
|
36
44
|
|
37
|
-
|
45
|
+
query_input = dialogflow.types.QueryInput(text=text_input)
|
38
46
|
|
39
|
-
|
47
|
+
response = session_client.detect_intent(session=session, query_input=query_input)
|
40
48
|
|
41
|
-
|
49
|
+
print('Query text: {}'.format(response.query_result.query_text))
|
42
50
|
|
43
|
-
|
51
|
+
print('Detected intent: {} (confidence: {})\n'.format(response.query_result.intent.display_name,response.query_result.intent_detection_confidence))
|
44
52
|
|
45
|
-
|
53
|
+
print('Fulfillment text: {}\n'.format(response.query_result.fulfillment_text))
|
46
54
|
|
47
55
|
```
|
48
56
|
|