Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ local.properties
.target

resources/word2vec_toy_data_and_model
resources/knowledgebase/apikeys.yml
resources_nlu/word2vec/roboy_enwik8.txt
resources_nlu/error_test/newLexicon.txt

Expand Down Expand Up @@ -73,9 +72,7 @@ interactive/.ipynb_checkpoints
community-server/data
community-server/data-backup

*.iml
nlu/parser/target/

nlu/parser/src/main/java/edu/stanford/nlp/sempre/roboy/api/apiKeys\.yml

dialog/src/main/java/roboy/util/api/apiKeys\.yml
# API KEYS
*.key
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ If you wish to have more detailed information, please view the [docs page](https

### Enabling External APIs

If you want to set external APIs, you will have to create an `APIkeys.yml` file containing all the keys. For more information, see the [relevant documentation page](https://roboydialog.readthedocs.io/en/devel/user_manual/2_configuration.html#enabling-external-apis)
If you want to set external APIs, you will have to create an `api.key` file containing all the keys. For more information, see the [relevant documentation page](https://roboydialog.readthedocs.io/en/devel/user_manual/2_configuration.html#enabling-external-apis)

## Troubleshooting

Expand Down
7 changes: 5 additions & 2 deletions config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ IBM_TTS_PASS: ""
CONTEXT_GUI_ENABLED: false
ACTION_CLIENT_SCRIPT: "/home/roboy/workspace/Roboy/src/roboy_dialog/resources/scripts/action_client.py"

TELEGRAM_API_TOKENS_FILE: ""

# Logging Levels
# Each Logging Module has different levels. End users should use warn. Developers should use either info or debug/fine.
Expand All @@ -80,4 +79,8 @@ DIALOG_LOG_MODE: "WARN"

# Parser/NLU: LogInfo
# Supports all Log4J levels. See Documentation for more details
PARSER_LOG_MODE: "WARN"
PARSER_LOG_MODE: "WARN"

# API KEY FILES
TELEGRAM_API_TOKENS_FILE: ""
EXTERNAL_API_KEY_LIST: "resources/knowledgebase/api.key"
2 changes: 2 additions & 0 deletions dialog/src/main/java/roboy/util/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ConfigManager {
public static long CONVERSATION_TIMEOUT = 0;

public static String TELEGRAM_API_TOKENS_FILE = "";
public static String EXTERNAL_API_KEY_LIST = "resources/knowledgebase/api.key";

public static String MEMORY_LOG_MODE = "INFO";
public static String DIALOG_LOG_MODE = "INFO";
Expand Down Expand Up @@ -133,6 +134,7 @@ private static void initializeConfig() {
}

TELEGRAM_API_TOKENS_FILE = yamlConfig.getString("TELEGRAM_API_TOKENS_FILE");
EXTERNAL_API_KEY_LIST = yamlConfig.getString("EXTERNAL_API_KEY_LIST");

MEMORY_LOG_MODE = (yamlConfig.getString("MEMORY_LOG_MODE"));
PARSER_LOG_MODE = (yamlConfig.getString("PARSER_LOG_MODE"));
Expand Down
3 changes: 2 additions & 1 deletion dialog/src/main/java/roboy/util/api/APIHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.commons.configuration2.YAMLConfiguration;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.logging.log4j.Logger;
import roboy.util.ConfigManager;

import java.io.*;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -49,7 +50,7 @@ private static final class keyGetter {

static String getKey(String key) {
try {
yamlConfiguration.read(new FileReader("resources/knowledgebase/apiKeys.yml"));
yamlConfiguration.read(new FileReader(ConfigManager.EXTERNAL_API_KEY_LIST));
} catch (ConfigurationException e) {
logger.error("Config File contains Errors");
logger.error(e.getMessage());
Expand Down
6 changes: 3 additions & 3 deletions docs/developer_manual/1_Tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ To make the process of adding new external APIs easier, an interface is provided
Storing API Keys
------------------------

API Keys should be stored in the ``roboy_dialog/resources/knowledgebase/apiKeys.yml`` file. It is vitally important that this file does not end up on git. Entries should be stored in the YAML format: ``apikey: xxxxxxx_apikey_goes_here_xxxxxxx``. The first part of the entry is the YAML key, while the second is the actual API key.
API Keys should be stored in the ``roboy_dialog/resources/knowledgebase/api.key`` file. It is vitally important that this file does not end up on git. Entries should be stored in the YAML format: ``apikey: xxxxxxx_apikey_goes_here_xxxxxxx``. The first part of the entry is the YAML key, while the second is the actual API key.

Implementing the Interface
---------------------------
Expand All @@ -662,7 +662,7 @@ One must implement the methods...
getKeyName
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The purpose of ``getKeyName`` is to tell APIHub, what the YAML key associated with the API Key in the ``apiKeys.yml`` file is. ``return "weatherkey";`` in most cases shall suffice.
The purpose of ``getKeyName`` is to tell APIHub, what the YAML key associated with the API Key in the ``api.key`` file is. ``return "weatherkey";`` in most cases shall suffice.

validateArguments
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -675,7 +675,7 @@ This method should be used to check if the arguments passed by the user are vali
getAPIURL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This method is in charge of creating the API Request URL. Assuming the ``getKeyName`` function is implemented correctly, the first parameter shall automatically send you the API Key from the ``apiKeys.yml`` file. The second parameter are the API Request Arguments that your state sends to APIHub.
This method is in charge of creating the API Request URL. Assuming the ``getKeyName`` function is implemented correctly, the first parameter shall automatically send you the API Key from the ``api.key`` file. The second parameter are the API Request Arguments that your state sends to APIHub.

This method expects a valid API request URL to be returned, like ``http://api.openweathermap.org/data/2.5/weather?q=davos&APPID=xxxxxxxxx``.

Expand Down
2 changes: 1 addition & 1 deletion docs/user_manual/2_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Roboy Dialog supports multiple external APIs. At the present moment, three exter
- The Movie DB
- Yandex Translate

If you wish to have Roboy be able to tell the weather, tell you upcoming movies and translate, you have to register on these websites, generate an API key and denote the key in the ``resources/knowledgebase/apiKeys.yml`` file. There you shall replace the ``xxxxxxx`` portions with your key.
If you wish to have Roboy be able to tell the weather, tell you upcoming movies and translate, you have to register on these websites, generate an API key and denote the key in the ``resources/knowledgebase/api.key`` file. There you shall replace the ``xxxxxxx`` portions with your key.

.. warning::
Do not upload any changes to the apiKey file to Git. Consequences will be severe...
Expand Down
3 changes: 0 additions & 3 deletions resources/knowledgebase/apiKeys.yml

This file was deleted.