質問編集履歴
2
文言の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,8 +10,8 @@
|
|
10
10
|
https://dialogflow-python-client-v2.readthedocs.io/en/latest/
|
11
11
|
こちらのDetecting Intent (Texts)を参考にしています。
|
12
12
|
|
13
|
+
■APIのコード
|
13
|
-
|
14
|
+
```local.py
|
14
|
-
```ここに言語を入力
|
15
15
|
project_id = "プロジェクトのID"
|
16
16
|
session_id = ""
|
17
17
|
language_code = "ja"
|
1
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
DialogflowのAPIにv2が出たということなので、v1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
|
1
|
+
DialogflowのAPIにv2が出たということなので、ローカル環境で動作するようにv1からの切り替え作業を行っているのですが、エラーが出てしまい困っています。
|
2
2
|
どのように対処したらよいのでしょうか。
|
3
3
|
また、session_idについて、v2ではどこから取得すればいいのかがよくわかっていません。
|
4
4
|
session_idはどのように扱えばいいのでしょうか。
|
@@ -6,21 +6,25 @@
|
|
6
6
|
■環境
|
7
7
|
python3.4.5
|
8
8
|
|
9
|
+
■参考にしたサイト
|
10
|
+
https://dialogflow-python-client-v2.readthedocs.io/en/latest/
|
11
|
+
こちらのDetecting Intent (Texts)を参考にしています。
|
12
|
+
|
9
13
|
■APIのコード(local.py)
|
10
14
|
```ここに言語を入力
|
11
|
-
|
15
|
+
project_id = "プロジェクトのID"
|
12
|
-
|
16
|
+
session_id = ""
|
13
|
-
|
17
|
+
language_code = "ja"
|
14
|
-
|
18
|
+
session_client = dialogflow.SessionsClient()
|
15
19
|
|
16
|
-
|
20
|
+
session = session_client.session_path(project_id, session_id)
|
17
21
|
|
18
|
-
|
22
|
+
text_input = dialogflow.types.TextInput(text=query, language_code=language_code)
|
19
|
-
|
23
|
+
query_input = dialogflow.types.QueryInput(text=text_input)
|
20
|
-
|
24
|
+
response = session_client.detect_intent(session=session, query_input=query_input)
|
21
|
-
|
25
|
+
print('Query text: {}'.format(response.query_result.query_text))
|
22
|
-
|
26
|
+
print('Detected intent: {} (confidence: {})\n'.format(response.query_result.intent.display_name,response.query_result.intent_detection_confidence))
|
23
|
-
|
27
|
+
print('Fulfillment text: {}\n'.format(response.query_result.fulfillment_text))
|
24
28
|
```
|
25
29
|
|
26
30
|
■コード実行時のエラー
|