Giter Site home page Giter Site logo

kalliope-project / kalliope_neuron_answer_of_everything Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 6.0 55 KB

Get an answer to a question from multiple backend engine like Google, wolframalpha or DuckDuckGo

License: GNU General Public License v3.0

Python 100.00%

kalliope_neuron_answer_of_everything's Introduction

answer-of-everything

Synopsis

A search engine to ask all kind of questions, where you can set the priority of the different search engines. If the first engine does not find an answer, it will lookup the next engine.

Installation

kalliope install --git-url https://github.com/kalliope-project/kalliope_neuron_answer_of_everything.git

Example

  • Kalliope --> I have a question how tall is the eiffel tower
  • Kalliope --> Can you answer me what time is it in Tokio
  • Kalliope --> Tell me when albert einstein is born
  • Kalliope --> Can you tell me what day was March 31, 1989

Main options

parameter required comments
question yes
engines yes Define the search engines you want to use
translate no Wolfram Alpha and Duckduckgo only support English, here you can find supported languages

Wolfram alpha engine

parameter required comments
wolfram_alpha yes
key yes https://products.wolframalpha.com/api/
unit no You can choose between metric (default) or imperial
option no You can chose between spoken_answer (default) or short_answer. With spoken_answer you get a full sentence back if available, otherwise it returns a short_answer

Google engine

parameter required comments
google yes

Duckduckgo engine

parameter required comments
duckduckgo yes

Returned values

name description
wolfram_answer Answer found on wolfram alpha
google_answer Answer found on google
duckduckgo_answer Answer found on duckduckgo
NoAnswerFound No Answer found, returns the question

Synapse example for all three engines (The order you define the engine is the order which Kalliope will try to get the answer, in this example it will try to get a answer first from wolfram_alpha then google and last duckduckgo)

  
  - name: "answer-of-everything"
    signals: 
      - order: "answer me the question {{ query }}"
    neurons:
      - answer_of_everything:
          question: "{{ query }}"
          language: "de"
          engines:  
                wolfram_alpha: 
                    key: "XXXX-XXXXXXXX"
                google:
                duckduckgo:
          file_template: "templates/answer_of_everything.j2" 

Synapse example for single engine

  - name: "answer-of-everything"
    signals: 
      - order: "ask wolfram {{ query }}"
    neurons:
      - answer_of_everything:
          question: "{{ query }}"
          language: "de"
          engines:  
                wolfram_alpha: 
                    key: "XXXX-XXXXXXXX"
          file_template: "templates/answer_of_everything.j2" 

Example file template

{% if wolfram_answer %} 
   {{ wolfram_answer }}
{% elif google_answer %}
    {{ google_answer }}
{% elif duckduckgo_answer %}
    {{ duckduckgo_answer }}
{% elif NoAnswerFound %} 
    I'm Sorry I have no Answer to the question {{ NoAnswerFound }}
{% endif %}

 ``

kalliope_neuron_answer_of_everything's People

Contributors

corus87 avatar sispheor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kalliope_neuron_answer_of_everything's Issues

Default API

WolframAlpha offers us various APIs http://products.wolframalpha.com/api/. At the moment we can use the following 3:

http://products.wolframalpha.com/short-answers-api/documentation/
http://products.wolframalpha.com/spoken-results-api/documentation/
http://products.wolframalpha.com/api/documentation/

SpokenAnswer :       
# release of the simpons =  The answer is Sunday, December 17, 1989
# who is deadpool = Returns a biographie      
# what is the weather in New york = None
# what is water made of =  None
# what is the answer to everything = 42
# How old is the sun = The Sun is about 4.57 billion years old
# what time is it in tokio = The answer is 11:08:30 P.M. JST; Monday, May 21, 2018

ShortAnswer:
# release of the simpons =  Sunday, December 17, 1989
# who is deadpool = Returns a biographie
# what is the weather in New york = None
# what is water made of =  None
# what is the answer to everything = 42
# How old is the sun = 4.57 billion years
# what time is it in tokio = 11:08:31 P.M. JST, Monday, May 21, 2018
 
