Giter Site home page Giter Site logo

ai-dungeon-cli's Introduction

AI Dungeon CLI

This is basically a cli client to play.aidungeon.io.

This allows playing AI Dungeon 2 inside a terminal.

I primarily did this to play the game on a DEC VT320 hardware terminal for a more faithful experience.

For more context, read the accompanying blog post.

AI Dungeon on a VT320

WARNING: As of writing the this client does not work anymore. This seems to be associated with API changes necessary for the introduction of the stamina system. We'll eventually adapt to those new changes and if you're handy with python you can help speed things up.

Installation

pip

PyPI version fury.io

$ python3 -m pip install ai-dungeon-cli

Or for unstable release from the source code:

$ python3 -m pip install .

Arch Linux

AUR version

Package is on AUR.

Using trizen:

$ trizen -S ai-dungeon-cli-git

Old school way:

$ git clone https://aur.archlinux.org/ai-dungeon-cli-git.git
$ cd ai-dungeon-cli-git
$ makepkg -si

Playing

Unless specified, all user inputs are considered Do actions.

Quoted input entries are automatically interpreted as Say actions, e.g.:

> "Hey dragon! You didn't invite me to the latest BBQ party!"

Do be explicit about the action type, prefix your input with a command:

  • /do
  • /say
  • /story
  • /remember

For example, the previous Say prompt could also be written:

> /say Hey dragon! You didn't invite me to the latest BBQ party!

To quit, either press Ctrl-C, Ctrl-D or type in the special /quit command.

Running

In any case, you first need to create a configuration file.

Installed

$ ai-dungeon-cli

From source

