thinkthinksyn 0.0.1__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.
Files changed (62) hide show
  1. thinkthinksyn-0.0.1/PKG-INFO +47 -0
  2. thinkthinksyn-0.0.1/README.md +17 -0
  3. thinkthinksyn-0.0.1/license +7 -0
  4. thinkthinksyn-0.0.1/pyproject.toml +43 -0
  5. thinkthinksyn-0.0.1/setup.cfg +4 -0
  6. thinkthinksyn-0.0.1/test/test_utils.py +134 -0
  7. thinkthinksyn-0.0.1/thinkthinksyn/__init__.py +5 -0
  8. thinkthinksyn-0.0.1/thinkthinksyn/client.py +584 -0
  9. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/__init__.py +9 -0
  10. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/async_helpers.py +424 -0
  11. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/file_lock.py +467 -0
  12. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/helper_funcs.py +359 -0
  13. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/nested_loop.py +380 -0
  14. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/concurrent_utils/shared_obj.py +408 -0
  15. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/__init__.py +7 -0
  16. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/advanced_builtins/__init__.py +5 -0
  17. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/advanced_builtins/_utils.py +270 -0
  18. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/advanced_builtins/dict.py +310 -0
  19. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/advanced_builtins/queue.py +248 -0
  20. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/advanced_builtins/set.py +109 -0
  21. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/condition/__init__.py +3 -0
  22. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/condition/_utils.py +280 -0
  23. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/condition/condition.py +1190 -0
  24. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/condition/parser.py +703 -0
  25. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/__init__.py +9 -0
  26. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/_utils.py +105 -0
  27. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/audio.py +456 -0
  28. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/image.py +430 -0
  29. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/loader.py +526 -0
  30. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/pdf.py +19 -0
  31. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/file_models/video.py +423 -0
  32. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/__init__.py +11 -0
  33. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/box2d.py +119 -0
  34. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/line2d.py +248 -0
  35. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/point2d.py +156 -0
  36. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/polygon2d.py +57 -0
  37. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/rect2d.py +120 -0
  38. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/data_structs/geometry/vec2d.py +34 -0
  39. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/decorators/__init__.py +3 -0
  40. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/decorators/cache.py +460 -0
  41. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/decorators/classproperty.py +269 -0
  42. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/storage/__init__.py +3 -0
  43. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/storage/local_cache.py +1 -0
  44. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/text_utils/__init__.py +3 -0
  45. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/text_utils/formatter.py +653 -0
  46. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/text_utils/zh_num_convertor.py +390 -0
  47. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/type_utils/__init__.py +7 -0
  48. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/type_utils/checking.py +856 -0
  49. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/type_utils/convertors.py +632 -0
  50. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/type_utils/func_helpers.py +378 -0
  51. thinkthinksyn-0.0.1/thinkthinksyn/common_utils/type_utils/type_helpers.py +1485 -0
  52. thinkthinksyn-0.0.1/thinkthinksyn/data_types/__init__.py +9 -0
  53. thinkthinksyn-0.0.1/thinkthinksyn/data_types/base.py +207 -0
  54. thinkthinksyn-0.0.1/thinkthinksyn/data_types/completion.py +497 -0
  55. thinkthinksyn-0.0.1/thinkthinksyn/data_types/embedding.py +54 -0
  56. thinkthinksyn-0.0.1/thinkthinksyn/data_types/llm_tools.py +302 -0
  57. thinkthinksyn-0.0.1/thinkthinksyn/data_types/models.py +308 -0
  58. thinkthinksyn-0.0.1/thinkthinksyn.egg-info/PKG-INFO +47 -0
  59. thinkthinksyn-0.0.1/thinkthinksyn.egg-info/SOURCES.txt +60 -0
  60. thinkthinksyn-0.0.1/thinkthinksyn.egg-info/dependency_links.txt +1 -0
  61. thinkthinksyn-0.0.1/thinkthinksyn.egg-info/requires.txt +18 -0
  62. thinkthinksyn-0.0.1/thinkthinksyn.egg-info/top_level.txt +1 -0
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: thinkthinksyn
3
+ Version: 0.0.1
4
+ Author-email: ThinkThinkSyn <contact@thinkthinksyn.com>
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/ThinkThinkSyn/thinkthinksyn
7
+ Project-URL: Issues, https://github.com/ThinkThinkSyn/thinkthinksyn/issues
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: license
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pydantic
13
+ Requires-Dist: sympy
14
+ Requires-Dist: aiossechat
15
+ Requires-Dist: colorlog
16
+ Requires-Dist: attrs
17
+ Requires-Dist: typeguard
18
+ Requires-Dist: typing-extensions>=4.1.0
19
+ Requires-Dist: pillow
20
+ Requires-Dist: psutil
21
+ Requires-Dist: aioftp
22
+ Requires-Dist: aiohttp
23
+ Requires-Dist: pydub
24
+ Requires-Dist: ffmpeg-downloader
25
+ Requires-Dist: moviepy
26
+ Requires-Dist: noisereduce
27
+ Requires-Dist: json-repair
28
+ Requires-Dist: audioop-lts
29
+ Dynamic: license-file
30
+
31
+ #### Client for accessing ThinkThinkSyn AI API Service.
32
+
33
+ Required Python >= 3.11
34
+
35
+ Example:
36
+ ```python
37
+ import asyncio
38
+
39
+ from thinkthinksyn import ThinkThinkSyn
40
+ tts = ThinkThinkSyn(apikey=os.getenv('TTS_APIKEY', ''))
41
+
42
+ async def test():
43
+ return (await tts.completion(prompt='1+1? tell me ans directly without words.'))['text'].strip()
44
+
45
+ if __name__ == "__main__":
46
+ asyncio.run(test())
47
+ ```
@@ -0,0 +1,17 @@
1
+ #### Client for accessing ThinkThinkSyn AI API Service.
2
+
3
+ Required Python >= 3.11
4
+
5
+ Example:
6
+ ```python
7
+ import asyncio
8
+
9
+ from thinkthinksyn import ThinkThinkSyn
10
+ tts = ThinkThinkSyn(apikey=os.getenv('TTS_APIKEY', ''))
11
+
12
+ async def test():
13
+ return (await tts.completion(prompt='1+1? tell me ans directly without words.'))['text'].strip()
14
+
15
+ if __name__ == "__main__":
16
+ asyncio.run(test())
17
+ ```
@@ -0,0 +1,7 @@
1
+ Copyright 2025 ThinkThinkSyn Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ version = "0.0.1"
7
+ name = "thinkthinksyn"
8
+ dependencies = [
9
+ "numpy",
10
+ "pydantic",
11
+ "sympy",
12
+ "aiossechat",
13
+ "colorlog",
14
+ "attrs",
15
+ "typeguard",
16
+ "typing-extensions>=4.1.0",
17
+ "pillow",
18
+ "psutil",
19
+ "aioftp",
20
+ "aiohttp",
21
+ "pydub",
22
+ "ffmpeg-downloader",
23
+ "moviepy",
24
+ "noisereduce",
25
+ "json-repair",
26
+ "audioop-lts",
27
+ ]
28
+ requires-python = ">= 3.11"
29
+ authors = [
30
+ {name = "ThinkThinkSyn", email = "contact@thinkthinksyn.com"},
31
+ ]
32
+ license = "MIT"
33
+ license-files = ["LICEN[CS]E*"]
34
+ readme = "README.md"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = [""]
38
+ include = ["thinkthinksyn*"]
39
+ exclude = ["tmp*"]
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/ThinkThinkSyn/thinkthinksyn"
43
+ Issues = "https://github.com/ThinkThinkSyn/thinkthinksyn/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,134 @@
1
+ import os
2
+ import sys
3
+ import time
4
+ import dotenv
5
+ import asyncio
6
+ import logging
7
+ import inspect
8
+ import contextlib
9
+ import colorlog
10
+
11
+ from functools import partial, cache, wraps
12
+ from concurrent.futures import ThreadPoolExecutor
13
+ from typing import TypeVar, Callable, Any
14
+
15
+ formatter = colorlog.ColoredFormatter(
16
+ '%(log_color)s[%(levelname)s]%(reset)s %(asctime)s | %(message)s',
17
+ datefmt='%Y-%m-%d %H:%M:%S',
18
+ log_colors={
19
+ 'DEBUG': 'white,dim',
20
+ 'INFO': 'white',
21
+ 'WARNING': 'yellow',
22
+ 'ERROR': 'red',
23
+ 'CRITICAL': 'red,bg_white',
24
+ 'SUCCESS': 'green',
25
+ }
26
+ )
27
+ logging.addLevelName(100, "SUCCESS")
28
+ _log_handler = logging.StreamHandler()
29
+ _log_handler.setFormatter(formatter)
30
+
31
+ logging.basicConfig(
32
+ level=logging.INFO,
33
+ format='[%(levelname)s] %(asctime)s | %(message)s',
34
+ datefmt='%Y-%m-%d %H:%M:%S',
35
+ force=True
36
+ )
37
+
38
+ class _Logger(logging.Logger):
39
+ def success(self, msg, *args, **kwargs):
40
+ if self.isEnabledFor(100):
41
+ self._log(100, msg, args, **kwargs)
42
+ logging.setLoggerClass(_Logger)
43
+
44
+ project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
45
+ sys.path.insert(0, project_dir)
46
+
47
+ env_path = os.path.join(project_dir, '.env')
48
+ if os.path.exists(env_path):
49
+ dotenv.load_dotenv(env_path)
50
+
51
+ logger: _Logger = logging.getLogger() # type: ignore
52
+ logger.handlers = [_log_handler]
53
+ setattr(logger, 'success', partial(_Logger.success, logger))
54
+
55
+ @contextlib.contextmanager
56
+ def _timer(label: str):
57
+ start = time.time()
58
+ yield
59
+ end = time.time()
60
+ logger.info(f"{label} took {end - start:.4f} seconds")
61
+
62
+ _T = TypeVar('_T', bound=Callable[[], Any])
63
+
64
+ def test_func(func: _T)-> _T:
65
+ func_name = func.__name__ # type: ignore
66
+ if inspect.iscoroutinefunction(func):
67
+ @wraps(func)
68
+ async def wrapper(*args, **kwargs): # type: ignore
69
+ with _timer(func_name):
70
+ try:
71
+ result = await func(*args, **kwargs)
72
+ logger.success(f"`{func_name}` passed. Result: \n{result}\n")
73
+ except Exception as e:
74
+ logger.error(f"`{func_name}` failed with exception: {e}")
75
+ else:
76
+ @wraps(func) # type: ignore
77
+ def wrapper(*args, **kwargs):
78
+ with _timer(func_name):
79
+ try:
80
+ result = func(*args, **kwargs) # type: ignore
81
+ logger.success(f"`{func_name}` passed. Result: \n{result}\n")
82
+ except Exception as e:
83
+ logger.error(f"`{func_name}` failed with exception: {e}")
84
+ return wrapper # type: ignore
85
+
86
+ _testing_funcs: dict[str, list[Callable[[], Any]]] = {}
87
+
88
+ def register_testing(module: str)->Callable[[_T], _T]:
89
+ if module not in _testing_funcs:
90
+ _testing_funcs[module] = []
91
+ def decorator(func: _T)-> _T:
92
+ _testing_funcs[module].append(func)
93
+ return func
94
+ return decorator
95
+
96
+ @cache
97
+ def _thread_pool_executor()->ThreadPoolExecutor:
98
+ return ThreadPoolExecutor(max_workers=os.cpu_count() or 4)
99
+
100
+ def run_testing(module: str):
101
+ if module not in _testing_funcs:
102
+ logger.info(f"No testing functions registered for module '{module}'")
103
+ return
104
+ sync_funcs, async_funcs = [], []
105
+ for func in _testing_funcs[module]:
106
+ if inspect.iscoroutinefunction(func):
107
+ async_funcs.append(test_func(func)) # type: ignore
108
+ else:
109
+ sync_funcs.append(test_func(func)) # type: ignore
110
+ total_count = len(sync_funcs) + len(async_funcs)
111
+ if async_funcs:
112
+ def run_async_tests(async_funcs):
113
+ async def run_async_tests():
114
+ await asyncio.gather(*(func() for func in async_funcs))
115
+ asyncio.run(run_async_tests())
116
+ sync_funcs.append(partial(run_async_tests, async_funcs))
117
+
118
+ with _timer(f"{total_count} tests for module '{module}'"):
119
+ futures = []
120
+ for func in sync_funcs:
121
+ futures.append(_thread_pool_executor().submit(func))
122
+ for future in futures:
123
+ future.result()
124
+
125
+
126
+ from thinkthinksyn import ThinkThinkSyn
127
+ tts = ThinkThinkSyn(apikey=os.getenv('TTS_APIKEY', ''))
128
+
129
+ __all__ = [
130
+ 'logger',
131
+ 'test_func',
132
+ 'register_testing',
133
+ 'tts',
134
+ ]
@@ -0,0 +1,5 @@
1
+ from .data_types import *
2
+
3
+ from .client import *
4
+
5
+ # not importing `common_utils`, as it is not necessary for end users