thinking-machine 0.1.4__tar.gz → 0.1.6__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.
- {thinking_machine-0.1.4/src/thinking_machine.egg-info → thinking_machine-0.1.6}/PKG-INFO +8 -4
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/README.md +6 -2
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/pyproject.toml +2 -2
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/cli.py +15 -6
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/machine.py +20 -0
- thinking_machine-0.1.6/src/thinking_machine/providers/basta.py +82 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6/src/thinking_machine.egg-info}/PKG-INFO +8 -4
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/SOURCES.txt +1 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/LICENSE +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/MANIFEST.in +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/setup.cfg +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/__init__.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/config.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/githf.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/machina.yaml +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/__init__.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/camelids.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/castor_pollux.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/depsek.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/electroid.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/openai.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/qrog.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/strangelove.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/utilities.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/dependency_links.txt +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/entry_points.txt +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/requires.txt +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/top_level.txt +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/tests/test_cli.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/tests/test_e2e.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/tests/test_llm_soup.py +0 -0
- {thinking_machine-0.1.4 → thinking_machine-0.1.6}/tests/test_utilities.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: thinking-machine
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: A Machine that thinks.
|
|
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/thinking-machine
|
|
7
7
|
Keywords: thinking-machine
|
|
@@ -21,8 +21,8 @@ In order to launch it from the command line or as a Python subprocess:
|
|
|
21
21
|
```bash
|
|
22
22
|
echo "Theodotos-Alexandreus: Are language models seeking the Truth, machine?" \
|
|
23
23
|
| uvx thinking-machine \
|
|
24
|
-
--provider-api-key
|
|
25
|
-
--github-token
|
|
24
|
+
--provider-api-key sk-proj-... \
|
|
25
|
+
--github-token ghp_...
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Or, with a local pip installation:
|
|
@@ -44,6 +44,10 @@ thinking-machine multilogue.txt > response.txt
|
|
|
44
44
|
```
|
|
45
45
|
Or:
|
|
46
46
|
```bash
|
|
47
|
+
thinking-machine -a multilogue.txt | vim
|
|
48
|
+
```
|
|
49
|
+
Or:
|
|
50
|
+
```bash
|
|
47
51
|
thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
|
|
48
52
|
```
|
|
49
53
|
|
|
@@ -5,8 +5,8 @@ In order to launch it from the command line or as a Python subprocess:
|
|
|
5
5
|
```bash
|
|
6
6
|
echo "Theodotos-Alexandreus: Are language models seeking the Truth, machine?" \
|
|
7
7
|
| uvx thinking-machine \
|
|
8
|
-
--provider-api-key
|
|
9
|
-
--github-token
|
|
8
|
+
--provider-api-key sk-proj-... \
|
|
9
|
+
--github-token ghp_...
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
Or, with a local pip installation:
|
|
@@ -28,6 +28,10 @@ thinking-machine multilogue.txt > response.txt
|
|
|
28
28
|
```
|
|
29
29
|
Or:
|
|
30
30
|
```bash
|
|
31
|
+
thinking-machine -a multilogue.txt | vim
|
|
32
|
+
```
|
|
33
|
+
Or:
|
|
34
|
+
```bash
|
|
31
35
|
thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
|
|
32
36
|
```
|
|
33
37
|
|
|
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "thinking-machine"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
authors = [
|
|
9
9
|
{name="Machina Ratiocinatrix", email="machina.ratio@gmail.com"},
|
|
10
10
|
{name="Alexander Fedotov", email="alex.fedotov@aol.com"}
|
|
11
11
|
]
|
|
12
|
-
description = "
|
|
12
|
+
description = "A Machine that thinks."
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
requires-python = ">=3.10"
|
|
15
15
|
classifiers=[
|
|
@@ -20,7 +20,7 @@ def options_and_arguments():
|
|
|
20
20
|
parser = argparse.ArgumentParser(
|
|
21
21
|
description="Thinking-Machine thinks for you about the meanings.",
|
|
22
22
|
epilog="Example: thinking-machine input_text.txt > output_text.txt"
|
|
23
|
-
# thinking-machine multilogue.txt > tmp && mv tmp multilogue.txt
|
|
23
|
+
# thinking-machine -a multilogue.txt > tmp && mv tmp multilogue.txt
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
# Give the access key and token, or set the environment variables in advance.
|
|
@@ -31,15 +31,19 @@ def options_and_arguments():
|
|
|
31
31
|
default=os.getenv('GITHUB_TOKEN', 'no_token'),
|
|
32
32
|
help="GitHub API token (defaults to $GITHUB_TOKEN)")
|
|
33
33
|
|
|
34
|
+
parser.add_argument('-a', '--append',
|
|
35
|
+
action='store_true',
|
|
36
|
+
help="Append the utterance to the input.")
|
|
37
|
+
|
|
38
|
+
parser.add_argument('-d', '--debug',
|
|
39
|
+
action='store_true',
|
|
40
|
+
help="Debug flag.")
|
|
41
|
+
|
|
34
42
|
# Add the interactive flag
|
|
35
43
|
# parser.add_argument('-i', '--interactive',
|
|
36
44
|
# action='store_true',
|
|
37
45
|
# help="Enable interactive mode (defaults to False)")
|
|
38
46
|
|
|
39
|
-
parser.add_argument('-a', '--append',
|
|
40
|
-
action='store_true',
|
|
41
|
-
help="Append the utterance to the input.")
|
|
42
|
-
|
|
43
47
|
# Positional arguments (files)
|
|
44
48
|
# '*' captures zero or more arguments into a list, nargs='+' one or more.
|
|
45
49
|
parser.add_argument('filenames',
|
|
@@ -99,6 +103,11 @@ def run():
|
|
|
99
103
|
else:
|
|
100
104
|
if config.provider == '':
|
|
101
105
|
raise ValueError(f"Unrecognized API key prefix and no provider specified.")
|
|
106
|
+
else:
|
|
107
|
+
if config.provider == 'Baseten':
|
|
108
|
+
os.environ['BASETEN_API_KEY'] = args.provider_api_key
|
|
109
|
+
else:
|
|
110
|
+
raise ValueError(f"Unsupported provider specified.")
|
|
102
111
|
|
|
103
112
|
config.provider_api_key = args.provider_api_key
|
|
104
113
|
|
|
@@ -127,7 +136,7 @@ def run():
|
|
|
127
136
|
# Open syslog connection
|
|
128
137
|
syslog.openlog(
|
|
129
138
|
ident="thinking-machine",
|
|
130
|
-
logoption=syslog.
|
|
139
|
+
logoption=syslog.LOG_NDELAY,
|
|
131
140
|
facility=syslog.LOG_USER
|
|
132
141
|
)
|
|
133
142
|
# Signal (single line less than 4096 only!)
|
|
@@ -152,6 +152,26 @@ def machine(plato_text, config, **kwargs):
|
|
|
152
152
|
|
|
153
153
|
return thoughts, text
|
|
154
154
|
|
|
155
|
+
elif provider == 'Baseten':
|
|
156
|
+
# Transform plato_text to CMJ format
|
|
157
|
+
messages = plato_text_to_cmj(plato_text=plato_text,
|
|
158
|
+
machine_name=name)
|
|
159
|
+
# Call OpenAI API via opehaina
|
|
160
|
+
environ['BASETEN_API_KEY'] = api_key
|
|
161
|
+
try:
|
|
162
|
+
from .providers import basta
|
|
163
|
+
except ImportError:
|
|
164
|
+
print("openai module is missing.", file=sys.stderr)
|
|
165
|
+
sys.exit(1)
|
|
166
|
+
|
|
167
|
+
thoughts, text = basta.respond(
|
|
168
|
+
messages=messages,
|
|
169
|
+
instructions=system_prompt,
|
|
170
|
+
**kwargs
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
return thoughts, text
|
|
174
|
+
|
|
155
175
|
elif provider == 'Meta':
|
|
156
176
|
# Transform plato_text to CMJ format
|
|
157
177
|
messages = plato_text_to_cmj(plato_text=plato_text,
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import urllib.request
|
|
9
|
+
import urllib.error
|
|
10
|
+
import json
|
|
11
|
+
from os import environ
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def respond(messages, instructions, **kwargs):
|
|
15
|
+
"""
|
|
16
|
+
"""
|
|
17
|
+
api_key = environ.get("BASETEN_API_KEY")
|
|
18
|
+
api_base = environ.get("BASETEN_API_BASE", "https://inference.baseten.co/v1")
|
|
19
|
+
default_model = environ.get("BASETEN_DEFAULT_MODEL", "deepseek-ai/DeepSeek-V4-Pro")
|
|
20
|
+
|
|
21
|
+
instruction = kwargs.get('system_instruction', instructions)
|
|
22
|
+
first_message = [dict(role='system', content=instruction)] if instruction else []
|
|
23
|
+
|
|
24
|
+
# add contents and user text to the first (instruction) message
|
|
25
|
+
first_message.extend(messages)
|
|
26
|
+
instruction_and_contents = first_message
|
|
27
|
+
|
|
28
|
+
# Define the payload
|
|
29
|
+
payload = {
|
|
30
|
+
"model": kwargs.get("model", default_model),
|
|
31
|
+
"messages": instruction_and_contents,
|
|
32
|
+
"max_tokens": kwargs.get("max_tokens", 32000),
|
|
33
|
+
"temperature": kwargs.get("temperature", 1.0),
|
|
34
|
+
"reasoning_effort": kwargs.get("reasoning_effort", "max"),
|
|
35
|
+
"thinking": {
|
|
36
|
+
"type": "enabled"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Convert data dictionary to JSON and encode it to bytes
|
|
41
|
+
data_bytes = json.dumps(payload).encode('utf-8')
|
|
42
|
+
|
|
43
|
+
# Set the mandatory headers
|
|
44
|
+
headers = {
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
"Authorization": f"Api-Key {api_key}",
|
|
47
|
+
"User-Agent": "Thinking-Machine"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Create the Request object
|
|
51
|
+
req = urllib.request.Request(
|
|
52
|
+
f'{api_base}/chat/completions',
|
|
53
|
+
data=data_bytes,
|
|
54
|
+
headers=headers,
|
|
55
|
+
method="POST")
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
# Execute the request
|
|
59
|
+
with urllib.request.urlopen(req, timeout=300) as response:
|
|
60
|
+
response_data = response.read().decode('utf-8')
|
|
61
|
+
output = json.loads(response_data)
|
|
62
|
+
message = output['choices'][0]['message']
|
|
63
|
+
text = message['content']
|
|
64
|
+
thoughts = message['reasoning_content']
|
|
65
|
+
|
|
66
|
+
return thoughts, text
|
|
67
|
+
|
|
68
|
+
except urllib.error.HTTPError as e:
|
|
69
|
+
# Handle HTTP errors (e.g., 401 Unauthorized, 400 Bad Request)
|
|
70
|
+
error_info = e.read().decode('utf-8', errors='ignore')
|
|
71
|
+
print(f"HTTP Error {e.code}: {e.reason}")
|
|
72
|
+
print(f"Error Details: {error_info}")
|
|
73
|
+
return '', ''
|
|
74
|
+
|
|
75
|
+
except urllib.error.URLError as e:
|
|
76
|
+
# Handle network/connection errors
|
|
77
|
+
print(f"Failed to reach the server: {e.reason}")
|
|
78
|
+
return '', ''
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == '__main__':
|
|
82
|
+
...
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: thinking-machine
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: A Machine that thinks.
|
|
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/thinking-machine
|
|
7
7
|
Keywords: thinking-machine
|
|
@@ -21,8 +21,8 @@ In order to launch it from the command line or as a Python subprocess:
|
|
|
21
21
|
```bash
|
|
22
22
|
echo "Theodotos-Alexandreus: Are language models seeking the Truth, machine?" \
|
|
23
23
|
| uvx thinking-machine \
|
|
24
|
-
--provider-api-key
|
|
25
|
-
--github-token
|
|
24
|
+
--provider-api-key sk-proj-... \
|
|
25
|
+
--github-token ghp_...
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Or, with a local pip installation:
|
|
@@ -44,6 +44,10 @@ thinking-machine multilogue.txt > response.txt
|
|
|
44
44
|
```
|
|
45
45
|
Or:
|
|
46
46
|
```bash
|
|
47
|
+
thinking-machine -a multilogue.txt | vim
|
|
48
|
+
```
|
|
49
|
+
Or:
|
|
50
|
+
```bash
|
|
47
51
|
thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
|
|
48
52
|
```
|
|
49
53
|
|
|
@@ -16,6 +16,7 @@ src/thinking_machine.egg-info/entry_points.txt
|
|
|
16
16
|
src/thinking_machine.egg-info/requires.txt
|
|
17
17
|
src/thinking_machine.egg-info/top_level.txt
|
|
18
18
|
src/thinking_machine/providers/__init__.py
|
|
19
|
+
src/thinking_machine/providers/basta.py
|
|
19
20
|
src/thinking_machine/providers/camelids.py
|
|
20
21
|
src/thinking_machine/providers/castor_pollux.py
|
|
21
22
|
src/thinking_machine/providers/depsek.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/__init__.py
RENAMED
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/camelids.py
RENAMED
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/castor_pollux.py
RENAMED
|
File without changes
|
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/electroid.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine/providers/strangelove.py
RENAMED
|
File without changes
|
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/requires.txt
RENAMED
|
File without changes
|
{thinking_machine-0.1.4 → thinking_machine-0.1.6}/src/thinking_machine.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|