With a conda env (assuming you're using anaconda):

$ cd ai-dungeon-cli
$ conda env create
$ conda activate ai-dungeon-cli-env
$ ./ai_dungeon_cli/__init__.py

With a viltualenv:

$ cd ai-dungeon-cli
$ virtualenv -p $(command -v python3) ai-dungeon-cli-venv
$ source ai-dungeon-cli-venv/bin/activate
$ python3 -m pip install -r requirements.txt
$ ./ai_dungeon_cli/__init__.py

Please note that all those examples use a virtual env in order to not mess up with the main Python env on your system.

Configuration (optional)

Several things can be tuned by resorting to a config file.

Create a file config.yml either:

  • in the same folder in your home folder: $HOME/.config/ai-dungeon-cli/config.yml
  • in the same folder as the sources: ./ai-dungeon-cli/ai_dungeon_cli/config.yml

Authentication

By default, if no authentication configuration is provided, an anonymous session is created.

ai-dungeon-cli supports 2 ways to configure user authentication.

Either precise a couple of credentials in conf:

email: '<MY-USER-EMAIL>'
password: '<MY-USER-PASSWORD>'

Or sniff a Authentication Token and use it directly:

auth_token: '<MY-AUTH-TOKEN>'

To get this token, you need to first login in a web browser to play.aidungeon.io.

Then you can find the token either in your browser localStorage or in the content of the connection_init message of the websocket communication (first sent message).

Either way, developer tools (F12) is your friend.

Slow Typing Animation

By default, responses are printed to the screen instantly.

To enable a fun "slow" typing animation, use:

slow_typing_effect: True

Prompt

The default user prompt is '> '.

You can customize it with e.g. :

prompt: 'me: '

Command-line arguments

All configuration options are mapped to command-line arguments.

Additionally, some features (such as multi-player support) are only available through those arguments.

The list of all arguments can be retrieved by calling ai-dungeon-cli with either -h of --help.

Authentication

One can use either the --auth-token <token> or --email <email> --password <password> arguments to authenticate.

Slow Typing Animation

Just append --slow-typing to your execution call to enable this fancy effect.

Prompt

The custom prompt can be set with --prompt '<prompt>'.

Multi-player

To join an existing multi-player adventure, use arguments --adventure <public-adventure-id> --name <character-name>.

Debug

TO enable debug mode and see the responses from the play.aidungeon.io API, use --debug. This option is mainly useful for developers.

Dependencies

Please have a look at requirements.txt.

Limitations and future improvements

Right now, the code is over-optimistic: we don't catch cleanly when the backend is down.

A better user experience could be achieved with the use of the curses library.

For now /revert and /alterspecial actions are not supported.

It would also be nice to add support for browsing other players' stories (Explore menu).

Implementation details

We fallback to a pure ASCII version of the splash logo if we detect an incompatible locale / terminal type.

Support

As you might have heard, hosting AI Dungeon costs a lot of money.

This cli client relies on the same infrastructure as the online version (play.aidungeon.io).

So don't hesitate to help support the hosting fees to keep the game up and running.

Author

Jordan Besly @p3r7 (blog).

Contributors & acknowledgements

Major contributions:

  • Idan Gur @idangur: OOP rewrite of game logic
  • Alberto Oporto Ames @otreblan: packaging, submission to AUR, CI chain and general housekeeping
  • @jgb95: slow typing effect
  • Alexander Batyrgariev @sasha00123: help on porting to new websocket/gql-based version of the API

Minor contributions:

  • Robert Davis @bdavs: pip requirements
  • @Jezza: suggested login using creds

Code for slow typing effect inspired by this message from Magnus Lycka on the Python Tutor mailing list.

Similar projects

People have also forked this code and adapted it to interact with GPT-3:

ai-dungeon-cli's People

Contributors

bdavs avatar idangur avatar jgb95 avatar otreblan avatar p3r7 avatar zer0xff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ai-dungeon-cli's Issues

error message at launch

I cannot launch application I have this error message ( i use archlinux)

Traceback (most recent call last):
File "/usr/bin/ai-dungeon-cli", line 33, in
sys.exit(load_entry_point('ai-dungeon->cli==0.4.5.dev7+git.bda573cb.dirty', 'console_scripts', 'ai-dungeon-cli'())
File /usr/bin/ai-dungeon-cli", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.8/importlib/init.py", line 127, in >import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "frozen importlib._bootstrap>", line 1014, in _gcd_import
File "frozen importlib._bootstrap>", line 991, in _find_and_load
File "frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "frozen importlib._bootstrap>", line 1014, in _gcd_import
File "frozen importlib._bootstrap>", line 991, in _find_and_load
File "frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "frozen importlib._bootstrap>", line 671, in _load_unlocked
File "frozen importlib._bootstrap_external>", line 783, in exec_module
File "frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/init.py", line 6, in module>
from gql import gql, Client, WebsocketsTransport
ImportError: cannot import name 'WebsocketsTransport' from 'gql'
(/usr/lib/python3.8/site-packages/gql/init.py)

sorry for my english i don't speak english it's google translation

Debug is true in production

I'm getting debug output after installing from the AUR:


 ▄▄▄       ██▓   ▓█████▄  █    ██  ███▄    █   ▄████ ▓█████  ▒█████   ███▄    █
▒████▄    ▓██▒   ▒██▀ ██▌ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▒██▒  ██▒ ██ ▀█   █
▒██  ▀█▄  ▒██▒   ░██   █▌▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▒██░  ██▒▓██  ▀█ ██▒
░██▄▄▄▄██ ░██░   ░▓█▄   ▌▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██   ██░▓██▒  ▐▌██▒
 ▓█   ▓██▒░██░   ░▒████▓ ▒▒█████▓ ▒██░   ▓██░░▒▓███▀▒░▒████▒░ ████▓▒░▒██░   ▓██░
 ▒▒   ▓▒█░░▓      ▒▒▓  ▒ ░▒▓▒ ▒ ▒ ░ ▒░   ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▒░   ▒ ▒
  ▒   ▒▒ ░ ▒ ░    ░ ▒  ▒ ░░▒░ ░ ░ ░ ░░   ░ ▒░  ░   ░  ░ ░  ░  ░ ▒ ▒░ ░ ░░   ░ ▒░
  ░   ▒    ▒ ░    ░ ░  ░  ░░░ ░ ░    ░   ░ ░ ░ ░   ░    ░   ░ ░ ░ ▒     ░   ░ ░
      ░  ░ ░        ░       ░              ░       ░    ░  ░    ░ ░           ░
                  ░

query options (variant #1)
{'user': {'id': '1361639', 'username': 'user_1361639', '__typename': 'User'}, 'content': {'id': 'scenario:458612', 'userId': '2510019', 'contentType': 'scenario', 'contentId
ptions': [{'id': 'scenario:458617', 'title': 'fantasy (recommended)', '__typename': 'Content'}, {'id': 'scenario:458620', 'title': 'mystery', '__typename': 'Content'}, {'id'
nt'}, {'id': 'scenario:458623', 'title': 'zombies', '__typename': 'Content'}, {'id': 'scenario:458624', 'title': 'cyberpunk', '__typename': 'Content'}, {'id': 'scenario:4586
o:459772', 'title': 'archive', '__typename': 'Content'}], 'playPublicId': None, '__typename': 'Content'}}
Pick a setting...

It seam like debug is hard coded to be enabled : https://github.com/Eigenbahn/ai-dungeon-cli/blob/master/ai_dungeon_cli/__init__.py#L33

Does not load even though dependencies are satisfied

Hello. I installed the program and have python 3.5.2 & requests library installed, however, starting up the program gives an error:

Traceback (most recent call last):
	File "/usr/local/bin/ai-dungeon-cli", line 18, in <module>
		cfg = yaml.load(cfg_raw, Loader=yaml.FullLoader)
AttributeError: module 'yaml' has no attribute 'FullLoader'

It appears that there is an error with the yaml package. However, pip3 doesn't want to install yaml, as it doesn't appear to be a package that can be installed, so it's probably a python-inbuilt package like math. Does anyone know what might be causing this?

auth_token not working

When I console.log(window.localStorage), I get the accessToken which I copy-paste into $HOME/.config/ai-dongeon-cli/config.yml file as auth_token: 'my auth token here'. When I run it, I get the following error:

 ▄▄▄       ██▓   ▓█████▄  █    ██  ███▄    █   ▄████ ▓█████  ▒█████   ███▄    █
▒████▄    ▓██▒   ▒██▀ ██▌ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▒██▒  ██▒ ██ ▀█   █
▒██  ▀█▄  ▒██▒   ░██   █▌▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▒██░  ██▒▓██  ▀█ ██▒
░██▄▄▄▄██ ░██░   ░▓█▄   ▌▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██   ██░▓██▒  ▐▌██▒
 ▓█   ▓██▒░██░   ░▒████▓ ▒▒█████▓ ▒██░   ▓██░░▒▓███▀▒░▒████▒░ ████▓▒░▒██░   ▓██░
 ▒▒   ▓▒█░░▓      ▒▒▓  ▒ ░▒▓▒ ▒ ▒ ░ ▒░   ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▒░   ▒ ▒
  ▒   ▒▒ ░ ▒ ░    ░ ▒  ▒ ░░▒░ ░ ░ ░ ░░   ░ ▒░  ░   ░  ░ ░  ░  ░ ▒ ▒░ ░ ░░   ░ ▒░
  ░   ▒    ▒ ░    ░ ░  ░  ░░░ ░ ░    ░   ░ ░ ░ ░   ░    ░   ░ ░ ░ ▒     ░   ░ ░
      ░  ░ ░        ░       ░              ░       ░    ░  ░    ░ ░           ░
                  ░

Unexpected response from API backend:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 585, in main
    ai_dungeon.choose_config()
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 318, in choose_config
    r.raise_for_status()
  File "/usr/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://ai-dungeon-api.herokuapp.com/scenario/362833/options

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/ai-dungeon-cli", line 33, in <module>
    sys.exit(load_entry_point('ai-dungeon-cli==0.3.1.dev0+git.0bef6eeb.dirty', 'console_scripts', 'ai-dungeon-cli')())
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 611, in main
    term_io.handle_basic_output(err)
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 77, in handle_basic_output
    print("\n".join(textwrap.wrap(text, self.get_width())))
  File "/usr/lib/python3.8/textwrap.py", line 379, in wrap
    return w.wrap(text)
  File "/usr/lib/python3.8/textwrap.py", line 351, in wrap
    chunks = self._split_chunks(text)
  File "/usr/lib/python3.8/textwrap.py", line 337, in _split_chunks
    text = self._munge_whitespace(text)
  File "/usr/lib/python3.8/textwrap.py", line 154, in _munge_whitespace
    text = text.expandtabs(self.tabsize)
AttributeError: 'HTTPError' object has no attribute 'expandtabs'

Ask politely maintainers / dev for permission

As pointed out by @importnetminecraft #23 (comment), this project could theoretically be used as a basis for creating nefarious DDoSing scripts to play.aidungeon.io.

My personal take on this #23 (comment) is that somebody with the will & power of performing a proper DDoS attack wouldn't be depending so much on this tool for this anyway.

But it would be a good anyway to just say hello and ask politely for permission.
And I guess it's nice for them to track those alternative & unofficial canals (notably twitch & messenger bots) by which they gain a few new users.

Is this pip package was ever working?

When I install via the pip package manager I don't get the conda yml file as it is contained in the GitHub files. So I can't start the environment. The second thing that I'm experiencing is when I run ai-dungeon-cli I get some errors from the code itself about libraries not containing things, or this is not right until I install the env in conda.

(base) C:\Users\Merlin\anaconda3\Lib\site-packages\ai_dungeon_cli>ai-dungeon-cli
Traceback (most recent call last):
  File "c:\users\merlin\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\merlin\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Merlin\anaconda3\Scripts\ai-dungeon-cli.exe\__main__.py", line 4, in <module>
  File "c:\users\merlin\anaconda3\lib\site-packages\ai_dungeon_cli\__init__.py", line 6, in <module>
    from gql import gql, Client, WebsocketsTransport
ImportError: cannot import name 'WebsocketsTransport' from 'gql' (c:\users\merlin\anaconda3\lib\site-packages\gql\__init__.py)

Need poetry integration

We already have integration with:

  • vanilla pip (requirements.txt)
  • conda (environment.yaml)

The big advantage of conda is that it creates automatically a dedicated virtual env (conda env specifically). The bad thing is that it's pretty niche compared to pip.

Vanilla pip does not offer this automatic virtual env creation out of the box, but Poetry seems to fill up that gap (and be what the cool kids use).

Crash when input is empty

 ▄▄▄       ██▓   ▓█████▄  █    ██  ███▄    █   ▄████ ▓█████  ▒█████   ███▄    █
▒████▄    ▓██▒   ▒██▀ ██▌ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▒██▒  ██▒ ██ ▀█   █
▒██  ▀█▄  ▒██▒   ░██   █▌▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▒██░  ██▒▓██  ▀█ ██▒
░██▄▄▄▄██ ░██░   ░▓█▄   ▌▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██   ██░▓██▒  ▐▌██▒
 ▓█   ▓██▒░██░   ░▒████▓ ▒▒█████▓ ▒██░   ▓██░░▒▓███▀▒░▒████▒░ ████▓▒░▒██░   ▓██░
 ▒▒   ▓▒█░░▓      ▒▒▓  ▒ ░▒▓▒ ▒ ▒ ░ ▒░   ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▒░   ▒ ▒
  ▒   ▒▒ ░ ▒ ░    ░ ▒  ▒ ░░▒░ ░ ░ ░ ░░   ░ ▒░  ░   ░  ░ ░  ░  ░ ▒ ▒░ ░ ░░   ░ ▒░
  ░   ▒    ▒ ░    ░ ░  ░  ░░░ ░ ░    ░   ░ ░ ░ ░   ░    ░   ░ ░ ░ ▒     ░   ░ ░
      ░  ░ ░        ░       ░              ░       ░    ░  ░    ░ ░           ░
                  ░

Pick a setting...

1) fantasy
2) mystery
3) apocalyptic
4) zombies
5) cyberpunk
6) custom
7) archive
8) madlib
> 1
Select a character...

