machine-thinking 0.0.3__tar.gz → 0.0.4__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 (18) hide show
  1. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/PKG-INFO +2 -3
  2. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/pyproject.toml +2 -9
  3. machine_thinking-0.0.3/src/machine_thinking/main.py → machine_thinking-0.0.4/src/machine_thinking/__init__.py +0 -8
  4. machine_thinking-0.0.4/src/machine_thinking/completion.py +48 -0
  5. machine_thinking-0.0.4/src/machine_thinking/messages.py +80 -0
  6. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking.egg-info/PKG-INFO +2 -3
  7. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking.egg-info/SOURCES.txt +3 -4
  8. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking.egg-info/top_level.txt +1 -0
  9. machine_thinking-0.0.3/src/machine_thinking/cli.py +0 -12
  10. machine_thinking-0.0.3/src/machine_thinking.egg-info/entry_points.txt +0 -2
  11. machine_thinking-0.0.3/src/machine_thinking.egg-info/requires.txt +0 -1
  12. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/LICENSE +0 -0
  13. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/README.md +0 -0
  14. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/setup.cfg +0 -0
  15. {machine_thinking-0.0.3/src/machine_thinking → machine_thinking-0.0.4/src}/__init__.py +0 -0
  16. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking/chat.py +0 -0
  17. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking/utils.py +0 -0
  18. {machine_thinking-0.0.3 → machine_thinking-0.0.4}/src/machine_thinking.egg-info/dependency_links.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machine-thinking
3
- Version: 0.0.3
4
- Summary: Package description
3
+ Version: 0.0.4
4
+ Summary: Calling the API of 'Thinking-Machines Lab' models without dependencies.
5
5
  Author-email: Machina Ratiocinatrix <machina.ratio@gmail.com>, Alexander Fedotov <alex.fedotov@aol.com>
6
6
  Project-URL: Homepage, https://github.com/machina-ratiocinatrix/machine-thinking
7
7
  Project-URL: Bug Tracker, https://github.com/machina-ratiocinatrix/machine-thinking/issues
@@ -12,7 +12,6 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: pyyaml==6.0.3
16
15
  Dynamic: license-file
17
16
 
18
17
  # Machine thinking
