thinking-machine 0.0.25__tar.gz → 0.0.26__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.0.26}/PKG-INFO +4 -5
  2. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/README.md +2 -2
  3. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/pyproject.toml +3 -4
  4. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/__init__.py +1 -4
  5. thinking_machine-0.0.26/src/thinking_machine/cli.py +139 -0
  6. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/config.py +3 -3
  7. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/castor_pollux.py +1 -1
  8. {thinking_machine-0.0.25 → thinking_machine-0.0.26/src/thinking_machine.egg-info}/PKG-INFO +4 -5
  9. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine.egg-info/requires.txt +0 -1
  10. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/tests/test_e2e.py +1 -1
  11. thinking_machine-0.0.25/src/thinking_machine/cli.py +0 -96
  12. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/LICENSE +0 -0
  13. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/MANIFEST.in +0 -0
  14. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/setup.cfg +0 -0
  15. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/githf.py +0 -0
  16. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/machina.yaml +0 -0
  17. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/machine.py +0 -0
  18. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/__init__.py +0 -0
  19. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/camelids.py +0 -0
  20. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/depsek.py +0 -0
  21. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/electroid.py +0 -0
  22. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/openai.py +0 -0
  23. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/qrog.py +0 -0
  24. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/providers/strangelove.py +0 -0
  25. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine/utilities.py +0 -0
  26. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine.egg-info/SOURCES.txt +0 -0
  27. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine.egg-info/dependency_links.txt +0 -0
  28. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine.egg-info/entry_points.txt +0 -0
  29. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/src/thinking_machine.egg-info/top_level.txt +0 -0
  30. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/tests/test_cli.py +0 -0
  31. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/tests/test_llm_soup.py +0 -0
  32. {thinking_machine-0.0.25 → thinking_machine-0.0.26}/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.0.26
4
+ Summary: Thinking-Machine does thinking.
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
@@ -49,7 +48,7 @@ cat multilogue.txt | thinking-machine
49
48
  ```
50
49
  Or:
51
50
  ```bash
52
- cat multilogue.txt | thinking-machine > multilogue.txt
51
+ cat multilogue.txt | thinking-machine > tmp && mv tmp multilogue.txt
53
52
  ```
54
53
  Or:
55
54
  ```bash
@@ -62,7 +61,7 @@ cat multilogue.txt new_turn.txt | thinking-machine
62
61
  ```
63
62
  Or:
64
63
  ```bash
65
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
64
+ cat multilogue.txt new_turn.txt | thinking-machine > tmp && mv tmp multilogue.txt
66
65
  ```
67
66
  Or, if you have installed other machines:
68
67
  ```bash
@@ -32,7 +32,7 @@ cat multilogue.txt | thinking-machine
32
32
  ```
33
33
  Or:
34
34
  ```bash
35
- cat multilogue.txt | thinking-machine > multilogue.txt
35
+ cat multilogue.txt | thinking-machine > tmp && mv tmp multilogue.txt
36
36
  ```
37
37
  Or:
38
38
  ```bash
@@ -45,7 +45,7 @@ cat multilogue.txt new_turn.txt | thinking-machine
45
45
  ```
46
46
  Or:
47
47
  ```bash
48
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
48
+ cat multilogue.txt new_turn.txt | thinking-machine > tmp && mv tmp multilogue.txt
49
49
  ```
50
50
  Or, if you have installed other machines:
51
51
  ```bash