1) noble
2) knight
3) squire
4) wizard
5) ranger
6) peasant
7) rogue
> 1
Enter your character's name...

> 1
Generating story... Please wait...

 You are 1, a noble living in the kingdom of Larion. You have a pouch of gold
and a small dagger. You are awakened by one of your servants who tells you that
your keep is under attack. You look out the window and see the enemy
approaching.  "Run!" you shout, but there is no time to run now. The soldiers
surround your keep and begin firing their muskets at it as well as throwing
stones from the walls. They are relentless and soon all that remains is for you
to make a choice...

> 
Traceback (most recent call last):
  File "/usr/bin/ai-dungeon-cli", line 11, in <module>
    load_entry_point('ai-dungeon-cli==0.3.0', 'console_scripts', 'ai-dungeon-cli')()
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 589, in main
    ai_dungeon.start_game()
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 278, in start_game
    self.process_next_action()
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 545, in process_next_action
    self.process_regular_action(user_input)
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 491, in process_regular_action
    (action, user_input) = self.find_action_type(user_input)
  File "/usr/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 482, in find_action_type
    elif user_input[0] == '"' and user_input[-1] == '"':
IndexError: string index out of range

Issue with stuff that i don't understand

It seems to actually start, but then i get this error, i don't really know what's wrong or how to fix it, please help, ty <3

 ▄▄▄       ██▓   ▓█████▄  █    ██  ███▄    █   ▄████ ▓█████  ▒█████   ███▄    █
