thinking-machine 0.0.25__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.
Files changed (32) hide show
  1. {thinking_machine-0.0.25/src/thinking_machine.egg-info → thinking_machine-0.1.0}/PKG-INFO +5 -28
  2. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/README.md +3 -25
  3. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/pyproject.toml +3 -4
  4. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/__init__.py +1 -4
  5. thinking_machine-0.1.0/src/thinking_machine/cli.py +148 -0
  6. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/config.py +3 -3
  7. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/castor_pollux.py +1 -1
  8. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/depsek.py +2 -1
  9. {thinking_machine-0.0.25 → thinking_machine-0.1.0/src/thinking_machine.egg-info}/PKG-INFO +5 -28
  10. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine.egg-info/requires.txt +0 -1
  11. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/tests/test_e2e.py +1 -1
  12. thinking_machine-0.0.25/src/thinking_machine/cli.py +0 -96
  13. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/LICENSE +0 -0
  14. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/MANIFEST.in +0 -0
  15. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/setup.cfg +0 -0
  16. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/githf.py +0 -0
  17. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/machina.yaml +0 -0
  18. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/machine.py +0 -0
  19. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/__init__.py +0 -0
  20. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/camelids.py +0 -0
  21. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/electroid.py +0 -0
  22. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/openai.py +0 -0
  23. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/qrog.py +0 -0
  24. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/providers/strangelove.py +0 -0
  25. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine/utilities.py +0 -0
  26. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine.egg-info/SOURCES.txt +0 -0
  27. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine.egg-info/dependency_links.txt +0 -0
  28. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine.egg-info/entry_points.txt +0 -0
  29. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/src/thinking_machine.egg-info/top_level.txt +0 -0
  30. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/tests/test_cli.py +0 -0
  31. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/tests/test_llm_soup.py +0 -0
  32. {thinking_machine-0.0.25 → thinking_machine-0.1.0}/tests/test_utilities.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thinking-machine
3
- Version: 0.0.25
4
- Summary: A Machine that thinks.
3
+ Version: 0.1.0
4
+ Summary: Thinking-Machine ...
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
@@ -12,7 +12,6 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: pyyaml==6.0.3
15
- Requires-Dist: click==8.3.1
16
15
  Dynamic: license-file
17
16
 
18
17
  # Thinking-Machine
@@ -37,37 +36,15 @@ export GITHUB_TOKEN="ghp_..."
37
36
  ```
38
37
  Then:
39
38
  ```bash
40
- thinking-machine multilogue.txt
39
+ thinking-machine -a multilogue.txt
41
40
  ```
42
41
  Or:
43
42
  ```bash
44
- thinking-machine multilogue.txt new_turn.txt
43
+ thinking-machine multilogue.txt > response.txt
45
44
  ```
46
45
  Or:
47
46
  ```bash
48
- cat multilogue.txt | thinking-machine
49
- ```
50
- Or:
51
- ```bash
52
- cat multilogue.txt | thinking-machine > multilogue.txt
53
- ```
54
- Or:
55
- ```bash
56
- (cat multilogue.txt; echo:"Theodotos: What do you think, Thinking-Machine?") \
57
- | thinking-machine
58
- ```
59
- Or:
60
- ```bash
61
- cat multilogue.txt new_turn.txt | thinking-machine
62
- ```
63
- Or:
64
- ```bash
65
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
66
- ```
67
- Or, if you have installed other machines:
68
- ```bash
69
- cat multilogue.md | thinking-machine \
70
- | summarizing-machine | judging-machine > summary_judgment.md
47
+ thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
71
48
  ```
72
49
 
73
50
  Or use it in your Python code:
@@ -20,37 +20,15 @@ export GITHUB_TOKEN="ghp_..."
20
20
  ```
21
21
  Then:
22
22
  ```bash
23
- thinking-machine multilogue.txt
23
+ thinking-machine -a multilogue.txt
24
24
  ```
25
25
  Or:
26
26
  ```bash
27
- thinking-machine multilogue.txt new_turn.txt
27
+ thinking-machine multilogue.txt > response.txt
28
28
  ```
29
29
  Or:
