A packaged GenieScript in Python
Project description
Packaged GenieScript for Python
GenieScript's core engine is originally built in Java/TypeScript. This is its language extension in Python. The goal of this package is to:
-
Provide an easy installation, almost directly from
pip
-
Expose the GenieScript engine as a set of easy-to-use APIs, enabling it to be used in larger Python projects
Installation
-
Install node in your current environment.
- GenieScript recommends
node >= 18
, although it is yet to be tested on earlier nodes. If you have multiple nodes in your environment, we recommend using nvm. After installing it, run (1)nvm install 18
, (2)nvm use 18
, and finally (3)nvm alias default 18
.
- GenieScript recommends
-
pip install pyGenieScript
-
pip install genienlp==0.7.0a4
(because installation ofgenienlp
depends on more libraries, it is not included as a mandatory dependency ofpyGenieScript
)
Usage
A minimalist example to run the yelp semantic parser
You can use GenieScript to query yelp database in natural language. We have prepared a yelp parser. Here are the steps to run this example:
- Open a
python
REPL process. Do the following:
>>> import pyGenieScript.geniescript
>>> genie = pyGenieScript.geniescript.Genie() # This command installs genie-toolkit and might take a while for the first time
>>> genie.nlu_server('yelp') # This command will download the yelp parser and might take a while for the first time
Tip: If you see Prediction worker had an error: spawn genienlp ENOENT
, this means genienlp
is not installed correctly.
If successful, the final message you see should be similar to this:
[I 230211 02:15:11 util:299] TransformerSeq2Seq has 139,420,416 parameters
Keep this REPL running, and in a separate terminal, run:
- The yelp skill requires you to register an API online and obtain a developer key. Register an account, retrieve the API key, and run:
export YELP_API_KEY=[your key]
- Open another
python
REPL process. Do the following:
>>> import pyGenieScript.geniescript
>>> genie = pyGenieScript.geniescript.Genie() # You should not need to wait now
>>> genie.initialize('localhost', 'yelp') # This sets the semantic parser to be accesible over local server
>>> genie.query("show me a chinese restaurant") # You should see meaningful results returned from Genie
>>> genie.quit() # Shuts down Genie server
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyGenieScript-0.0.0a3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 665a1a7c5720ba58cedfc773dffc6fa7aee6cb08a80bc418e73f021365c158f4 |
|
MD5 | 68917e06c5646a96a01d1c1eee1abb70 |
|
BLAKE2b-256 | a5550d3be2400a16c0e121cd1dab997fdc4380b24f1bd4276f049c4057226550 |