Skip to main content

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

  1. 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.
  2. Install some required system dependency of pyGenieScript, including:

  3. pip install pyGenieScript

  4. pip install genienlp==0.7.0a4 (because installation of genienlp depends on more libraries, it is not included as a mandatory dependency of pyGenieScript). For Mac M1/M2 users, refer to this installation guide.

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:

  1. 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:

  1. 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]
  1. 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

Installation FAQ

If you encounter a stall of genie.query() when running for the first time (see here), please cancel the stalled process and run again.

API documentation

Main API documentations are aviliable here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyGenieScript-0.0.0b19.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyGenieScript-0.0.0b19-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file pyGenieScript-0.0.0b19.tar.gz.

File metadata

  • Download URL: pyGenieScript-0.0.0b19.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pyGenieScript-0.0.0b19.tar.gz
Algorithm Hash digest
SHA256 7a3b722272b40be21fd844e1b4904e343852f8a7f214cab1948ffb86d8e57cce
MD5 0a7d13a0d46eb46099bba2eed0a2e06b
BLAKE2b-256 2f9a0c9951e8e38e21e3badfa4216535218fbfee145433293d87de2b5aee4333

See more details on using hashes here.

File details

Details for the file pyGenieScript-0.0.0b19-py3-none-any.whl.

File metadata

File hashes

Hashes for pyGenieScript-0.0.0b19-py3-none-any.whl
Algorithm Hash digest
SHA256 6e735c757fded2c0a401ad46d9f9b4ec16d7bc220c873e1d81937bbb52ab6fac
MD5 0b38af5fc64178b93b0e2ca9c6b6b657
BLAKE2b-256 c6fa79e92976e839bdf748952b2458228700c0158cadd5669885825b90ca7c6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page