typechat 0.0.4__tar.gz → 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {typechat-0.0.4 → typechat-0.1.0}/.gitignore +162 -162
- {typechat-0.0.4 → typechat-0.1.0}/LICENSE +21 -21
- typechat-0.1.0/PKG-INFO +253 -0
- typechat-0.1.0/README.md +221 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/README.md +129 -119
- {typechat-0.0.4 → typechat-0.1.0}/examples/calendar/README.md +38 -38
- {typechat-0.0.4 → typechat-0.1.0}/examples/calendar/demo.py +33 -33
- {typechat-0.0.4 → typechat-0.1.0}/examples/calendar/input.txt +10 -10
- {typechat-0.0.4 → typechat-0.1.0}/examples/calendar/schema.py +87 -87
- {typechat-0.0.4 → typechat-0.1.0}/examples/coffeeShop/README.md +44 -44
- {typechat-0.0.4 → typechat-0.1.0}/examples/coffeeShop/demo.py +34 -34
- {typechat-0.0.4 → typechat-0.1.0}/examples/coffeeShop/input.txt +47 -47
- {typechat-0.0.4 → typechat-0.1.0}/examples/coffeeShop/input2.txt +8 -8
- {typechat-0.0.4 → typechat-0.1.0}/examples/coffeeShop/schema.py +139 -139
- typechat-0.1.0/examples/drawing/__init__.py +1 -0
- typechat-0.1.0/examples/drawing/demo.py +60 -0
- typechat-0.1.0/examples/drawing/input.txt +5 -0
- typechat-0.1.0/examples/drawing/render.py +107 -0
- typechat-0.1.0/examples/drawing/schema.py +83 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/healthData/README.md +30 -30
- {typechat-0.0.4 → typechat-0.1.0}/examples/healthData/demo.py +51 -51
- {typechat-0.0.4 → typechat-0.1.0}/examples/healthData/input.txt +63 -63
- {typechat-0.0.4 → typechat-0.1.0}/examples/healthData/schema.py +62 -62
- {typechat-0.0.4 → typechat-0.1.0}/examples/healthData/translator.py +67 -67
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/README.md +35 -35
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/demo.py +57 -57
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/program.py +158 -158
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/schema.py +15 -15
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/schemaV2.py +50 -50
- {typechat-0.0.4 → typechat-0.1.0}/examples/multiSchema/README.md +23 -23
- {typechat-0.0.4 → typechat-0.1.0}/examples/multiSchema/input.txt +8 -8
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/client.py +379 -379
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/demo.py +41 -41
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/schema.py +302 -302
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/spotipyWrapper.py +112 -112
- {typechat-0.0.4 → typechat-0.1.0}/examples/restaurant/README.md +62 -62
- {typechat-0.0.4 → typechat-0.1.0}/examples/restaurant/demo.py +32 -32
- {typechat-0.0.4 → typechat-0.1.0}/examples/restaurant/input.txt +14 -14
- {typechat-0.0.4 → typechat-0.1.0}/examples/restaurant/schema.py +49 -49
- typechat-0.1.0/examples/sentiment/README.md +39 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/sentiment/demo.py +30 -27
- {typechat-0.0.4 → typechat-0.1.0}/examples/sentiment/input.txt +3 -3
- typechat-0.1.0/examples/sentiment/non_interactive.py +37 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/sentiment/schema.py +10 -10
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/calendar.ipynb +129 -129
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/coffeeShop.ipynb +115 -113
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/healthData.ipynb +145 -145
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/math.ipynb +137 -137
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/music.ipynb +139 -139
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/restaurant.ipynb +117 -117
- {typechat-0.0.4 → typechat-0.1.0}/notebooks/sentiment.ipynb +103 -103
- {typechat-0.0.4 → typechat-0.1.0}/package-lock.json +49 -46
- {typechat-0.0.4 → typechat-0.1.0}/package.json +17 -14
- {typechat-0.0.4 → typechat-0.1.0}/pyproject.toml +195 -194
- {typechat-0.0.4 → typechat-0.1.0}/pyrightconfig.json +16 -16
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/__about__.py +4 -4
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/__init__.py +45 -25
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/interactive.py +37 -37
- typechat-0.1.0/src/typechat/_internal/model.py +437 -0
- typechat-0.1.0/src/typechat/_internal/result.py +38 -0
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/translator.py +149 -125
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/ts_conversion/__init__.py +35 -35
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/ts_conversion/python_type_to_ts_nodes.py +521 -447
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/ts_conversion/ts_node_to_string.py +96 -96
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/ts_conversion/ts_type_nodes.py +78 -78
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/validator.py +67 -67
- {typechat-0.0.4 → typechat-0.1.0}/tests/__init__.py +3 -3
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.11_snapshots__/test_conflicting_names_1/test_conflicting_names_1.schema.d.ts +6 -6
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.11_snapshots__/test_hello_world/test_generic_alias1.schema.d.ts +35 -35
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.12+_snapshots__/test_generic_alias_3/test_generic_alias3.schema.d.ts +13 -13
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.12+_snapshots__/test_generic_alias_4/test_generic_alias4.schema.d.ts +17 -17
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.12+_snapshots__/test_type_alias_syntax/test_type_alias_union1.schema.d.ts +3 -3
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.12_snapshots__/test_conflicting_names_1/test_conflicting_names_1.schema.d.ts +15 -15
- {typechat-0.0.4 → typechat-0.1.0}/tests/__py3.12_snapshots__/test_hello_world/test_generic_alias1.schema.d.ts +35 -35
- typechat-0.1.0/tests/__py3.13_snapshots__/test_conflicting_names_1/test_conflicting_names_1.schema.d.ts +15 -0
- typechat-0.1.0/tests/__py3.13_snapshots__/test_hello_world/test_generic_alias1.schema.d.ts +35 -0
- typechat-0.1.0/tests/__py3.14_snapshots__/test_conflicting_names_1/test_conflicting_names_1.schema.d.ts +15 -0
- typechat-0.1.0/tests/__py3.14_snapshots__/test_hello_world/test_generic_alias1.schema.d.ts +35 -0
- typechat-0.1.0/tests/__snapshots__/test_abstract_collections/test_abstract_collections.schema.d.ts +15 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_coffeeshop/test_coffeeshop_schema.schema.d.ts +96 -96
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_dataclasses/test_data_classes.schema.d.ts +17 -17
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_generic_alias_1/test_generic_alias1.schema.d.ts +13 -13
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_generic_alias_2/test_generic_alias2.schema.d.ts +17 -17
- typechat-0.1.0/tests/__snapshots__/test_inline_comments/test_dataclass_inline_comments.schema.d.ts +9 -0
- typechat-0.1.0/tests/__snapshots__/test_inline_comments/test_doc_takes_priority_over_inline.schema.d.ts +9 -0
- typechat-0.1.0/tests/__snapshots__/test_inline_comments/test_typeddict_inline_comments.schema.d.ts +8 -0
- typechat-0.1.0/tests/__snapshots__/test_newtype/test_newtype_1.schema.d.ts +11 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_translator.ambr +419 -386
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_tuple_errors_1/test_tuples_2.schema.d.ts +23 -23
- {typechat-0.0.4 → typechat-0.1.0}/tests/__snapshots__/test_tuples_1/test_tuples_1.schema.d.ts +18 -14
- {typechat-0.0.4 → typechat-0.1.0}/tests/coffeeshop_deprecated.py +155 -155
- typechat-0.1.0/tests/test_abstract_collections.py +27 -0
- typechat-0.1.0/tests/test_client_model.py +183 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_coffeeshop.py +145 -145
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_conflicting_names_1.py +25 -25
- typechat-0.1.0/tests/test_create_language_model.py +126 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_dataclasses.py +30 -30
- typechat-0.1.0/tests/test_failure.py +243 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_generic_alias_1.py +22 -22
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_generic_alias_2.py +26 -26
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_generic_alias_3.py +20 -20
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_generic_alias_4.py +23 -23
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_hello_world.py +40 -40
- typechat-0.1.0/tests/test_inline_comments.py +364 -0
- typechat-0.1.0/tests/test_interactive.py +79 -0
- typechat-0.1.0/tests/test_keyless_model.py +294 -0
- typechat-0.1.0/tests/test_model.py +83 -0
- typechat-0.1.0/tests/test_multimodal_model.py +513 -0
- typechat-0.1.0/tests/test_newtype.py +53 -0
- typechat-0.1.0/tests/test_prompt_types.py +104 -0
- typechat-0.1.0/tests/test_schema_documentation.py +48 -0
- typechat-0.1.0/tests/test_sentiment_non_interactive.py +147 -0
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_translator.py +134 -95
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_tuple_errors_1.py +22 -22
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_tuples_1.py +31 -27
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_type_alias_syntax.py +7 -7
- {typechat-0.0.4 → typechat-0.1.0}/tests/test_validator.py +15 -15
- {typechat-0.0.4 → typechat-0.1.0}/tests/utilities.py +60 -60
- typechat-0.0.4/PKG-INFO +0 -91
- typechat-0.0.4/README.md +0 -60
- typechat-0.0.4/examples/sentiment/README.md +0 -21
- typechat-0.0.4/src/typechat/_internal/model.py +0 -184
- typechat-0.0.4/src/typechat/_internal/result.py +0 -21
- {typechat-0.0.4 → typechat-0.1.0}/examples/math/input.txt +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/multiSchema/agents.py +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/multiSchema/demo.py +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/multiSchema/router.py +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/README.md +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/examples/music/input.txt +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/_internal/__init__.py +0 -0
- {typechat-0.0.4 → typechat-0.1.0}/src/typechat/py.typed +0 -0
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
# Byte-compiled / optimized / DLL files
|
|
2
|
-
__pycache__/
|
|
3
|
-
*.py[cod]
|
|
4
|
-
*$py.class
|
|
5
|
-
|
|
6
|
-
# C extensions
|
|
7
|
-
*.so
|
|
8
|
-
|
|
9
|
-
# Distribution / packaging
|
|
10
|
-
.Python
|
|
11
|
-
build/
|
|
12
|
-
develop-eggs/
|
|
13
|
-
dist/
|
|
14
|
-
downloads/
|
|
15
|
-
eggs/
|
|
16
|
-
.eggs/
|
|
17
|
-
lib/
|
|
18
|
-
lib64/
|
|
19
|
-
parts/
|
|
20
|
-
sdist/
|
|
21
|
-
var/
|
|
22
|
-
wheels/
|
|
23
|
-
share/python-wheels/
|
|
24
|
-
*.egg-info/
|
|
25
|
-
.installed.cfg
|
|
26
|
-
*.egg
|
|
27
|
-
MANIFEST
|
|
28
|
-
|
|
29
|
-
# PyInstaller
|
|
30
|
-
# Usually these files are written by a python script from a template
|
|
31
|
-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
-
*.manifest
|
|
33
|
-
*.spec
|
|
34
|
-
|
|
35
|
-
# Installer logs
|
|
36
|
-
pip-log.txt
|
|
37
|
-
pip-delete-this-directory.txt
|
|
38
|
-
|
|
39
|
-
# Unit test / coverage reports
|
|
40
|
-
htmlcov/
|
|
41
|
-
.tox/
|
|
42
|
-
.nox/
|
|
43
|
-
.coverage
|
|
44
|
-
.coverage.*
|
|
45
|
-
.cache
|
|
46
|
-
nosetests.xml
|
|
47
|
-
coverage.xml
|
|
48
|
-
*.cover
|
|
49
|
-
*.py,cover
|
|
50
|
-
.hypothesis/
|
|
51
|
-
.pytest_cache/
|
|
52
|
-
cover/
|
|
53
|
-
|
|
54
|
-
# Translations
|
|
55
|
-
*.mo
|
|
56
|
-
*.pot
|
|
57
|
-
|
|
58
|
-
# Django stuff:
|
|
59
|
-
*.log
|
|
60
|
-
local_settings.py
|
|
61
|
-
db.sqlite3
|
|
62
|
-
db.sqlite3-journal
|
|
63
|
-
|
|
64
|
-
# Flask stuff:
|
|
65
|
-
instance/
|
|
66
|
-
.webassets-cache
|
|
67
|
-
|
|
68
|
-
# Scrapy stuff:
|
|
69
|
-
.scrapy
|
|
70
|
-
|
|
71
|
-
# Sphinx documentation
|
|
72
|
-
docs/_build/
|
|
73
|
-
|
|
74
|
-
# PyBuilder
|
|
75
|
-
.pybuilder/
|
|
76
|
-
target/
|
|
77
|
-
|
|
78
|
-
# Jupyter Notebook
|
|
79
|
-
.ipynb_checkpoints
|
|
80
|
-
|
|
81
|
-
# IPython
|
|
82
|
-
profile_default/
|
|
83
|
-
ipython_config.py
|
|
84
|
-
|
|
85
|
-
# pyenv
|
|
86
|
-
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
-
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
-
# .python-version
|
|
89
|
-
|
|
90
|
-
# pipenv
|
|
91
|
-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
-
# install all needed dependencies.
|
|
95
|
-
#Pipfile.lock
|
|
96
|
-
|
|
97
|
-
# poetry
|
|
98
|
-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
-
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
-
# commonly ignored for libraries.
|
|
101
|
-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
-
#poetry.lock
|
|
103
|
-
|
|
104
|
-
# pdm
|
|
105
|
-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
-
#pdm.lock
|
|
107
|
-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
-
# in version control.
|
|
109
|
-
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
-
.pdm.toml
|
|
111
|
-
|
|
112
|
-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
-
__pypackages__/
|
|
114
|
-
|
|
115
|
-
# Celery stuff
|
|
116
|
-
celerybeat-schedule
|
|
117
|
-
celerybeat.pid
|
|
118
|
-
|
|
119
|
-
# SageMath parsed files
|
|
120
|
-
*.sage.py
|
|
121
|
-
|
|
122
|
-
# Environments
|
|
123
|
-
.env
|
|
124
|
-
.venv
|
|
125
|
-
env/
|
|
126
|
-
venv/
|
|
127
|
-
ENV/
|
|
128
|
-
env.bak/
|
|
129
|
-
venv.bak/
|
|
130
|
-
|
|
131
|
-
# Spyder project settings
|
|
132
|
-
.spyderproject
|
|
133
|
-
.spyproject
|
|
134
|
-
|
|
135
|
-
# Rope project settings
|
|
136
|
-
.ropeproject
|
|
137
|
-
|
|
138
|
-
# mkdocs documentation
|
|
139
|
-
/site
|
|
140
|
-
|
|
141
|
-
# mypy
|
|
142
|
-
.mypy_cache/
|
|
143
|
-
.dmypy.json
|
|
144
|
-
dmypy.json
|
|
145
|
-
|
|
146
|
-
# Pyre type checker
|
|
147
|
-
.pyre/
|
|
148
|
-
|
|
149
|
-
# pytype static type analyzer
|
|
150
|
-
.pytype/
|
|
151
|
-
|
|
152
|
-
# Cython debug symbols
|
|
153
|
-
cython_debug/
|
|
154
|
-
|
|
155
|
-
# PyCharm
|
|
156
|
-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
-
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
-
#.idea/
|
|
161
|
-
|
|
162
|
-
node_modules
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
|
|
162
|
+
node_modules
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
typechat-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: typechat
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TypeChat is a library that makes it easy to build natural language interfaces using types.
|
|
5
|
+
Project-URL: Documentation, https://github.com/microsoft/TypeChat#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/microsoft/TypeChat/issues
|
|
7
|
+
Project-URL: Source, https://github.com/microsoft/TypeChat
|
|
8
|
+
Author: Microsoft Corporation
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: httpx>=0.27.0
|
|
20
|
+
Requires-Dist: pydantic-core>=2.16.3
|
|
21
|
+
Requires-Dist: pydantic>=2.5.2
|
|
22
|
+
Requires-Dist: typing-extensions>=4.10.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: coverage[toml]>=6.5; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest<9,>=8.0.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: syrupy>=5.0.0; extra == 'dev'
|
|
28
|
+
Provides-Extra: examples
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == 'examples'
|
|
30
|
+
Requires-Dist: spotipy; extra == 'examples'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# TypeChat
|
|
34
|
+
|
|
35
|
+
TypeChat is a library that makes it easy to build natural language interfaces using types.
|
|
36
|
+
|
|
37
|
+
Building natural language interfaces has traditionally been difficult.
|
|
38
|
+
These apps often relied on complex decision trees to determine intent and collect the required inputs to take action.
|
|
39
|
+
Large language models (LLMs) have made this easier by enabling us to take natural language input from a user and match to intent.
|
|
40
|
+
This has introduced its own challenges, including the need to constrain the model's reply for safety,
|
|
41
|
+
structure responses from the model for further processing, and ensuring that the reply from the model is valid.
|
|
42
|
+
Prompt engineering aims to solve these problems, but comes with a steep learning curve and increased fragility as the prompt increases in size.
|
|
43
|
+
|
|
44
|
+
TypeChat replaces _prompt engineering_ with _schema engineering_.
|
|
45
|
+
|
|
46
|
+
Simply define types that represent the intents supported in your natural language application.
|
|
47
|
+
That could be as simple as an interface for categorizing sentiment or more complex examples like types for a shopping cart or music application.
|
|
48
|
+
For example, to add additional intents to a schema, a developer can add additional types into a discriminated union.
|
|
49
|
+
To make schemas hierarchical, a developer can use a "meta-schema" to choose one or more sub-schemas based on user input.
|
|
50
|
+
|
|
51
|
+
After defining your types, TypeChat takes care of the rest by:
|
|
52
|
+
|
|
53
|
+
1. Constructing a prompt to the LLM using types.
|
|
54
|
+
2. Validating the LLM response conforms to the schema. If the validation fails, repair the non-conforming output through further language model interaction.
|
|
55
|
+
3. Summarizing succinctly (without use of a LLM) the instance and confirm that it aligns with user intent.
|
|
56
|
+
|
|
57
|
+
Types are all you need!
|
|
58
|
+
|
|
59
|
+
## Getting Started
|
|
60
|
+
|
|
61
|
+
Install TypeChat:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
pip install typechat
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To use TypeChat in an existing backend without an interactive chat loop, follow the
|
|
68
|
+
[non-interactive Python quickstart](../site/src/docs/python/non-interactive.md).
|
|
69
|
+
It includes a [standalone sentiment example](./examples/sentiment/non_interactive.py) and an async function you can call from application code.
|
|
70
|
+
|
|
71
|
+
You can also develop TypeChat from source, which needs [Python >=3.11](https://www.python.org/downloads/),
|
|
72
|
+
[hatch](https://hatch.pypa.io/1.6/install/), and [Node.js >=24.22.1](https://nodejs.org/en/download):
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
git clone https://github.com/microsoft/TypeChat
|
|
76
|
+
cd TypeChat/python
|
|
77
|
+
hatch shell
|
|
78
|
+
npm ci
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
To see TypeChat in action, we recommend exploring the
|
|
82
|
+
[TypeChat example projects](https://github.com/microsoft/TypeChat/tree/main/python/examples).
|
|
83
|
+
You can try them on your local machine or in a GitHub Codespace.
|
|
84
|
+
|
|
85
|
+
To learn more about TypeChat, visit the
|
|
86
|
+
[documentation](https://microsoft.github.io/TypeChat/docs/python/basic-usage/)
|
|
87
|
+
which includes more information on TypeChat and how to get started.
|
|
88
|
+
|
|
89
|
+
## Reusing model authentication
|
|
90
|
+
|
|
91
|
+
For keyless Azure OpenAI requests, pass a synchronous or asynchronous bearer-token
|
|
92
|
+
provider to `create_azure_openai_language_model` with `api_key=None`. If your app
|
|
93
|
+
already has a configured asynchronous OpenAI or Azure OpenAI client, use
|
|
94
|
+
`create_openai_language_model_from_client` instead.
|
|
95
|
+
|
|
96
|
+
Both paths reuse authentication supplied by your application without adding SDK
|
|
97
|
+
dependencies to TypeChat or requiring TypeChat-specific environment-variable names.
|
|
98
|
+
Existing API-key and environment-based calls are unchanged. See the
|
|
99
|
+
[token-provider example](../site/src/docs/python/basic-usage.md#using-a-bearer-token-provider)
|
|
100
|
+
and [configured-client example](../site/src/docs/python/basic-usage.md#reusing-an-already-configured-client)
|
|
101
|
+
for ownership, retry, and error behavior.
|
|
102
|
+
|
|
103
|
+
All four model factories accept a keyword-only `temperature` option. It defaults
|
|
104
|
+
to `0.0`, preserving existing behavior. Pass `temperature=None` to omit the
|
|
105
|
+
parameter entirely and use the configured client's or service's default, for
|
|
106
|
+
example with reasoning models that reject explicit sampling parameters. This
|
|
107
|
+
does not disable reasoning, change authentication, or select a different API.
|
|
108
|
+
|
|
109
|
+
## Text and image prompts
|
|
110
|
+
|
|
111
|
+
Both built-in Chat Completions models and the configured-client adapter accept
|
|
112
|
+
typed text/image parts in `PromptSection.content`. Existing whole-string prompts
|
|
113
|
+
remain supported without migration.
|
|
114
|
+
|
|
115
|
+
The following example demonstrates both `model.complete` and translator context;
|
|
116
|
+
applications can use either call independently. Supply your own hosted image URL
|
|
117
|
+
and already-base64-encoded image data:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from typing_extensions import TypedDict
|
|
121
|
+
|
|
122
|
+
from typechat import (
|
|
123
|
+
PromptSection,
|
|
124
|
+
Result,
|
|
125
|
+
TypeChatJsonTranslator,
|
|
126
|
+
TypeChatLanguageModel,
|
|
127
|
+
TypeChatValidator,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class ImageDescription(TypedDict):
|
|
132
|
+
description: str
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
async def inspect_images(
|
|
136
|
+
model: TypeChatLanguageModel, image_base64: str
|
|
137
|
+
) -> tuple[Result[str], Result[ImageDescription]]:
|
|
138
|
+
context: list[PromptSection] = [
|
|
139
|
+
{"role": "user", "content": [
|
|
140
|
+
{"type": "text", "text": "Use these images as context."},
|
|
141
|
+
{"type": "image_url", "image_url": {"url": "https://example.com/photo.png"}},
|
|
142
|
+
{"type": "image_url", "image_url": {
|
|
143
|
+
"url": f"data:image/png;base64,{image_base64}",
|
|
144
|
+
"detail": "low",
|
|
145
|
+
}},
|
|
146
|
+
]},
|
|
147
|
+
]
|
|
148
|
+
text = await model.complete(context)
|
|
149
|
+
translator = TypeChatJsonTranslator(model, TypeChatValidator(ImageDescription), ImageDescription)
|
|
150
|
+
data = await translator.translate("Describe the images.", prompt_preamble=context)
|
|
151
|
+
return text, data
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The public dictionary types are `TextPromptContent` (`{"type": "text", "text": str}`),
|
|
155
|
+
`ImagePromptContent` (`{"type": "image_url", "image_url": ImageUrl}`), and `ImageUrl`
|
|
156
|
+
with a required nonempty `url: str` and optional `detail: "auto" | "low" | "high"`.
|
|
157
|
+
`PromptContent` is a string or an ordered list of these tagged parts, not a list of
|
|
158
|
+
bare strings. Text works in system, user, and assistant messages; images are
|
|
159
|
+
supported only in user messages. Malformed input produces a content-free `Failure`
|
|
160
|
+
locating the section or part before authentication or dispatch.
|
|
161
|
+
|
|
162
|
+
`translate` still takes a string request. Its preamble stays before the generated
|
|
163
|
+
schema/request message, and image context is preserved during validation and repair.
|
|
164
|
+
Successful model completions remain text-only. Authentication, HTTP controls, and
|
|
165
|
+
configured-client ownership remain unchanged.
|
|
166
|
+
|
|
167
|
+
TypeChat only forwards image references: it does not fetch, decode, resize, or
|
|
168
|
+
validate image contents. Supported formats (such as PNG, JPEG, or WebP), URL
|
|
169
|
+
accessibility, image counts, detail support, and size/resolution limits depend on
|
|
170
|
+
your provider and model. No image-processing or provider SDK dependency is added.
|
|
171
|
+
See [text and image usage](../site/src/docs/python/basic-usage.md#text-and-image-prompts)
|
|
172
|
+
for the complete prompt type definitions and limitations.
|
|
173
|
+
|
|
174
|
+
## Documenting schema fields
|
|
175
|
+
|
|
176
|
+
Trailing Python comments on directly declared `TypedDict` and dataclass fields become
|
|
177
|
+
documentation in the generated TypeScript schema:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from typing import Annotated
|
|
181
|
+
from typing_extensions import Doc, TypedDict
|
|
182
|
+
|
|
183
|
+
class Point(TypedDict):
|
|
184
|
+
x: int # X-coordinate
|
|
185
|
+
y: Annotated[int, Doc("Y-coordinate")] # Explicit documentation takes precedence.
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Explicit `Annotated` documentation, supplied through `Doc` or a string, takes precedence
|
|
189
|
+
over an inline comment, including when that explicit documentation is empty.
|
|
190
|
+
Comments are recognized using Python's tokenizer, so `#` inside a string literal is not
|
|
191
|
+
treated as documentation. For multiline field declarations, put the comment on the final line.
|
|
192
|
+
`# type: ignore` directives, including those with bracketed error codes, are not treated
|
|
193
|
+
as field documentation.
|
|
194
|
+
|
|
195
|
+
Source inspection is read-only and supports nested class definitions with multiline strings.
|
|
196
|
+
If source is unavailable, such as for dynamically created types or deployments without source files,
|
|
197
|
+
conversion continues using the type annotations
|
|
198
|
+
and explicit documentation without inline comments. If available source cannot be parsed,
|
|
199
|
+
the problem is reported in `TypeScriptSchemaConversionResult.errors` rather than silently
|
|
200
|
+
discarding the comments.
|
|
201
|
+
|
|
202
|
+
## Accessing failed output
|
|
203
|
+
|
|
204
|
+
`Failure` retains its existing `message` and can also carry an unvalidated `value: object` and
|
|
205
|
+
`response_text: str | None`. Validators return the rejected input in `value`; translators also retain
|
|
206
|
+
the original model text, including when it is not valid JSON:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from typechat import Failure
|
|
210
|
+
|
|
211
|
+
result = await translator.translate(request)
|
|
212
|
+
if isinstance(result, Failure):
|
|
213
|
+
if result.has_value:
|
|
214
|
+
rejected = result.value
|
|
215
|
+
# Validate or repair this value before treating it as the target type.
|
|
216
|
+
original_response = result.response_text
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Check `has_value` before using `value`. It distinguishes unavailable data from a rejected `None`,
|
|
220
|
+
`False`, `0`, or empty string. An unavailable value is represented by an internal missing-value marker,
|
|
221
|
+
not `None`. Custom validators can supply their own payloads using
|
|
222
|
+
`Failure(message, value=rejected, response_text=text)`, and the translator preserves those payloads.
|
|
223
|
+
`Failure(message)` remains valid, and payload fields are omitted from its representation.
|
|
224
|
+
Use `isinstance` with `Success` or `Failure` to distinguish outcomes, not the presence of `value`.
|
|
225
|
+
|
|
226
|
+
On final failure, automatic repair retains the latest rejected candidate and available response text,
|
|
227
|
+
not a full attempt history. If a repair response cannot be parsed, `value` can come from an earlier
|
|
228
|
+
attempt than `response_text`. An initial network failure has no candidate value. Successful results,
|
|
229
|
+
error messages, and repair limits are unchanged, including Python's existing repair of malformed JSON.
|
|
230
|
+
|
|
231
|
+
Rejected values and response text may contain sensitive output. Do not log or serialize them blindly.
|
|
232
|
+
|
|
233
|
+
## Contributing
|
|
234
|
+
|
|
235
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
236
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
237
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
238
|
+
|
|
239
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
240
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
241
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
242
|
+
|
|
243
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
244
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
245
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
246
|
+
|
|
247
|
+
## Trademarks
|
|
248
|
+
|
|
249
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
250
|
+
trademarks or logos is subject to and must follow
|
|
251
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
252
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
253
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|