FullResults : 
# release of the simpons = Sunday, December 17, 1989 | more: None
# who is deadpool = alternate names | Wade "Winston" Wilson  |  Jack  |  The Merc With a Mouth  | ...  more: None
# what is the weather in New york = temperature | 18 °Cconditions | clearrelative humidity | 61%  (dew point: 11 °C)wind speed | 0 m/s(54 minutes ago) | more: dew point: 11 °C) wind speed, 0 m/s (54 minutes ago
# what is water made of =  | number of atoms | mass fraction | atom fraction H (hydrogen) | 2 | 11.191% | 66.7% O (oxygen) | 1 | 88.809% | 33.3% | more: hydrogen), 2, 11.191%, 66.7% O (oxygen), 1, 88.809%, 33.3%
# what is the answer to everything = 42 more: according to the book The Hitchhiker's Guide to the Galaxy, by Douglas Adams
# How old is the sun = Nothing
# what time is it in tokio = Nothing

Any suggestions, which API we should provide?

Error with translate

Hi,
I installed this neurons, and it's look very impressive. but it make me an error with the googletranslate's API.
Without the option translate: "fr", the responses are ok, but in english, and my english is so poor ...
With the option to translate, Kalliope fix, and the debug mode show me an error with the googletranslate code, line 53, empty argument ...
I use Python 2.7 and the last version of kalliope on Rpi.
I hav'nt my pi here, but if you want, i'll past the kalliope's debug tomorow.

And sorry for my little level in english ...

Proposal: implementation

- name: "test"
  signals:
    - order: "search on the internet {{ search }}"
  neurons:
    - answer_of_everything:
        engine: "wolfram"
        engine_parameters:  # optional
          parameter_name1: "value1"
          parameter_name2: "value2"
        search: "{{ search }}"
        say_template: "{{ answer_of_everything_response }}"

ERROR after answering ?!!

When i ask kalliope a quesion it answers me and then this error appears !!!

Google Speech Recognition thinks you said I have a question what time is it in Tokyo
Order matched in the brain. Running synapse "say-local-date"

Order matched in the brain. Running synapse "answer-of-everything-short"
it's 21 and 45 minute
Short answer found: 3:45:33 A.M. JST, Sunday, September 30, 2018

ERROR STARTS HERE :-

Exception in thread <class 'kalliope.signals.order.order.Order'>:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/signals/order/order.py", line 87, in run
self.start_trigger()
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 383, in trigger
return self.machine._process(func)
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 1059, in _process
self._transition_queue0
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 399, in _trigger
return self._process(event_data)
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 409, in _process
if trans.execute(event_data):
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 263, in execute
self._change_state(event_data)
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 274, in _change_state
event_data.machine.get_state(self.dest).enter(event_data)
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 120, in enter
event_data.machine.callback(handle, event_data)
File "build/bdist.linux-armv7l/egg/transitions/core.py", line 1005, in callback
func(*event_data.args, **event_data.kwargs)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/signals/order/order.py", line 185, in analysing_order_thread
is_api_call=False)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/SynapseLauncher.py", line 104, in run_matching_synapse_from_order
execdata = lifo_buffer.execute(is_api_call=is_api_call)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/Lifo/LIFOBuffer.py", line 109, in execute
self._process_synapse_list(last_synapse_fifo_list)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/Lifo/LIFOBuffer.py", line 139, in _process_synapse_list
self._process_neuron_list(matched_synapse=matched_synapse)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/Lifo/LIFOBuffer.py", line 173, in _process_neuron_list
parameters_dict=matched_synapse.parameters)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/NeuronLauncher.py", line 62, in start_neuron
instantiated_neuron = NeuronLauncher.launch_neuron(neuron)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/NeuronLauncher.py", line 44, in launch_neuron
resources_dir=neuron_folder)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/Utils/Utils.py", line 140, in get_dynamic_class_instantiation
return klass(**parameters)
File "resources/neurons/answer_of_everything/answer_of_everything.py", line 43, in init
self.say(answer)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/NeuronModule.py", line 149, in say
tts_message = self._get_message_from_dict(message)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/NeuronModule.py", line 197, in _get_message_from_dict
returned_message = self._get_file_template(self.file_template, message_dict)
File "/usr/local/lib/python2.7/dist-packages/kalliope-0.5.2-py2.7.egg/kalliope/core/NeuronModule.py", line 217, in _get_file_template
t = Template(cls._get_content_of_file(real_file_template_path))
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg/jinja2/environment.py", line 945, in new
return env.from_string(source, template_class=cls)
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg/jinja2/environment.py", line 880, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg/jinja2/environment.py", line 591, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "", line 1, in template
TemplateSyntaxError: tag name expected

@Sispheor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.