- å®çŸ©æžãã©ã«ã
ãã- å®çŸ©æž
ãã- ãµãå®çŸ©æž
- å€æ°è³æãã©ã«ã
ãã- å€æ°ãã¡ã€ã«1
ãã- å€æ°ãã¡ã€ã«2
- åèè³æãã©ã«ã
ãã- åèè³æ1
ãã- åèè³æ2
äŸãã°ã¹ã©ã€ãçæã®å Žåã®ã¢ãŒããã¯ãã£
- ã¹ã©ã€ãå®çŸ©æžãã©ã«ã
ãã- ã¡ã€ã³ã¹ã©ã€ãå®çŸ©æž
ãã- ãµãã¹ã©ã€ãå®çŸ©æž
- ã¹ã©ã€ãå
¥åæ
å ±ãã©ã«ã
ãã- ã¹ã©ã€ãæ§ææãã¡ã€ã«
ãã- ã¿ãŒã²ããæ
å ±ãã¡ã€ã«
- ã¹ã©ã€ããã³ãã¬ãŒããã©ã«ã
ãã- ã³ã³ãµã«é¢šãã³ãã¬ãŒã
ãã- ãã¶ã€ããŒé¢šãã³ãã¬ãŒã
ãã- ã¹ã©ã€ããã€ã¹ãã¬ã€ãã©ã€ã³
åºæ¬çã«ãŠãŒã¶ãŒãå€æŽããã®ã¯ãã¹ã©ã€ãå ¥åæ å ±ãã©ã«ãã®äžèº«
ã¹ã©ã€ãå ¥åæ å ±ãã©ã«ããšã¹ã©ã€ããã³ãã¬ãŒããã©ã«ãã®åæã®ä»æ¹ã¯ãã¹ã©ã€ãå®çŸ©æžã«èšè¿°ãããã
ã¹ã©ã€ãå ¥åæ å ±ãã©ã«ãã«ã¯ã以äžã®æ å ±ãå«ããã¡ã€ã«ãå ¥ããã
- ã¹ã©ã€ãã®æ§ææïŒã¢ãŠãã©ã€ã³ãšæ¬æ
- ã¿ãŒã²ããæ å ±ïŒå¯Ÿè±¡ãšããèŽè¡ã®æ å ±ïŒ
ã¹ã©ã€ããã³ãã¬ãŒããã©ã«ãã«ã¯ã以äžã®æ å ±ãå«ããã¡ã€ã«ãå ¥ããã
- ã¹ã©ã€ãã®ãã³ãã¬ãŒãïŒãã¶ã€ã³ãã¬ã€ã¢ãŠãïŒ
- ã¹ã©ã€ãã®ãã€ã¹ãã¬ã€ãã©ã€ã³ïŒè²äœ¿ãããã©ã³ããå³è¡šã®äœ¿ãæ¹ãªã©ïŒ
ãã®ã¢ãŒããã¯ãã£ã䜿ãããšã§ã¹ã©ã€ãè³æã®äœæãå¹çåããäžè²«æ§ã®ããé«å質ãªã¹ã©ã€ããäœæããããšãã§ãããŠãŒã¶ãŒã¯å ¥åæ å ±ãå€æŽããã ãã§å®çŸ©æžã«åŸã£ãŠã¹ã©ã€ããèªåçæãããããã«ãªãã
niwatoko ã¯ãèªç¶èšèªã§ããã°ã©ãã³ã°ãè¡ãããšãã§ããæ°ããããã°ã©ãã³ã°èšèªã§ãããã®ãããžã§ã¯ãã®ç®çã¯ãniwatoko ã®Pythonããã±ãŒãžãéçºãããŠãŒã¶ãŒãèªç¶èšèªã䜿ã£ãŠããã°ã©ã ãèšè¿°ããå®è¡ã§ããããã«ããããšã§ããããã±ãŒãžã«ã¯ãèªç¶èšèªåŠçã®ããã®èªèç³»AIãšãããã°ã©ã ã®åºåãçæããããã®çæAIïŒããã¹ãçæãç»åçæïŒãçµã¿èŸŒãŸããŸãã
niwatoko/
âââ niwatoko/
â âââ __init__.py
â âââ parser.py
â âââ interpreter.py
â âââ foundation_model/
â â âââ recognition/
â â â âââ stt/
â â â â âââ __init__.py
â â â â âââ openai.py
â â â â âââ claude.py
â â â âââ vision/
â â â â âââ __init__.py
â â â â âââ openai.py
â â â â âââ claude.py
â â âââ interpretation/
â â â âââ llm/
â â â â âââ __init__.py
â â â â âââ openai.py
â â â â âââ claude.py
â â â âââ code/
â â â â âââ __init__.py
â â â â âââ ...
â â âââ generation/
â â â âââ image/
â â â â âââ __init__.py
â â â â âââ openai.py
â â â â âââ claude.py
â â â âââ tts/
â â â â âââ __init__.py
â â â â âââ openai.py
â â â â âââ claude.py
â âââ utils/
â âââ __init__.py
â âââ ...
âââ tests/
â âââ __init__.py
â âââ test_parser.py
â âââ test_interpreter.py
â âââ foundation_model/
â â âââ recognition/
â â â âââ test_stt.py
â â â âââ test_vision.py
â â âââ interpretation/
â â â âââ test_llm.py
â â â âââ test_code.py
â â âââ generation/
â â âââ test_image.py
â â âââ test_tts.py
â âââ test_docs/
â â âââ test_doc1.md
â â âââ test_doc2.md
â â âââ test_doc3.md
â âââ ...
âââ docs/
â âââ conf.py
â âââ index.rst
â âââ ...
âââ README.md
âââ LICENSE
âââ setup.py
âââ requirements.txt
âââ Dockerfile
âââ docker-compose.yml
âââ .github/workflows/
âââ ci.yml
âââ cd.yml
niwatoko/
: ããã±ãŒãžã®ã¡ã€ã³ãã£ã¬ã¯ããªãããŒãµãŒãã€ã³ã¿ãŒããªã¿ãŒãAIã¢ãžã¥ãŒã«ãªã©ãå«ãŸããŸããtests/
: ãã¹ãã³ãŒããæ ŒçŽãããã£ã¬ã¯ããªãdocs/
: Sphinxã䜿çšããŠçæãããããã¥ã¡ã³ãã®ãœãŒã¹ãã¡ã€ã«ãæ ŒçŽãããã£ã¬ã¯ããªãREADME.md
: ããã±ãŒãžã®æŠèŠãã€ã³ã¹ããŒã«æ¹æ³ã䜿çšæ¹æ³ãªã©ã説æãããã¡ã€ã«ãLICENSE
: ããã±ãŒãžã®ã©ã€ã»ã³ã¹ãèšèŒãããã¡ã€ã«ãsetup.py
: ããã±ãŒãžã®ã¡ã¿ããŒã¿ãšã€ã³ã¹ããŒã«æ¹æ³ãå®çŸ©ãããã¡ã€ã«ãrequirements.txt
: ããã±ãŒãžãäŸåããå€éšã©ã€ãã©ãªãèšèŒãããã¡ã€ã«ãDockerfile
: Dockerã€ã¡ãŒãžã®ãã«ãæé ãèšè¿°ãããã¡ã€ã«ãdocker-compose.yml
: è€æ°ã®Dockerã³ã³ãããå®çŸ©ã»å®è¡ããããã®èšå®ãã¡ã€ã«ã.github/workflows/
: GitHub Actionsã«ããCI/CDã¯ãŒã¯ãããŒã®èšå®ãã¡ã€ã«ãæ ŒçŽãããã£ã¬ã¯ããªã
from setuptools import setup, find_packages
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name="niwatoko",
version="0.1.0",
description="A natural language programming language",
long_description=long_description,
long_description_content_type="text/markdown",
author="Your Name",
author_email="your.email@example.com",
url="https://github.com/yourusername/niwatoko",
packages=find_packages(),
install_requires=[
"numpy",
"nltk",
"tensorflow",
"torch",
"transformers",
"pillow",
],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)
name
: ããã±ãŒãžåãæå®ããŸããversion
: ããã±ãŒãžã®ããŒãžã§ã³ãæå®ããŸããdescription
: ããã±ãŒãžã®çã説æãèšèŒããŸããlong_description
: ããã±ãŒãžã®è©³çŽ°ãªèª¬æãèšèŒããŸããéåžžãREADME.mdã®å 容ãæå®ããŸããauthor
: äœè åãèšèŒããŸããauthor_email
: äœè ã®ã¡ãŒã«ã¢ãã¬ã¹ãèšèŒããŸããurl
: ããã±ãŒãžã®Webãµã€ãããªããžããªã®URLãæå®ããŸããpackages
: ããã±ãŒãžã«å«ããPythonã¢ãžã¥ãŒã«ãæå®ããŸããfind_packages()
ã䜿çšããŠèªåçã«æ€åºã§ããŸããinstall_requires
: ããã±ãŒãžãäŸåããå€éšã©ã€ãã©ãªãæå®ããŸãã
__version__ = "0.1.0"
from .parser import parse
from .interpreter import interpret
__init__.py
ã¯ãããã±ãŒãžã®åæååŠçãè¡ããã¡ã€ã«ã§ãã__version__
å€æ°ãå®çŸ©ããŠãããã±ãŒãžã®ããŒãžã§ã³ãæå®ããŸãã- ããã±ãŒãžã®å
¬éAPIãšãªãé¢æ°ãã¯ã©ã¹ã
__init__.py
ã§importããããšã§ããŠãŒã¶ãŒãããã±ãŒãžã䜿çšãããããªããŸãã
# niwatoko
niwatoko is a natural language programming language that allows users to write programs using natural language. It is implemented as a Python package and includes recognition AI for natural language processing and generative AI for program output (text and image generation).
## Installation
To install niwatoko, use pip:
pip install niwatoko
## Usage
Here's a simple example of how to use niwatoko:
```python
from niwatoko import parse, interpret
program = """
Create a function that takes two numbers as input and returns their sum.
"""
ast = parse(program)
result = interpret(ast)
print(result)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please read CONTRIBUTING.md for details on how to contribute to this project.
If you have any questions or need support, please open an issue on the GitHub repository.
- ããã±ãŒãžã®æŠèŠã説æããŸãã
- ã€ã³ã¹ããŒã«æ¹æ³ãèšèŒããŸãã
- 䜿çšæ¹æ³ãå
·äœçãªã³ãŒãäŸãšãšãã«èª¬æããŸãã
- ã©ã€ã»ã³ã¹ã«ã€ããŠèšåããLICENSEãã¡ã€ã«ãžã®ãªã³ã¯ã貌ããŸãã
- è²¢ç®æ¹æ³ã«ã€ããŠèª¬æããCONTRIBUTING.mdãã¡ã€ã«ãžã®ãªã³ã¯ã貌ããŸãã
- ãµããŒãæ¹æ³ãèšèŒããGitHubã®issueããŒãžãžã®ãªã³ã¯ã貌ããŸãã
## 6. LICENSEãã¡ã€ã«
- LICENSEãã¡ã€ã«ã¯ãããã±ãŒãžã®ã©ã€ã»ã³ã¹ãæèšããããã®ãã¡ã€ã«ã§ãã
- äž»èŠãªãªãŒãã³ãœãŒã¹ã©ã€ã»ã³ã¹ã«ã¯ä»¥äžã®ãããªãã®ããããŸãã
- MIT License: éåžžã«å¯å®¹ãªã©ã€ã»ã³ã¹ã§ãåçšå©çšãä¿®æ£ãé
åžãç§çå©çšãèªããããŠããŸãã
- Apache License 2.0: åçšå©çšãä¿®æ£ãé
åžãç¹èš±ã®äœ¿çšãèªããããŠããŸããã©ã€ã»ã³ã¹æ¡æã®æäŸãå¿
èŠã§ãã
- GNU General Public License (GPL): 匷ãã³ããŒã¬ããã©ã€ã»ã³ã¹ã§ã掟çç©ã¯GPLã§å
¬éããå¿
èŠããããŸãã
- BSD License: MITã©ã€ã»ã³ã¹ãšåæ§ã«å¯å®¹ãªã©ã€ã»ã³ã¹ã§ãããã©ã€ã»ã³ã¹æ¡æã®æäŸãå¿
èŠã§ãã
## 7. ããã±ãŒãžã®ããŒãžã§ã³ç®¡ç
- ã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã«åºã¥ããŠãMAJOR.MINOR.PATCH圢åŒã§ããŒãžã§ã³ãè¡šçŸããŸãã
- APIã®äºææ§ãæãªãããå€æŽãè¡ã£ãå Žåã¯ãMAJORããŒãžã§ã³ãäžããŸãã
- åŸæ¹äºææ§ãä¿ã¡ã€ã€æ©èœãè¿œå ããå Žåã¯ãMINORããŒãžã§ã³ãäžããŸãã
- ãã°ä¿®æ£ãªã©ã®å°ããªå€æŽã¯ãPATCHããŒãžã§ã³ãäžããŸãã
## 8. ãã¹ãã®æžãæ¹
- ãã¹ããã¡ã€ã«ã®åœåèŠåã¯ã`test_*.py`ãŸãã¯`*_test.py`ãšããŸãã
- ãã¹ãã¯ã©ã¹ã¯ã`unittest.TestCase`ãç¶æ¿ããŠå®çŸ©ããŸãã
- ãã¹ãã¡ãœããã®åœåèŠåã¯ã`test_`ã§å§ããŸãã
- `assert`ã¡ãœããã䜿çšããŠãæåŸ
ããçµæãšå®éã®çµæãæ¯èŒããŸãã
- `coverage.py`ãªã©ã®ããŒã«ã䜿çšããŠããã¹ãã®ã«ãã¬ããžã枬å®ããŸãã
- CLIã³ãã³ãã®å®è¡çµæããã£ããã£ããŠãæåŸ
ããåºåãšæ¯èŒãããã¹ããäœæããŸãã
- ç°ãªãã³ãã³ãã©ã€ã³ãªãã·ã§ã³ãæå®ããå Žåã®ãã¹ããäœæããŸãã
- ãšã©ãŒåŠçã®ãã¹ãïŒäžæ£ãªåŒæ°ãæž¡ããå Žåãªã©ïŒãäœæããŸãã
## 9. ããã¥ã¡ã³ãã®äœææ¹æ³
- Sphinxã䜿çšããŠããã¥ã¡ã³ããäœæããŸãã
- `sphinx-quickstart`ã³ãã³ããå®è¡ããŠãSphinxãããžã§ã¯ããäœæããŸãã
- reStructuredTextèšæ³ã䜿çšããŠãããã¥ã¡ã³ãã®ãœãŒã¹ãã¡ã€ã«ãäœæããŸãã
- `"""docstring"""`ã䜿çšããŠãã¢ãžã¥ãŒã«ãã¯ã©ã¹ãé¢æ°ã®ããã¥ã¡ã³ããèšè¿°ããŸãã
- `conf.py`ãã¡ã€ã«ã§Sphinxã®èšå®ãè¡ããŸãã
- `make html`ã³ãã³ããå®è¡ããŠãHTMLããã¥ã¡ã³ããçæããŸãã
## 10. DockeråãšCI/CDã®èšå®
- `Dockerfile`ãäœæããŠãã¢ããªã±ãŒã·ã§ã³ã®Dockerã€ã¡ãŒãžããã«ãããŸãã
- `docker-compose.yml`ãã¡ã€ã«ãäœæããŠãè€æ°ã®Dockerã³ã³ãããå®çŸ©ããå®è¡ããŸãã
- Dockerã€ã¡ãŒãžããã«ãããŠDocker Hubãªã©ã®ã³ã³ããã¬ãžã¹ããªã«ããã·ã¥ããŸãã
- GitHub Actionsã䜿çšããŠãCI/CDãã€ãã©ã€ã³ãèšå®ããŸãã
- `ci.yml`ãã¡ã€ã«ã§ãã¹ãããªã³ã¿ãŒãã³ãŒããã©ãŒããã¿ãŒãªã©ãå®è¡ããŸãã
- `cd.yml`ãã¡ã€ã«ã§Dockerã€ã¡ãŒãžã®ãã«ããšããã·ã¥ããããã€ã¡ã³ããèªååããŸãã
## 11. Webã¢ããªã±ãŒã·ã§ã³ã®UIèšå®
- Streamlitã䜿çšããŠWebã¢ããªã±ãŒã·ã§ã³ã®UIãèšå®ããŸãã
- `streamlit`ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããŸãã
- `app.py`ãã¡ã€ã«ãäœæããStreamlitã¢ããªã±ãŒã·ã§ã³ãå®çŸ©ããŸãã
- UIã³ã³ããŒãã³ããé
眮ããå
¥åãåãåããåŠççµæã衚瀺ããŸãã
- Gradioã䜿çšããŠWebã¢ããªã±ãŒã·ã§ã³ã®UIãèšå®ããŸãã
- `gradio`ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããŸãã
- `app.py`ãã¡ã€ã«ãäœæããGradioã¢ããªã±ãŒã·ã§ã³ãå®çŸ©ããŸãã
- UIã³ã³ããŒãã³ããé
眮ããå
¥åãåãåããåŠççµæã衚瀺ããŸãã
ããã±ãŒãžã®éçºã«ããã£ãŠã¯ãPEP 8ãªã©ã®Pythonã³ãŒãã£ã³ã°èŠçŽã«åŸããå¯èªæ§ãšä¿å®æ§ãéèŠããŸãããŸããé©åãªã¢ãžã¥ãŒã«åãšãªããžã§ã¯ãæåèšèšãè¡ããæ¡åŒµæ§ãšåå©çšæ§ãé«ããŸãã
ããã±ãŒãžã®å
¬éã«ã¯ãPyPIãå©çšããŸãã`setup.py`ãã¡ã€ã«ãé©åã«èšå®ãã`python setup.py sdist bdist_wheel`ã³ãã³ãã§ããã±ãŒãžãäœæããåŸã`twine upload dist/*`ã³ãã³ãã§PyPIã«ã¢ããããŒãããŸãã
CI/CDã®èšå®ã«ã¯ãGitHub Actionsã䜿çšããŸãã`.github/workflows/`ãã£ã¬ã¯ããªã«YAMLãã¡ã€ã«ãäœæãããã¹ãããªã³ã¿ãŒãã³ãŒããã©ãŒããã¿ãŒãDockerã€ã¡ãŒãžã®ãã«ããšããã·ã¥ããããã€ã¡ã³ããªã©ã®èªååã¿ã¹ã¯ãå®çŸ©ããŸãã
## ã¡ã¢
ã¯ããVercelã§Sphinxã®ããã¥ã¡ã³ããå
¬éããããšãã§ããŸããVercelã¯éçãµã€ããã¹ãã£ã³ã°ã«ç¹åãããµãŒãã¹ã§ãSphinxã®ãããªéçãµã€ããžã§ãã¬ãŒã¿ãŒãšã®çžæ§ãè¯ãã§ãã
Vercelã䜿ã£ãŠSphinxããã¥ã¡ã³ããå
¬éããæé ã¯ä»¥äžã®éãã§ãã
1. Sphinxãããžã§ã¯ãããã«ããã
```bash
sphinx-build -b html . _build/html && open _build/html/index.html
- Vercelçšã®èšå®ãã¡ã€ã«
vercel.json
ããããžã§ã¯ãã«ãŒãã«äœæãã
{
"version": 2,
"builds": [
{
"src": "*.html",
"use": "@vercel/static"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/_build/html/$1"
}
]
}
ãã®èšå®ã§ã¯ã_build/html
ãã£ã¬ã¯ããªä»¥äžã®éçãã¡ã€ã«ãå
¬éããããã«æå®ããŠããŸãã
- Vercelã«ãããžã§ã¯ãããããã€ãã
Vercelã®CLIãã€ã³ã¹ããŒã«ãããããžã§ã¯ãã«ãŒãã§ä»¥äžã®ã³ãã³ããå®è¡ããŸãã
$ vercel --prod
Vercelã®ã³ãã³ããèŠã€ãããªããšãããšã©ãŒãçºçããŠããŸããã Vercelã®CLIãã€ã³ã¹ããŒã«ãããŠããªãå¯èœæ§ããããŸãã
以äžã®æé ã§Vercel CLIãã€ã³ã¹ããŒã«ããŠãã ããã
- Node.jsãšnpmãã€ã³ã¹ããŒã«ãããŠããããšã確èªãã
Vercel CLIã¯Node.jsãšnpmã䜿çšããããããããããã€ã³ã¹ããŒã«ããŠããå¿ èŠããããŸããã¿ãŒããã«ã§ä»¥äžã®ã³ãã³ããå®è¡ããããŒãžã§ã³ã衚瀺ãããã°ã€ã³ã¹ããŒã«æžã¿ã§ãã
$ node -v
$ npm -v
- Vercel CLIãã€ã³ã¹ããŒã«ãã
npmã䜿ã£ãŠVercel CLIãã°ããŒãã«ã«ã€ã³ã¹ããŒã«ããŸãã
$ npm install -g vercel
- ã€ã³ã¹ããŒã«ã確èªãã
ã€ã³ã¹ããŒã«ãå®äºãããã以äžã®ã³ãã³ãã§ããŒãžã§ã³ã確èªããŸãã
$ vercel --version
ããŒãžã§ã³ã衚瀺ãããã°ãVercel CLIã®ã€ã³ã¹ããŒã«ã¯æåã§ãã
- Vercelã«ãã°ã€ã³ãã
Vercel CLIã䜿ã£ãŠãããã€ããã«ã¯ãVercelã¢ã«ãŠã³ãã«ãã°ã€ã³ããå¿ èŠããããŸãã以äžã®ã³ãã³ããå®è¡ããã¡ãŒã«ã¢ãã¬ã¹ãšãã¹ã¯ãŒããå ¥åããŠãã°ã€ã³ããŸãã
$ vercel login
以äžã®æé ã§Vercel CLIãã€ã³ã¹ããŒã«ãããã°ã€ã³ãã§ããããå床 vercel --prod
ã³ãã³ããå®è¡ããŠãããã€ããŠã¿ãŠãã ããã
Vercel CLIãæ£ããã€ã³ã¹ããŒã«ãããŠããã°ããããã€ãéå§ãããã¯ãã§ãã
ãããšããããžã§ã¯ããVercelã«ãããã€ãããå²ãåœãŠãããURLã衚瀺ãããŸãã
- èªåãããã€ã®èšå®ïŒãªãã·ã§ã³ïŒ
Vercelã¯GitHubãªã©ã®ãªããžããªãšé£æºããŠãpushããããèªåã§ãããã€ããããšãã§ããŸããVercelã®ããã·ã¥ããŒããããããžã§ã¯ãã®èšå®ãè¡ãããšã§ç°¡åã«èªåãããã€ãèšå®ã§ããŸãã
以äžã®æé ã«ãããVercelã§Sphinxããã¥ã¡ã³ããå ¬éããããšãã§ããŸãã Vercelã¯ç¡æãã©ã³ã§ãååãªæ©èœãæäŸããŠãããããæ軜ã«Sphinxããã¥ã¡ã³ãããã¹ãã£ã³ã°ããã®ã«é©ãããµãŒãã¹ãšèšããŸãã