@@ -3,12 +3,12 @@ requires = ["setuptools>=67.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "machine-thinking"
6
- version = "0.0.3"
6
+ version = "0.0.4"
7
7
  authors = [
8
8
  {name="Machina Ratiocinatrix", email="machina.ratio@gmail.com"},
9
9
  {name="Alexander Fedotov", email="alex.fedotov@aol.com"}
10
10
  ]
11
- description = "Package description"
11
+ description = "Calling the API of 'Thinking-Machines Lab' models without dependencies."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
14
14
  classifiers=[
@@ -19,13 +19,6 @@ classifiers=[
19
19
 
20
20
  keywords = ["machine-thinking"]
21
21
 
22
- dependencies = [
23
- "pyyaml == 6.0.3"
24
- ]
25
-
26
- [project.scripts]
27
- machine-thinking = "machine_thinking.cli:run"
28
-
29
22
  [project.urls]
30
23
  "Homepage" = "https://github.com/machina-ratiocinatrix/machine-thinking"
31
24
  "Bug Tracker" = "https://github.com/machina-ratiocinatrix/machine-thinking/issues"
@@ -5,11 +5,3 @@
5
5
  This source code is licensed under the license found in the
6
6
  LICENSE file in the root directory of this source tree.
7
7
  """
8
-
9
-
10
- def main(): # arg=None):
11
- print(' main.')
12
-
13
-
14
- if __name__ == '__main__':
15
- main()
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Python
3
+
4
+ """Copyright (c) Alexander Fedotov.
5
+ This source code is licensed under the license found in the
6
+ LICENSE file in the root directory of this source tree.
7
+ """
8
+ from .utils import (default_model,
9
+ query)
10
+
11
+
12
+ def complete(text, **kwargs):
13
+ """A completions endpoint call
14
+ """
15
+ responses = []
16
+ payload = {
17
+ "model": kwargs.get("model", default_model),
18
+ "prompt": kwargs.get("prompt", text),
19
+ "response_format": kwargs.get('response_format', {'type': 'text'}),
20
+ "reasoning_effort": kwargs.get("reasoning_effort", "high"),
21
+ "reasoning_history":kwargs.get("reasoning_history", "interleaved"),
22
+ "thinking": kwargs.get("thinking", None),
23
+ "max_tokens": kwargs.get("max_tokens", 5),
24
+ "n": kwargs.get("n", 1),
25
+ "stop": kwargs.get("stop_sequences", ["stop"]),
26
+ # "seed": kwargs.get("seed", None),
27
+ "frequency_penalty":kwargs.get("frequency_penalty", 0),
28
+ "presence_penalty": kwargs.get("presence_penalty", 0),
29
+ # "logit_bias": kwargs.get("logit_bias", None),
30
+ "logprobs": kwargs.get("logprobs", None),
31
+ # "top_logprobs": kwargs.get("top_logprobs", None),
32
+ "temperature": kwargs.get("temperature", 1),
33
+ "top_p": kwargs.get("top_p", 1),
34
+ 'top_k': kwargs.get('top_k', 50),
35
+ 'stream': False,
36
+ # "user": kwargs.get("user", None)
37
+ }
38
+
39
+ responses = query(payload, '/completions')
40
+ response = responses['choices'][0]
41
+ text = response['text']
42
+ thoughts = ''
43
+
44
+ return thoughts, text
45
+
46
+
47
+ if __name__ == '__main__':
48
+ ...
@@ -0,0 +1,80 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Python
3
+
4
+ """Copyright (c) Alexander Fedotov.
5
+ This source code is licensed under the license found in the
6
+ LICENSE file in the root directory of this source tree.
7
+ """
8
+ from .utils import (query,
9
+ default_model,
10
+ get_function,
11
+ get_func_args,
12
+ call_function)
13
+
14
+
15
+ def get_weather(location):
16
+ # print(f"Executing weather tool for location: {location}")
17
+ return {"temperature": "72F", "condition": "Sunny"}
18
+
19
+
20
+ def message(messages=None, instructions=None, tools=None, **kwargs):
21
+ """A continuation of text with a given context and instruction.
22
+ """
23
+ messages = kwargs.get('messages', messages)
24
+
25
+ payload = {
26
+ 'model': kwargs.get('model', default_model),
27
+ 'system': kwargs.get('system', instructions),
28
+ 'messages': kwargs.get('messages', messages),
29
+ 'output_config': kwargs.get('output_config',{'effort': 'high'}),
30
+ 'thinking': kwargs.get('thinking', {
31
+ 'type': 'enabled',
32
+ 'budget_tokens': 10000,
33
+ }),
34
+ 'tool_choice': kwargs.get('tool_choice', {'type': 'auto', 'disable_parallel_tool_use': False}),
35
+ 'max_tokens': kwargs.get('max_tokens', 4096),
36
+ 'prompt_truncate_len': kwargs.get('prompt_truncate_len', 100000),
37
+ 'n': kwargs.get('n', 1),
38
+ 'top_p': kwargs.get('top_p', 0.9),
39
+ 'top_k': kwargs.get('top_k', 10),
40
+ 'stream': False
41
+ }
42
+ if tools:
43
+ payload['tools'] = tools
44
+ payload['parallel_tool_calls'] = True
45
+ payload['tool_choice'] = 'auto'
46
+
47
+ while True:
48
+ result = query(payload, '/messages')
49
+ completion_message = result['choices'][0]['message']
50
+ messages.append(completion_message)
51
+ thoughts = completion_message.get('reasoning_content', '')
52
+ text = completion_message.get('content', '')
53
+ function_calls = completion_message.get('tool_calls', [])
54
+
55
+ if function_calls:
56
+ # Call all requested functions and create response messages.
57
+ for function_call in function_calls:
58
+ call_id = function_call.get('id')
59
+ func_def = function_call.get('function')
60
+ func_name = func_def.get('name', '')
61
+
62
+ # Look up tool by name in globals and caller frames
63
+ func = get_function(func_name)
64
+ func_args = get_func_args(func_def)
65
+ result = call_function(func, func_args)
66
+
67
+ tool_message = {
68
+ "role": "tool",
69
+ "tool_call_id": call_id,
70
+ "content": result
71
+ }
72
+ messages.append(tool_message)
73
+ else:
74
+ break
75
+
76
+ return thoughts, text
77
+
78
+
79
+ if __name__ == '__main__':
80
+ ...
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machine-thinking
3
- Version: 0.0.3
4
- Summary: Package description
3
+ Version: 0.0.4
4
+ Summary: Calling the API of 'Thinking-Machines Lab' models without dependencies.
5
5
  Author-email: Machina Ratiocinatrix <machina.ratio@gmail.com>, Alexander Fedotov <alex.fedotov@aol.com>
6
6
  Project-URL: Homepage, https://github.com/machina-ratiocinatrix/machine-thinking
7
7
  Project-URL: Bug Tracker, https://github.com/machina-ratiocinatrix/machine-thinking/issues
@@ -12,7 +12,6 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: pyyaml==6.0.3
16
15
  Dynamic: license-file
17
16
 
18
17
  # Machine thinking
@@ -1,14 +1,13 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
+ src/__init__.py
4
5
  src/machine_thinking/__init__.py
5
6
  src/machine_thinking/chat.py
6
- src/machine_thinking/cli.py
7
- src/machine_thinking/main.py
7
+ src/machine_thinking/completion.py
8
+ src/machine_thinking/messages.py
8
9
  src/machine_thinking/utils.py
9
10
  src/machine_thinking.egg-info/PKG-INFO
10
11
  src/machine_thinking.egg-info/SOURCES.txt
11
12
  src/machine_thinking.egg-info/dependency_links.txt
12
- src/machine_thinking.egg-info/entry_points.txt
13
- src/machine_thinking.egg-info/requires.txt
14
13
  src/machine_thinking.egg-info/top_level.txt
@@ -1,12 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Python
3
-
4
- """Copyright (c) Alexander Fedotov.
5
- This source code is licensed under the license found in the
6
- LICENSE file in the root directory of this source tree.
7
- """
8
- from .main import main
9
-
10
-
11
- def run(): #arg): # (count, arg): if with option.
12
- main() #arg)
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- machine-thinking = machine_thinking.cli:run
@@ -1 +0,0 @@
1
- pyyaml==6.0.3