▒████▄    ▓██▒   ▒██▀ ██▌ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▒██▒  ██▒ ██ ▀█   █
▒██  ▀█▄  ▒██▒   ░██   █▌▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▒██░  ██▒▓██  ▀█ ██▒
░██▄▄▄▄██ ░██░   ░▓█▄   ▌▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██   ██░▓██▒  ▐▌██▒
 ▓█   ▓██▒░██░   ░▒████▓ ▒▒█████▓ ▒██░   ▓██░░▒▓███▀▒░▒████▒░ ████▓▒░▒██░   ▓██░
 ▒▒   ▓▒█░░▓      ▒▒▓  ▒ ░▒▓▒ ▒ ▒ ░ ▒░   ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▒░   ▒ ▒
  ▒   ▒▒ ░ ▒ ░    ░ ▒  ▒ ░░▒░ ░ ░ ░ ░░   ░ ▒░  ░   ░  ░ ░  ░  ░ ▒ ▒░ ░ ░░   ░ ▒░
  ░   ▒    ▒ ░    ░ ░  ░  ░░░ ░ ░    ░   ░ ░ ░ ░   ░    ░   ░ ░ ░ ▒     ░   ░ ░
      ░  ░ ░        ░       ░              ░       ░    ░  ░    ░ ░           ░
                  ░

