Skip to content

Commit

Permalink
Update documentation to reflect the rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
swapagarwal committed Apr 20, 2016
1 parent 9c1f53d commit caa709f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ To add a new module, follow these steps:

1. Fork the repo
2. Create a new branch (`git checkout -b my-new-feature`)
3. Add a new file in `modules/src/` folder (define `match` and `process` functions)
4. Add some tests in `modules/tests/` folder (run them locally with `py.test`)
3. Add a new file in `modules/src/` folder (define `process` function)
4. Add some tests in `modules/tests/` folder
5. Add the module name in `src/__init__.py`
6. Commit your changes (`git commit -am 'Add some feature'`)
7. Push to the branch (`git push origin my-new-feature`)
Expand All @@ -23,8 +23,6 @@ To fix a bug or enhance an existing module, follow these steps:
6. Push to the branch (`git push origin improve-feature`)
7. Create a Pull Request

You may take this [commit](https://github.com/swapagarwal/JARVIS-on-Messenger/commit/ee974e44d027f8bdc4329a35e1d8410d7779acb2) as a reference.

Keep the code as simple as possible. No need of obfuscation / code golf.

If you have to explain your code, you're doing it wrong!
Expand Down
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ There are a lot of features that I've planned for JARVIS. Feel free to add to th
Some advanced features:

- [ ] Add templates support (Structured Messages)
- [ ] Integrate with [Wit.ai](https://wit.ai/swapagarwal/JARVIS-on-Messenger) to parse Natural Language
- [x] Integrate with [Wit.ai](https://wit.ai/swapagarwal/JARVIS-on-Messenger) to parse Natural Language
- [ ] Retain context between queries

### Structure

```sh
├── modules/ # home for various features
├── modules/src/ # code goes here
├── modules/tests/ # tests go here
├── CONTRIBUTING.md # contributing guidelines
└── jarvis.py # the main bot
├── modules/ # home for various features
├── modules/src/ # code goes here
├── modules/tests/ # tests go here
├── CONTRIBUTING.md # contributing guidelines
└── jarvis.py # the main bot
```

### Usage
Expand All @@ -61,16 +61,11 @@ JARVIS is at your service [here](http://m.me/J.A.R.V.I.S.on.Messenger). Currentl

### Sample Queries

`Hi, Jarvis!`

`Are you there?`

`tell me a joke`

`iron man movie`

`cloud definition`

`Hi, Jarvis!`
`Are you there?`
`tell me a joke`
`iron man movie`
`cloud definition`
More examples can be found [here](https://github.com/swapagarwal/JARVIS-on-Messenger/tree/master/modules/tests).

### Local Development / Testing
Expand All @@ -79,4 +74,14 @@ More examples can be found [here](https://github.com/swapagarwal/JARVIS-on-Messe
2. `sudo apt-get install python-dev libffi-dev libssl-dev`
3. `pip install -r requirements.txt`
4. `python jarvis.py`
5. Visit `http://localhost:5000/test/?q=<YOUR_QUERY>` to see results.
5. Visit the following URLs to see results:
`http://localhost:5000/process/?q=<YOUR_QUERY>` returns the intent of the query.
`http://localhost:5000/search/?q=<YOUR_QUERY>` returns the search result of the query.

### History

I started out with rule-based model but it didn't scale well so now I've shifted to Natural Language Processing.
Rest assured, I'll strive to keep it as simple as possible so that you, yes you, can contribute!

If you'd like to contribute to the old model, you are welcome to do so as well.
I've created a new branch [`legacy`](https://github.com/swapagarwal/JARVIS-on-Messenger/tree/legacy) for this purpose. I'll be accepting Pull Requests to this branch also. :smile:
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ACCESS_TOKEN = '<ACCESS_TOKEN>'
VERIFY_TOKEN = '<VERIFY_TOKEN>'
WIT_AI_SERVER_ACCESS_TOKEN = '<WIT_AI_SERVER_ACCESS_TOKEN>'
WIT_AI_ACCESS_TOKEN = 'IKJJJYYVR3X672DHFVS7U7C4L2MQSS2P'
8 changes: 6 additions & 2 deletions jarvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
def about():
return 'Just A Rather Very Intelligent System, now on Messenger!'

@app.route('/test/')
def test():
@app.route('/process/')
def process():
return json.dumps(modules.process_query(request.args.get('q')))

@app.route('/search/')
def search():
return modules.search(request.args.get('q'))

@app.route('/webhook/', methods=['GET', 'POST'])
Expand Down
4 changes: 2 additions & 2 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import sys
from src import *

WIT_AI_SERVER_ACCESS_TOKEN = os.environ.get('WIT_AI_SERVER_ACCESS_TOKEN', config.WIT_AI_SERVER_ACCESS_TOKEN)
WIT_AI_ACCESS_TOKEN = os.environ.get('WIT_AI_ACCESS_TOKEN', config.WIT_AI_ACCESS_TOKEN)

def process_query(input):
try:
r = requests.get('https://api.wit.ai/message?v=20160420&q=' + input, headers={
'Authorization': 'Bearer %s' % WIT_AI_SERVER_ACCESS_TOKEN
'Authorization': 'Bearer %s' % WIT_AI_ACCESS_TOKEN
})
data = r.json()
intent = data['outcomes'][0]['intent']
Expand Down

0 comments on commit caa709f

Please sign in to comment.