30
30
  ```bash
31
- cat multilogue.txt | thinking-machine
32
- ```
33
- Or:
34
- ```bash
35
- cat multilogue.txt | thinking-machine > multilogue.txt
36
- ```
37
- Or:
38
- ```bash
39
- (cat multilogue.txt; echo:"Theodotos: What do you think, Thinking-Machine?") \
40
- | thinking-machine
41
- ```
42
- Or:
43
- ```bash
44
- cat multilogue.txt new_turn.txt | thinking-machine
45
- ```
46
- Or:
47
- ```bash
48
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
49
- ```
50
- Or, if you have installed other machines:
51
- ```bash
52
- cat multilogue.md | thinking-machine \
53
- | summarizing-machine | judging-machine > summary_judgment.md
31
+ thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
54
32
  ```
55
33
 
56
34
  Or use it in your Python code:
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "thinking-machine"
7
- version = "0.0.25"
7
+ version = "0.1.0"
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 = "A Machine that thinks."
12
+ description = "Thinking-Machine ..."
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.10"
15
15
  classifiers=[
@@ -19,8 +19,7 @@ classifiers=[
19
19
  ]
20
20
  keywords = ["thinking-machine"]
21
21
  dependencies = [
22
- "pyyaml == 6.0.3",
23
- "click == 8.3.1"
22
+ "pyyaml == 6.0.3"
24
23
  ]
25
24
 
26
25
  [project.scripts]
@@ -7,17 +7,14 @@ LICENSE file in the root directory of this source tree.
7
7
  """
8
8
  from .config import Config
9
9
  from .machine import machine
10
- from .cli import run
11
10
  from .githf import fetch_instructions
12
11
  from .utilities import (plato_text_to_muj,
13
12
  plato_text_to_mpuj,
14
13
  llm_soup_to_text,
15
- new_plato_text,
16
- messages_to_mpj)
14
+ new_plato_text)
17
15
 
18
16
  __all__ = [
19
17
  'machine',
20
- 'run',
21
18
  'fetch_instructions',
22
19
  'Config'
23
20
  ]
@@ -0,0 +1,148 @@
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 os
9
+ import sys
10
+ import select
11
+ import fileinput
12
+ import argparse
13
+ import syslog
14
+ from .config import Config
15
+ from .utilities import new_plato_text
16
+
17
+
18
+ def options_and_arguments():
19
+ # Initialize the parser
20
+ parser = argparse.ArgumentParser(
21
+ description="Thinking-Machine thinks for you about the meanings.",
22
+ epilog="Example: thinking-machine input_text.txt > output_text.txt"
23
+ # thinking-machine multilogue.txt > tmp && mv tmp multilogue.txt
24
+ )
25
+
26
+ # Give the access key and token, or set the environment variables in advance.
27
+ parser.add_argument('-p', '--provider-api-key',
28
+ default=os.getenv('PROVIDER_API_KEY', 'no_key'),
29
+ help="LLM provider API key (defaults to $PROVIDER_API_KEY)")
30
+ parser.add_argument('-g', '--github-token',
31
+ default=os.getenv('GITHUB_TOKEN', 'no_token'),
32
+ help="GitHub API token (defaults to $GITHUB_TOKEN)")
33
+
34
+ # Add the interactive flag
35
+ # parser.add_argument('-i', '--interactive',
36
+ # action='store_true',
37
+ # help="Enable interactive mode (defaults to False)")
38
+
39
+ parser.add_argument('-a', '--append',
40
+ action='store_true',
41
+ help="Append the utterance to the input.")
42
+
43
+ # Positional arguments (files)
44
+ # '*' captures zero or more arguments into a list, nargs='+' one or more.
45
+ parser.add_argument('filenames',
46
+ nargs='*',
47
+ help="Zero (when text comes though a pipe) or more files to process.")
48
+ return parser
49
+
50
+
51
+ def run():
52
+ """
53
+ $ text | thinking-machine # Accepts text from the pipe
54
+ $ echo "...<text>..." | thinking-machine #
55
+
56
+ $ thinking-machine multilogue.txt new_turn.txt # ...or files.
57
+ """
58
+
59
+ args = options_and_arguments().parse_args()
60
+
61
+ # If no files are provided AND no data is being piped in - exit.
62
+ if not args.filenames:
63
+ # Check if stdin (fd 0) is ready to be read
64
+ readable, _, _ = select.select([sys.stdin], [], [], 0.1)
65
+ if not readable:
66
+ print("Error: No input files or piped text stream.")
67
+ options_and_arguments().print_help()
68
+ sys.exit(1)
69
+
70
+ config = Config()
71
+
72
+ if args.provider_api_key:
73
+ if args.provider_api_key.startswith('sk-'):
74
+ if args.provider_api_key.startswith('sk-proj-'):
75
+ config.provider = 'OpenAI'
76
+ os.environ['OPENAI_API_KEY'] = args.provider_api_key
77
+ elif args.provider_api_key.startswith('sk-ant-'):
78
+ config.provider = 'Anthropic'
79
+ os.environ['ANTHROPIC_API_KEY'] = args.provider_api_key
80
+ else:
81
+ config.provider = 'DepSek'
82
+ os.environ['DEPSEK_API_KEY'] = args.provider_api_key
83
+ elif args.provider_api_key.startswith('AIzaSy'):
84
+ config.provider = 'Gemini'
85
+ os.environ['GEMINI_API_KEY'] = args.provider_api_key
86
+ elif args.provider_api_key.startswith('gsk_'):
87
+ config.provider = 'Groq'
88
+ os.environ['GROQ_API_KEY'] = args.provider_api_key
89
+ elif args.provider_api_key.startswith('xai-'):
90
+ config.provider = 'XAI'
91
+ os.environ['XAI_API_KEY'] = args.provider_api_key
92
+ elif args.provider_api_key.startswith('LLM|'):
93
+ config.provider = 'Meta'
94
+ os.environ['META_API_KEY'] = args.provider_api_key
95
+ elif args.provider_api_key == 'no_provider_key':
96
+ sys.stderr.write(f'No provider key!\n')
97
+ sys.stderr.flush()
98
+ sys.exit(1)
99
+ else:
100
+ if config.provider == '':
101
+ raise ValueError(f"Unrecognized API key prefix and no provider specified.")
102
+
103
+ config.provider_api_key = args.provider_api_key
104
+
105
+ if args.github_token:
106
+ config.github_token = args.github_token
107
+ os.environ['GITHUB_TOKEN'] = args.github_token
108
+
109
+ # Ingest files line by line. Join is here for long files.
110
+ lines = []
111
+ for line in fileinput.input(files=args.filenames or ['-'], encoding="utf-8"):
112
+ lines.append(line)
113
+ raw_input = "".join(lines)
114
+
115
+ from .machine import machine
116
+
117
+ try:
118
+ thoughts, text = machine(raw_input, config)
119
+ output = new_plato_text(thoughts, text, config.name)
120
+ if args.append:
121
+ output = raw_input +'\n\n' + output
122
+ sys.stdout.write(output)
123
+ sys.stdout.flush()
124
+
125
+ # Assesment and signals.
126
+ utterance = "My answer is ready"
127
+ # Open syslog connection
128
+ syslog.openlog(
129
+ ident="thinking-machine",
130
+ logoption=syslog.LOG_PERROR | syslog.LOG_NDELAY,
131
+ facility=syslog.LOG_USER
132
+ )
133
+ # Signal (single line less than 4096 only!)
134
+ syslog.syslog(syslog.LOG_INFO, f"thinking-machine: {utterance}.")
135
+ syslog.closelog()
136
+
137
+ except Exception as e:
138
+ if args.debug:
139
+ import traceback
140
+ traceback.print_exc()
141
+ else:
142
+ sys.stderr.write(f'Machine did not work {e}\n')
143
+ sys.stderr.flush()
144
+ sys.exit(1)
145
+
146
+
147
+ if __name__ == '__main__':
148
+ run()
@@ -15,9 +15,9 @@ class Config:
15
15
  github_name: str = field(default_factory=lambda: environ.get('GITHUB_NAME', ''))
16
16
  github_email: str = field(default_factory=lambda: environ.get('GITHUB_EMAIL', ''))
17
17
  provider_api_key: str = field(default_factory=lambda: environ.get('PROVIDER_API_KEY', ''))
18
- provider: str = field(default_factory=lambda: environ.get('PROVIDER', 'OpenAI'))
18
+ provider: str = field(default_factory=lambda: environ.get('PROVIDER', ''))
19
19
  machine_organization_name: str = field(default_factory=lambda: environ.get('MACHINE_ORGANIZATION_NAME', 'machina-ratiocinatrix'))
20
20
  private_repo_with_text: str = field(default_factory=lambda: environ.get('PRIVATE_REPO_WITH_TEXT','thinking_machine'))
21
21
  system_prompt_file: str = field(default_factory=lambda: environ.get('SYSTEM_PROMPT_FILE', 'machina.yaml'))
22
- name: str = field(default_factory=lambda: environ.get('MACHINE-NAME','thinking-machine'))
23
- instructions: str = field(default_factory=lambda: environ.get('MACHINE-DESCRIPTION','The Assistant is Thinking-Machine.'))
22
+ name: str = ''
23
+ instructions: str = ''
@@ -80,7 +80,7 @@ def respond(messages=None, instructions=None, **kwargs):
80
80
  # Set the mandatory headers
81
81
  headers = {
82
82
  "Content-Type": "application/json",
83
- "User-Agent": "Name-of-the-Machine"
83
+ "User-Agent": "Thinking-Machine"
84
84
  }
85
85
 
86
86
  # urlencode parameter
@@ -16,7 +16,7 @@ def respond(messages, instructions, **kwargs):
16
16
  """
17
17
  api_key = environ.get("DEPSEK_API_KEY")
18
18
  api_base = environ.get("DEPSEK_API_BASE", "https://api.deepseek.com")
19
- default_model = environ.get("DEPSEK_DEFAULT_MODEL", "deepseek-reasoner")
19
+ default_model = environ.get("DEPSEK_DEFAULT_MODEL", "deepseek-v4-pro")
20
20
 
21
21
  instruction = kwargs.get('system_instruction', instructions)
22
22
  first_message = [dict(role='system', content=instruction)] if instruction else []
@@ -31,6 +31,7 @@ def respond(messages, instructions, **kwargs):
31
31
  "messages": instruction_and_contents,
32
32
  "max_tokens": kwargs.get("max_tokens", 32000),
33
33
  "temperature": kwargs.get("temperature", 1.0),
34
+ "reasoning_effort": kwargs.get("reasoning_effort", "max"),
34
35
  "thinking": {
35
36
  "type": "enabled"
36
37
  }
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thinking-machine
3
- Version: 0.0.25
4
- Summary: A Machine that thinks.
3
+ Version: 0.1.0
4
+ Summary: Thinking-Machine ...
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
@@ -12,7 +12,6 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: pyyaml==6.0.3
15
- Requires-Dist: click==8.3.1
16
15
  Dynamic: license-file
17
16
 
18
17
  # Thinking-Machine
@@ -37,37 +36,15 @@ export GITHUB_TOKEN="ghp_..."
37
36
  ```
38
37
  Then:
39
38
  ```bash
40
- thinking-machine multilogue.txt
39
+ thinking-machine -a multilogue.txt
41
40
  ```
42
41
  Or:
43
42
  ```bash
44
- thinking-machine multilogue.txt new_turn.txt
43
+ thinking-machine multilogue.txt > response.txt
45
44
  ```
46
45
  Or:
47
46
  ```bash
48
- cat multilogue.txt | thinking-machine
49
- ```
50
- Or:
51
- ```bash
52
- cat multilogue.txt | thinking-machine > multilogue.txt
53
- ```
54
- Or:
55
- ```bash
56
- (cat multilogue.txt; echo:"Theodotos: What do you think, Thinking-Machine?") \
57
- | thinking-machine
58
- ```
59
- Or:
60
- ```bash
61
- cat multilogue.txt new_turn.txt | thinking-machine
62
- ```
63
- Or:
64
- ```bash
65
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
66
- ```
67
- Or, if you have installed other machines:
68
- ```bash
69
- cat multilogue.md | thinking-machine \
70
- | summarizing-machine | judging-machine > summary_judgment.md
47
+ thinking-machine -a multilogue.txt > tmp && echo tmp > multilogue.txt
71
48
  ```
72
49
 
73
50
  Or use it in your Python code:
@@ -21,7 +21,7 @@ def test_uvx_integration():
21
21
  ".[all]",
22
22
  "--from",
23
23
  ".",
24
- "name-of-the-machine"
24
+ "thinking-machine"
25
25
  ]
26
26
 
27
27
  # The keys/tokens are passed through the environment automatically via env=env.
@@ -1,96 +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 os import environ
9
- import sys
10
- import click
11
- import fileinput
12
- from .config import Config
13
- from .utilities import new_plato_text
14
-
15
-
16
- @click.command()
17
- @click.option('-k', '--provider-api-key',
18
- envvar='PROVIDER_API_KEY',
19
- default='no_key', help='Language Model API provider key.')
20
- @click.option('-t', '--github-token', envvar='GITHUB_TOKEN',
21
- default='no_token', help='GitHub API token for private repo access.')
22
- @click.option('-d', '--debug/--no-debug',
23
- default=False, help='Print full stack trace on errors.')
24
- @click.option('-i', '--interactive',
25
- is_flag=True, help='Respond and stay interactive')
26
- @click.argument('filenames', nargs=-1,
27
- type=click.Path(exists=True))
28
- def run(provider_api_key, github_token, debug, interactive, filenames):
29
- """
30
- $ text | name-of-the-machine # Accepts text from the pipe
31
- $ echo "...<text>..." | name-of-the-machine #
32
-
33
- $ name-of-the-machine multilogue.txt new_turn.txt # Loads files.
34
- """
35
- config = Config()
36
-
37
- if provider_api_key:
38
- if provider_api_key.startswith('sk-'):
39
- if provider_api_key.startswith('sk-proj-'):
40
- config.provider = 'OpenAI'
41
- environ['OPENAI_API_KEY'] = provider_api_key
42
- elif provider_api_key.startswith('sk-ant-'):
43
- config.provider = 'Anthropic'
44
- environ['ANTHROPIC_API_KEY'] = provider_api_key
45
- else:
46
- config.provider = 'DepSek'
47
- environ['DEPSEK_API_KEY'] = provider_api_key
48
- elif provider_api_key.startswith('AIzaSy'):
49
- config.provider = 'Gemini'
50
- environ['GEMINI_API_KEY'] = provider_api_key
51
- elif provider_api_key.startswith('gsk_'):
52
- config.provider = 'Groq'
53
- environ['GROQ_API_KEY'] = provider_api_key
54
- elif provider_api_key.startswith('xai-'):
55
- config.provider = 'XAI'
56
- environ['XAI_API_KEY'] = provider_api_key
57
- elif provider_api_key.startswith('LLM|'):
58
- config.provider = 'Meta'
59
- environ['META_API_KEY'] = provider_api_key
60
- elif provider_api_key == 'no_provider_key':
61
- sys.stderr.write(f'No provider key!\n')
62
- sys.stderr.flush()
63
- sys.exit(1)
64
- else:
65
- if config.provider == '':
66
- raise ValueError(f"Unrecognized API key prefix and no provider specified.")
67
-
68
- config.provider_api_key = provider_api_key
69
-
70
- if github_token:
71
- config.github_token = github_token
72
- environ['GITHUB_TOKEN'] = github_token
73
-
74
- raw_input = ''
75
- for line in fileinput.input(files=filenames or ('-',), encoding="utf-8"):
76
- raw_input += line
77
-
78
- from .machine import machine
79
-
80
- try:
81
- thoughts, text = machine(raw_input, config)
82
- output = raw_input + '\n\n' + new_plato_text(thoughts, text, config.name)
83
- sys.stdout.write(output)
84
- sys.stdout.flush()
85
- except Exception as e:
86
- if debug:
87
- import traceback
88
- traceback.print_exc()
89
- else:
90
- sys.stderr.write(f'Machine did not work {e}\n')
91
- sys.stderr.flush()
92
- sys.exit(1)
93
-
94
-
95
- if __name__ == '__main__':
96
- run()