Traceback (most recent call last):
  File "/home/runner/TESTY/venv/bin/ai-dungeon-cli", line 8, in <module>
    sys.exit(main())
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 357, in main
    ai_dungeon.make_user_choose_config()
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 178, in make_user_choose_config
    prompt, settings = self.api.get_options(self.api.single_player_mode_id)
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/ai_dungeon_cli/impl/api/client.py", line 119, in get_options
    result = self._execute_query('''
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/ai_dungeon_cli/impl/api/client.py", line 32, in _execute_query
    return self.gql_client.execute(gql(query), variable_values=params)
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/client.py", line 355, in execute
    data = loop.run_until_complete(
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/client.py", line 252, in execute_async
    return await session.execute(
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/client.py", line 1143, in execute
    result = await self._execute(
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/client.py", line 1049, in _execute
    result = await asyncio.wait_for(
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
    return fut.result()
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets_base.py", line 432, in execute
    async for result in generator:
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets_base.py", line 388, in subscribe
    answer_type, execution_result = await listener.get()
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets_base.py", line 56, in get
    raise item
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets_base.py", line 310, in _receive_data_loop
    answer_type, answer_id, execution_result = self._parse_answer(
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets.py", line 425, in _parse_answer
    return self._parse_answer_apollo(json_answer)
  File "/home/runner/TESTY/venv/lib/python3.8/site-packages/gql/transport/websockets.py", line 386, in _parse_answer_apollo
    raise TransportQueryError(
gql.transport.exceptions.TransportQueryError: {'message': 'Session not found'}

Update to latest API revision / externalized API client lib

Relying on an externalized low-level API client lib would allow:

  • more projects to rely on it
  • have a less monolithic code base
  • be more effective when adapting to API changes

Initial idea formulated at #23 (comment).

Would certainly explore using 1Macho/AIDungeonAPI as proposed by #23 (comment).

Subjects to explore:

  • have only an async version of API calls (that could be made sync by awaiting them) or propose both (for performance + legibility)
  • having a debug option to log queries / responses

GQL pip version filter matches alpha4 causing a BC break

When using "python3 -m pip install ai-dungeon-cli" method OR installing from source, pip is installing the "gql-3.0.0a4" package automatically, resulting in the following error:

Traceback (most recent call last):
  File "/home/mnowak/.local/bin/ai-dungeon-cli", line 5, in <module>
    from ai_dungeon_cli.__init__ import main
  File "/home/mnowak/.local/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 6, in <module>
    from gql import gql, Client, WebsocketsTransport
ImportError: cannot import name 'WebsocketsTransport' from 'gql' (/home/mnowak/.local/lib/python3.8/site-packages/gql/__init__.py)

If I remove that package and manually install gql-3.0.0a1, a2, or a3 I am getting this error:

  File "/home/mnowak/.local/bin/ai-dungeon-cli", line 8, in <module>
    sys.exit(main())
  File "/home/mnowak/.local/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 356, in main
    ai_dungeon.make_user_choose_config()
  File "/home/mnowak/.local/lib/python3.8/site-packages/ai_dungeon_cli/__init__.py", line 177, in make_user_choose_config
    prompt, settings = self.api.get_options(self.api.single_player_mode_id)
  File "/home/mnowak/.local/lib/python3.8/site-packages/ai_dungeon_cli/impl/api/client.py", line 119, in get_options
    result = self._execute_query('''
  File "/home/mnowak/.local/lib/python3.8/site-packages/ai_dungeon_cli/impl/api/client.py", line 32, in _execute_query
    return self.gql_client.execute(gql(query), variable_values=params)
  File "/home/mnowak/.local/lib/python3.8/site-packages/gql/client.py", line 120, in execute
    data: Dict[Any, Any] = loop.run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/mnowak/.local/lib/python3.8/site-packages/gql/client.py", line 99, in execute_async
    return await session.execute(document, *args, **kwargs)
  File "/home/mnowak/.local/lib/python3.8/site-packages/gql/client.py", line 342, in execute
    raise TransportQueryError(str(result.errors[0]), errors=result.errors)
gql.transport.exceptions.TransportQueryError: {'message': 'Cannot query field "content" on type "Query". Did you mean "comments"?', 'locations': [{'line': 7, 'column': 3}], 'extensions': {'code': 'INTERNAL_SERVER_ERROR'}}
mnowak@L5110:~/ai-dungeon-cli$ 

Installed packages:

mnowak@L5110:~/ai-dungeon-cli$ pip3 freeze --user
ai-dungeon-cli==0.4.5
aiohttp==3.6.2
async-timeout==3.0.1
attrs==20.3.0
gql==3.0.0a1
graphql-core==3.1.2
multidict==4.7.6
promise==2.3
requests==2.24.0
Rx==1.6.1
websockets==8.1
yarl==1.5.1

I see it referencing a config of some sort but from reading the repo information I believed the config was optional? I'm not sure if that is related or not to this so I apologize if the error is something simple I missed. Please let me know if you would like me to run anything or provide any other information, thanks!

Support multiplayer mode

Seems pretty easy to do: just an hardcoded scenario-id different than the one for single player.

But how to connect with other known users?

Also, should we prompt user every time or assume single player and enable multiplayer w/ a cli option?

Port to newest API

Sorry if this bothers you, I got an error and I think this is the best place to report it. Included the error log.
AIDCLI.log

readline broke OSX build

so there are 2 issues as of the readline merge.

  1. readline.get_line_buffer is a function so its missing () operator
  2. adding the operator, you notice that process_next_action() is now continusly looping without user input, since readline.get_line_buffer() seems to be a none blocking call.
Traceback (most recent call last):
  File "ai_dungeon_cli/__init__.py", line 353, in <module>
    main()
  File "ai_dungeon_cli/__init__.py", line 337, in main
    ai_dungeon.start_game()
  File "ai_dungeon_cli/__init__.py", line 303, in start_game
    self.process_next_action()
  File "ai_dungeon_cli/__init__.py", line 294, in process_next_action
    if user_input.startswith("/remember"):
AttributeError: 'builtin_function_or_method' object has no attribute 'startswith'

Crash when using --slow-typing

Hi,

when I append the --slow-typing switch, I get the following error:

~/.config/ai-dungeon-cli$ ai-dungeon-cli --slow-typing
Traceback (most recent call last):
  File "/usr/local/bin/ai-dungeon-cli", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/ai_dungeon_cli/__init__.py", line 311, in main
    term_io = TermIoSlowStory(conf.prompt)
  File "/usr/local/lib/python3.8/dist-packages/ai_dungeon_cli/impl/user_interaction.py", line 83, in __init__
    sys.stdout = Unbuffered(sys.stdout)
NameError: name 'sys' is not defined

Do I have a wrong python version installed?
Thanks for the help!

New Release request

Can you make a new release?
The current one doesn't include the setup.py to make the package.
So I can make a non CVS AUR package.

Implement login support.

Just thought I'd give you a heads up.
You can log in the user if you want with:

POST https://api.aidungeon.io/users

{
    "email": "_",
    "password": "_"
}

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.