def get_answer_from_kb(self, kb_details, question_from_user): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() self.kb_route = self.configuration[kb_details] question_to_kb = {} question_to_kb.update({'question': question_from_user}) headers = { 'Authorization': 'EndpointKey ' + self.kb_endpoint, 'Content-Type': 'application/json' } try: self.log.write_log(sessionID='session1', log_message="question " + str(question_to_kb)) self.conn = http.client.HTTPSConnection(self.kb_host, port=443) self.conn.request("POST", self.kb_route, str(question_to_kb), headers) self.response = self.conn.getresponse() self.answer = self.response.read() #this code is written to fetch the actual answer provided by the knowlegemaker answer_in_str = str(json.loads(self.answer)) answer_in_dict = ast.literal_eval(answer_in_str) answer_return = answer_in_dict['answers'][0]['answer'] self.log.write_log(sessionID='session1', log_message="question " + str(answer_return)) return answer_return except: print("Unexpected error:", sys.exc_info()[0]) print("Unexpected error:", sys.exc_info()[1])
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() self.kb_host = self.configuration['KB_HOST'] self.kb_endpoint = self.configuration['KB_ENDPOINT'] self.kb_route = '' self.log = Log()
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() self.luis_app_id=self.configuration['LUIS_APP_ID'] self.luis_endpoint_key = self.configuration['LUIS_ENDPOINT_KEY'] self.luis_endpoint = self.configuration['LUIS_ENDPOINT'] self.luis_app = LuisApplication(self.luis_app_id,self.luis_endpoint_key,self.luis_endpoint) self.luis_options = LuisPredictionOptions(include_all_intents=True,include_instance_data=True) self.luis_recognizer = LuisRecognizer(application=self.luis_app,prediction_options=self.luis_options,include_api_results=True) self.log=Log()
def __init__(self, conversation_state: ConversationState, user_state: UserState): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() self.luis_app_id = self.configuration['LUIS_APP_ID'] self.luis_endpoint_key = self.configuration['LUIS_ENDPOINT_KEY'] self.luis_endpoint = self.configuration['LUIS_ENDPOINT'] self.luis_app = LuisApplication(self.luis_app_id, self.luis_endpoint_key, self.luis_endpoint) self.luis_options = LuisPredictionOptions(include_all_intents=True, include_instance_data=True) self.luis_recognizer = LuisRecognizer( application=self.luis_app, prediction_options=self.luis_options, include_api_results=True) self.qna_knowledge_base_id = self.configuration["QNA_KNOWLEDGEBASE_ID"] self.qna_endpoint_key = self.configuration["QNA_ENDPOINT_KEY"] self.qna_host = self.configuration["QNA_ENDPOINT_HOST"] self.qna_maker = QnAMaker( QnAMakerEndpoint(knowledge_base_id=self.qna_knowledge_base_id, endpoint_key=self.qna_endpoint_key, host=self.qna_host)) self.log = Log() self.IntentIdentified = False self.intent = 'none' self.stat = 'init' self.city = "" self.score = "" if conversation_state is None: raise TypeError( "[StateManagementBot]: Missing parameter. conversation_state is required but None was given" ) if user_state is None: raise TypeError( "[StateManagementBot]: Missing parameter. user_state is required but None was given" ) self.conversation_state = conversation_state self.user_state = user_state self.conversation_data_accessor = self.conversation_state.create_property( "ConversationData") self.user_profile_accessor = self.user_state.create_property( "UserProfile")
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() """self.owmapikey = self.configuration['A*_SEARCH_API_KEY'] self.owm = pyowm.OWM(self.owmapikey) def get_direction_info(self,city): self.city=city self.bot_says = ###STRINGS OF DIRECTIONS ADDED TOGETHER (defined in function above)###""" return self.bot_says
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() """self.owmapikey = self.configuration['A*_SEARCH_API_KEY']
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config() self.owmapikey = self.configuration['WEATHER_API_KEY'] self.owm = pyowm.OWM(self.owmapikey)
def __init__(self): self.config_reader = ConfigReader() self.configuration = self.config_reader.read_config()
from flask import Flask from config.config_reader import ConfigReader from api.user_api import * app = Flask(__name__) app.register_blueprint(users_api) @app.route('/') def main_page(): return 'It is working!' if __name__ == '__main__': config_reader = ConfigReader() debug = config_reader.get_app_config("debug") port = config_reader.get_app_config("port") app.run(debug=debug, port=port)
import sys sys.path.insert(1, '/home/nitin/code/Ashrut/compass/ui_app/app/helper/kafka') from consumer import CustomKafkaConsumer as kafka_consumer from config.config_reader import ConfigReader config = ConfigReader() data = config.get_kafka_consumer_data() ip = data['ip'] port = data['port'] topic = data['topic'] from_begin = True if data['from_begin'] == 0: from_begin = False consumer = kafka_consumer(ip=ip, port=port, topic=topic, from_begin=from_begin) print('Starting Kafka Consumer!') consumer.get()