-
Python >= 3.8
click
langchain
langchain_openai
openai
pydantic
pynput
python-dotenv
requests
sshkeyboard
types-pynput
types-requests
-
OpenAI API Key
See pyproject.toml
for detail information.
You can install simple_typing_application
with pip
.
pip install git+https://github.com/hmasdev/simple_typing_application.git
If you want to install the full-version, i.e. simple_typing_application
with data analysis packages like pandas
, matplotlib
and jupyterlab
, specify [extra]
.
git clone https://github.com/hmasdev/simple_typing_application.git
cd simple_typing_application
pip install .[extra]
You can specify the following optional dependencies:
[huggingface]
[extra]
[dev]
For more details, see ./pyproject.toml
.
You can specify some parameters with '.json'.
For example, the following .json
files are valid:
The content of ./sample_config.json
is as follows:
{
"sentence_generator_type": "OPENAI",
"sentence_generator_config": {
"model": "gpt-3.5-turbo-16k",
"temperature": 0.7,
"openai_api_key": "HERE_IS_YOUR_API_KEY",
"memory_size": 0,
"max_retry": 5
},
"user_interface_type": "CONSOLE",
"user_interface_config": {},
"key_monitor_type": "PYNPUT",
"key_monitor_config": {},
"record_direc": "./record"
}
As default, the contents of 'sample_config.json' are used except openai_api_key
.
In this case, you should add an environment variable OPENAI_API_KEY
which contains your API key or create .env
file like
OPENAI_API_KEY={HERE_IS_YOUR_API_KEY}
You can specify the followings as sentence_generator_type
:
OPENAI
: Use OpenAI API to generate typing targets;HUGGINGFACE
: Use the model available in HuggingFace to generate typing targets;STATIC
: Use typing targets which you have specified.
For each sentence_generator_type
, you can specify the detailed parameters as sentence_generator_config
:
-
OPENAI
model
: See langchain.chat_models.openai.ChatOpenAItemperature
: See langchain.chat_models.openai.ChatOpenAIopenai_api_key
: See langchain.chat_models.openai.ChatOpenAImemory_size
: See langchain.memory.buffer.ConversationBufferMemorymax_retry
: Maximum number of times to rerun when an error occurs
-
HUGGINGFACE
model
: Model name. For example, "line-corporation/japanese-large-lm-3.6b", "rinna/japanese-gpt-neox-3.6b", "rinna/bilingual-gpt-neox-4b" and "cyberagent/open-calm-7b" are available as Japanese LLM. For details, See huggingface.co/models.do_sample
:true
orfalse
. See huggingface.co/docs/transformers/pipeline_tutorial.max_length
: int. See huggingface.co/docs/transformers/pipeline_tutorial.top_k
: int. See huggingface.co/docs/transformers/pipeline_tutorial.top_p
: float between 0 and 1. See huggingface.co/docs/transformers/pipeline_tutorial.device
:cpu
orcuda
-
STATIC
text_kana_map
: key-value pairs whose keys are row typing targets and values are typing targets which do not include kanjis;is_random
: whether typing targets are randomly selected or sequentially displayed.
To see the default values, see ./simple_typing_application/models/config_models/sentence_generator_config_model.py
.
You can specify the followings as user_interface_type
:
CONSOLE
: CUI
For each user_interface_type
, you can specify the detailed parameters as user_interface_config
:
CONSOLE
- No parameters
To see the default values, see ./simple_typing_application/models/config_models/user_interface_config_model.py
.
You can specity the followings as key_monitor_type
:
PYNPUT
:pynput
-based local key monitorSSHKEYBOARD
:sshkeyboard
-based key monitor
For each key_monitor_type
, you can specify the detailed parameters as key_monitor_config
:
PYNPUT
- No parameters
SSHKEYBOARD
- No parameters
To see the default values, see ./simple_typing_application/models/config_models/key_monitor_config_model.py
.
You can launch this application with the following command:
python -m simple_typing_application -c HERE_IS_YOUR_CONFIG_FILE
If you want to launch this application with debug mode, run the following command:
python -m simple_typing_application -c HERE_IS_YOUR_CONFIG_FILE --debug
For more details, run python -m simple_typing_application --help
.
simple_typing_application
shows typing targets through the interface which you has specified.
Type correct keys.
Note that Typing Target (Romaji)
displayed in your interface is one of correct typing patterns. For example, when Typing Target (Hiragana)
is 'ち', both 'ti' and 'chi' are correct although only one of them is displayed.
In addition to normal typing, the following keys can be accepted:
Esc
: to quit the application;Ctrl+c
: to quit the application;Tab
: to skip the current typing target.
The application records your typing in the following format in the directory specified in you config file for each typing target.
{
"timestamp": "HERE IS TIMESTAMP THE TYPING START WITH FORMAT %Y-%m-%dT%H:%M:%S.%f",
"typing_target": {
"text": "HERE IS TYPING TARGET",
"text_hiragana_alphabet_symbol": "HERE IS TRANSFORMED STRING WHICH CONTAINS ONLY HIRAGANA, ALPHABET AND SYMBOLS",
"typing_target": [["CORRECT PATTERN. TYPICALLY ROMANIZED STRING", ...], ...]
},
"records": [
{
"timestamp": "HERE IS TIMESTAMP WHEN YOU TYPE %Y-%m-%dT%H:%M:%S.%f",
"pressed_key": "WHICH KEY YOU HAVE PRESSED",
"correct_keys": ["", ...],
"is_correct": true or false
},
...
]
}
Refer to ./sample_record.json
for example.
-
Fork this repository:
-
Clone your forked repository:
git clone https://github.com/hmasdev/simple_typing_application cd simple_typing_application
-
Create your feature branch:
git checkout -b feature/your-feature
-
Setup your development environment:
pip install .[dev]
if you want to develop the application with
huggingface
,pandas
and etc., run the following command:$ pip install .[huggingface,extra,dev]
To know which option is available, see
./pyproject.toml
. -
Develop your feature and add tests.
-
Test your feature:
pytest # Unit test pytest -m integrate # integration test
-
Check the code style and static type:
flake8 simple_typing_application flake8 tests mypy simple_typing_application mypy tests
-
Commit your changes:
git add . git commit -m "Add your feature"
-
Push to the branch:
git push -u origin feature/your-feature
-
Create a new Pull Request:
Thank you for your contribution!
simple_typing_application
is licensed under the MIT License. See the LICENSE file for more details.
- [1] https://api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
- [2] https://api.python.langchain.com/en/latest/memory/langchain.memory.buffer.ConversationBufferMemory.html
- [3] https://huggingface.co/models?pipeline_tag=text-generation
- [4] https://huggingface.co/docs/transformers/pipeline_tutorial