@@ -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.0.26"
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 does thinking."
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,139 @@
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
+ from .config import Config
14
+ from .utilities import new_plato_text
15
+
16
+
17
+ def options_and_arguments():
18
+ # Initialize the parser
19
+ parser = argparse.ArgumentParser(
20
+ description="Thinking-Machine thinks for you about the meanings.",
21
+ epilog="Example: thinking-machine input_text.txt > output_text.txt"
22
+ # thinking-machine multilogue.txt > tmp && mv tmp multilogue.txt
23
+ )
24
+
25
+ # Give the access key and token, or set the environment variables in advance.
26
+ parser.add_argument('-p', '--provider-api-key',
27
+ default=os.getenv('PROVIDER_API_KEY', 'no_key'),
28
+ help="LLM provider API key (defaults to $PROVIDER_API_KEY)")
29
+ parser.add_argument('-g', '--github-token',
30
+ default=os.getenv('GITHUB_TOKEN', 'no_token'),
31
+ help="GitHub API token (defaults to $GITHUB_TOKEN)")
32
+
33
+ # Add the interactive flag
34
+ # parser.add_argument('-i', '--interactive',
35
+ # action='store_true',
36
+ # help="Enable interactive mode (defaults to False)")
37
+
38
+ parser.add_argument('-d', '--debug',
39
+ action='store_true',
40
+ help="Debug mode flag")
41
+
42
+ # Positional arguments (files)
43
+ # '*' captures zero or more arguments into a list, nargs='+' one or more.
44
+ parser.add_argument('filenames',
45
+ nargs='*',
46
+ help="Zero (when text comes though a pipe) or more files to process.")
47
+ return parser
48
+
49
+
50
+ def run():
51
+ """
52
+ $ text | thinking-machine # Accepts text from the pipe
53
+ $ echo "...<text>..." | thinking-machine #
54
+
55
+ $ thinking-machine multilogue.txt new_turn.txt # ...or files.
56
+ """
57
+
58
+ args = options_and_arguments().parse_args()
59
+
60
+ # If debug - arguments values, raw and parsed.
61
+ if args.debug:
62
+ print(f"Debug - Raw arguments: {sys.argv}\n")
63
+ print(f"provider-api-key: {args.provider_api_key}")
64
+ print(f"github-token: {args.github_token}")
65
+ print(f"Files to process: {args.filenames}")
66
+
67
+ # If no files are provided AND no data is being piped in - exit.
68
+ if not args.filenames:
69
+ # Check if stdin (fd 0) is ready to be read
70
+ readable, _, _ = select.select([sys.stdin], [], [], 0.1)
71
+ if not readable:
72
+ print("Error: No input files or piped text stream.")
73
+ options_and_arguments().print_help()
74
+ sys.exit(1)
75
+
76
+ config = Config()
77
+
78
+ if args.provider_api_key:
79
+ if args.provider_api_key.startswith('sk-'):
80
+ if args.provider_api_key.startswith('sk-proj-'):
81
+ config.provider = 'OpenAI'
82
+ os.environ['OPENAI_API_KEY'] = args.provider_api_key
83
+ elif args.provider_api_key.startswith('sk-ant-'):
84
+ config.provider = 'Anthropic'
85
+ os.environ['ANTHROPIC_API_KEY'] = args.provider_api_key
86
+ else:
87
+ config.provider = 'DepSek'
88
+ os.environ['DEPSEK_API_KEY'] = args.provider_api_key
89
+ elif args.provider_api_key.startswith('AIzaSy'):
90
+ config.provider = 'Gemini'
91
+ os.environ['GEMINI_API_KEY'] = args.provider_api_key
92
+ elif args.provider_api_key.startswith('gsk_'):
93
+ config.provider = 'Groq'
94
+ os.environ['GROQ_API_KEY'] = args.provider_api_key
95
+ elif args.provider_api_key.startswith('xai-'):
96
+ config.provider = 'XAI'
97
+ os.environ['XAI_API_KEY'] = args.provider_api_key
98
+ elif args.provider_api_key.startswith('LLM|'):
99
+ config.provider = 'Meta'
100
+ os.environ['META_API_KEY'] = args.provider_api_key
101
+ elif args.provider_api_key == 'no_provider_key':
102
+ sys.stderr.write(f'No provider key!\n')
103
+ sys.stderr.flush()
104
+ sys.exit(1)
105
+ else:
106
+ if config.provider == '':
107
+ raise ValueError(f"Unrecognized API key prefix and no provider specified.")
108
+
109
+ config.provider_api_key = args.provider_api_key
110
+
111
+ if args.github_token:
112
+ config.github_token = args.github_token
113
+ os.environ['GITHUB_TOKEN'] = args.github_token
114
+
115
+ # Ingest files line by line. Join is here for long files.
116
+ lines = []
117
+ for line in fileinput.input(files=args.filenames or ['-'], encoding="utf-8"):
118
+ lines.append(line)
119
+ raw_input = "".join(lines)
120
+
121
+ from .machine import machine
122
+
123
+ try:
124
+ thoughts, text = machine(raw_input, config)
125
+ output = raw_input + new_plato_text(thoughts, text, config.name)
126
+ sys.stdout.write(output)
127
+ sys.stdout.flush()
128
+ except Exception as e:
129
+ if args.debug:
130
+ import traceback
131
+ traceback.print_exc()
132
+ else:
133
+ sys.stderr.write(f'Machine did not work {e}\n')
134
+ sys.stderr.flush()
135
+ sys.exit(1)
136
+
137
+
138
+ if __name__ == '__main__':
139
+ 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
@@ -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.0.26
4
+ Summary: Thinking-Machine does thinking.
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
@@ -49,7 +48,7 @@ cat multilogue.txt | thinking-machine
49
48
  ```
50
49
  Or:
51
50
  ```bash
52
- cat multilogue.txt | thinking-machine > multilogue.txt
51
+ cat multilogue.txt | thinking-machine > tmp && mv tmp multilogue.txt
53
52
  ```
54
53
  Or:
55
54
  ```bash
@@ -62,7 +61,7 @@ cat multilogue.txt new_turn.txt | thinking-machine
62
61
  ```
63
62
  Or:
64
63
  ```bash
65
- cat multilogue.txt new_turn.txt | thinking-machine > multilogue.txt
64
+ cat multilogue.txt new_turn.txt | thinking-machine > tmp && mv tmp multilogue.txt
66
65
  ```
67
66
  Or, if you have installed other machines:
68
67
  ```bash
@@ -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()