summarizing-machine 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.
- summarizing_machine-0.0.1/LICENSE +21 -0
- summarizing_machine-0.0.1/MANIFEST.in +1 -0
- summarizing_machine-0.0.1/PKG-INFO +77 -0
- summarizing_machine-0.0.1/README.md +60 -0
- summarizing_machine-0.0.1/pyproject.toml +33 -0
- summarizing_machine-0.0.1/setup.cfg +4 -0
- summarizing_machine-0.0.1/src/summarizing_machine/__init__.py +20 -0
- summarizing_machine-0.0.1/src/summarizing_machine/cli.py +96 -0
- summarizing_machine-0.0.1/src/summarizing_machine/config.py +23 -0
- summarizing_machine-0.0.1/src/summarizing_machine/githf.py +69 -0
- summarizing_machine-0.0.1/src/summarizing_machine/machina.yaml +7 -0
- summarizing_machine-0.0.1/src/summarizing_machine/machine.py +177 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/__init__.py +7 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/camelids.py +87 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/castor_pollux.py +127 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/depsek.py +81 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/electroid.py +78 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/openai.py +82 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/qrog.py +82 -0
- summarizing_machine-0.0.1/src/summarizing_machine/providers/strangelove.py +81 -0
- summarizing_machine-0.0.1/src/summarizing_machine/utilities.py +418 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/PKG-INFO +77 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/SOURCES.txt +29 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/dependency_links.txt +1 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/entry_points.txt +2 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/requires.txt +2 -0
- summarizing_machine-0.0.1/src/summarizing_machine.egg-info/top_level.txt +1 -0
- summarizing_machine-0.0.1/tests/test_cli.py +20 -0
- summarizing_machine-0.0.1/tests/test_e2e.py +45 -0
- summarizing_machine-0.0.1/tests/test_llm_soup.py +71 -0
- summarizing_machine-0.0.1/tests/test_utilities.py +69 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Alexander Fedotov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include src/summarizing_machine/*.yaml
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: summarizing-machine
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Machine that summarizes texts.
|
|
5
|
+
Author-email: Machina Ratiocinatrix <machina.ratio@gmail.com>, Alexander Fedotov <alex.fedotov@aol.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/summarizing-machine/summarizing-machine
|
|
7
|
+
Keywords: summarizing-machine
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: pyyaml==6.0.3
|
|
15
|
+
Requires-Dist: click==8.3.1
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# Summarizing-Machine
|
|
19
|
+
A Machine that summarizes texts.
|
|
20
|
+
|
|
21
|
+
In order to launch it from the command line or as a Python subprocess:
|
|
22
|
+
```bash
|
|
23
|
+
echo "Theodotos-Alexandreus: Are language models seeking the Truth, machine?" \
|
|
24
|
+
| uvx summarizing-machine \
|
|
25
|
+
--provider-api-key=sk-proj-... \
|
|
26
|
+
--github-token=ghp_...
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or, with a local pip installation:
|
|
30
|
+
```bash
|
|
31
|
+
pip install summarizing-machine
|
|
32
|
+
```
|
|
33
|
+
Set the environment variables:
|
|
34
|
+
```bash
|
|
35
|
+
export PROVIDER_API_KEY="sk-proj-..."
|
|
36
|
+
export GITHUB_TOKEN="ghp_..."
|
|
37
|
+
```
|
|
38
|
+
Then:
|
|
39
|
+
```bash
|
|
40
|
+
summarizing-machine multilogue.txt
|
|
41
|
+
```
|
|
42
|
+
Or:
|
|
43
|
+
```bash
|
|
44
|
+
summarizing-machine multilogue.txt new_turn.txt
|
|
45
|
+
```
|
|
46
|
+
Or:
|
|
47
|
+
```bash
|
|
48
|
+
cat multilogue.txt | summarizing-machine
|
|
49
|
+
```
|
|
50
|
+
Or:
|
|
51
|
+
```bash
|
|
52
|
+
cat multilogue.txt | summarizing-machine > multilogue.txt
|
|
53
|
+
```
|
|
54
|
+
Or:
|
|
55
|
+
```bash
|
|
56
|
+
(cat multilogue.txt; echo:"Theodotos: What do you think, Summarizing-Machine?") \
|
|
57
|
+
| summarizing-machine
|
|
58
|
+
```
|
|
59
|
+
Or:
|
|
60
|
+
```bash
|
|
61
|
+
cat multilogue.txt new_turn.txt | summarizing-machine
|
|
62
|
+
```
|
|
63
|
+
Or:
|
|
64
|
+
```bash
|
|
65
|
+
cat multilogue.txt new_turn.txt | summarizing-machine > multilogue.txt
|
|
66
|
+
```
|
|
67
|
+
Or, if you have installed other machines:
|
|
68
|
+
```bash
|
|
69
|
+
cat multilogue.md | summarizing-machine \
|
|
70
|
+
| summarizing-machine | judging-machine > summary_judgment.md
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Or use it in your Python code:
|
|
74
|
+
```Python
|
|
75
|
+
# Python
|
|
76
|
+
import thinking_machine
|
|
77
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Summarizing-Machine
|
|
2
|
+
A Machine that summarizes texts.
|
|
3
|
+
|
|
4
|
+
In order to launch it from the command line or as a Python subprocess:
|
|
5
|
+
```bash
|
|
6
|
+
echo "Theodotos-Alexandreus: Are language models seeking the Truth, machine?" \
|
|
7
|
+
| uvx summarizing-machine \
|
|
8
|
+
--provider-api-key=sk-proj-... \
|
|
9
|
+
--github-token=ghp_...
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or, with a local pip installation:
|
|
13
|
+
```bash
|
|
14
|
+
pip install summarizing-machine
|
|
15
|
+
```
|
|
16
|
+
Set the environment variables:
|
|
17
|
+
```bash
|
|
18
|
+
export PROVIDER_API_KEY="sk-proj-..."
|
|
19
|
+
export GITHUB_TOKEN="ghp_..."
|
|
20
|
+
```
|
|
21
|
+
Then:
|
|
22
|
+
```bash
|
|
23
|
+
summarizing-machine multilogue.txt
|
|
24
|
+
```
|
|
25
|
+
Or:
|
|
26
|
+
```bash
|
|
27
|
+
summarizing-machine multilogue.txt new_turn.txt
|
|
28
|
+
```
|
|
29
|
+
Or:
|
|
30
|
+
```bash
|
|
31
|
+
cat multilogue.txt | summarizing-machine
|
|
32
|
+
```
|
|
33
|
+
Or:
|
|
34
|
+
```bash
|
|
35
|
+
cat multilogue.txt | summarizing-machine > multilogue.txt
|
|
36
|
+
```
|
|
37
|
+
Or:
|
|
38
|
+
```bash
|
|
39
|
+
(cat multilogue.txt; echo:"Theodotos: What do you think, Summarizing-Machine?") \
|
|
40
|
+
| summarizing-machine
|
|
41
|
+
```
|
|
42
|
+
Or:
|
|
43
|
+
```bash
|
|
44
|
+
cat multilogue.txt new_turn.txt | summarizing-machine
|
|
45
|
+
```
|
|
46
|
+
Or:
|
|
47
|
+
```bash
|
|
48
|
+
cat multilogue.txt new_turn.txt | summarizing-machine > multilogue.txt
|
|
49
|
+
```
|
|
50
|
+
Or, if you have installed other machines:
|
|
51
|
+
```bash
|
|
52
|
+
cat multilogue.md | summarizing-machine \
|
|
53
|
+
| summarizing-machine | judging-machine > summary_judgment.md
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or use it in your Python code:
|
|
57
|
+
```Python
|
|
58
|
+
# Python
|
|
59
|
+
import thinking_machine
|
|
60
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools==82.0.1"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "summarizing-machine"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{name="Machina Ratiocinatrix", email="machina.ratio@gmail.com"},
|
|
10
|
+
{name="Alexander Fedotov", email="alex.fedotov@aol.com"}
|
|
11
|
+
]
|
|
12
|
+
description = "A Machine that summarizes texts."
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
classifiers=[
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
]
|
|
20
|
+
keywords = ["summarizing-machine"]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"pyyaml == 6.0.3",
|
|
23
|
+
"click == 8.3.1"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
summarizing-machine = "summarizing_machine.cli:run"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Homepage" = "https://github.com/summarizing-machine/summarizing-machine"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = ["pytest>=8.0.0"]
|
|
@@ -0,0 +1,20 @@
|
|
|
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 .config import Config
|
|
9
|
+
from .machine import machine
|
|
10
|
+
from .githf import fetch_instructions
|
|
11
|
+
from .utilities import (plato_text_to_muj,
|
|
12
|
+
plato_text_to_mpuj,
|
|
13
|
+
llm_soup_to_text,
|
|
14
|
+
new_plato_text)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'machine',
|
|
18
|
+
'fetch_instructions',
|
|
19
|
+
'Config'
|
|
20
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
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 | summarizing-machine # Accepts text from the pipe
|
|
31
|
+
$ echo "...<text>..." | summarizing-machine #
|
|
32
|
+
|
|
33
|
+
$ summarizing-machine multilogue.txt new_turn.txt # ...or 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()
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
from dataclasses import dataclass, field
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class Config:
|
|
14
|
+
github_token: str = field(default_factory=lambda: environ.get('GITHUB_TOKEN', ''))
|
|
15
|
+
github_name: str = field(default_factory=lambda: environ.get('GITHUB_NAME', ''))
|
|
16
|
+
github_email: str = field(default_factory=lambda: environ.get('GITHUB_EMAIL', ''))
|
|
17
|
+
provider_api_key: str = field(default_factory=lambda: environ.get('PROVIDER_API_KEY', ''))
|
|
18
|
+
provider: str = field(default_factory=lambda: environ.get('PROVIDER', ''))
|
|
19
|
+
machine_organization_name: str = field(default_factory=lambda: environ.get('MACHINE_ORGANIZATION_NAME', 'summarizing-machine'))
|
|
20
|
+
private_repo_with_text: str = field(default_factory=lambda: environ.get('PRIVATE_REPO_WITH_TEXT','summarizing_machine'))
|
|
21
|
+
system_prompt_file: str = field(default_factory=lambda: environ.get('SYSTEM_PROMPT_FILE', 'machina.yaml'))
|
|
22
|
+
name: str = ''
|
|
23
|
+
instructions: str = ''
|
|
@@ -0,0 +1,69 @@
|
|
|
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 sys
|
|
9
|
+
from os import path
|
|
10
|
+
import yaml
|
|
11
|
+
import urllib.request
|
|
12
|
+
import urllib.error
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def download_github_file(owner, repo, file_path, token):
|
|
16
|
+
"""
|
|
17
|
+
Downloads a file from a GitHub repository using the GitHub REST API.
|
|
18
|
+
We request the raw content by using the 'application/vnd.github.v3.raw' accept header.
|
|
19
|
+
"""
|
|
20
|
+
url = f"https://api.github.com/repos/{owner}/{repo}/contents/{file_path}"
|
|
21
|
+
|
|
22
|
+
headers = {
|
|
23
|
+
"Authorization": f"token {token}",
|
|
24
|
+
"Accept": "application/vnd.github.v3.raw",
|
|
25
|
+
"User-Agent": "Summarizing-Machine"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
req = urllib.request.Request(url, headers=headers)
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
with urllib.request.urlopen(req, timeout=10) as response:
|
|
32
|
+
return response.read()
|
|
33
|
+
except urllib.error.HTTPError as e:
|
|
34
|
+
print(f"HTTP Error {e.code}: {e.reason}")
|
|
35
|
+
error_info = e.read().decode('utf-8')
|
|
36
|
+
print(f"Details: {error_info}")
|
|
37
|
+
return None
|
|
38
|
+
except urllib.error.URLError as e:
|
|
39
|
+
print(f"URL Error: {e.reason}")
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def fetch_instructions(config):
|
|
44
|
+
"""Retrieve the system prompt from a private GitHub repo.
|
|
45
|
+
Falls back to the local machina.yaml if GitHub is unreachable.
|
|
46
|
+
Returns the 'name' of the Machine in dashed format.
|
|
47
|
+
Returns the 'description' field from the YAML as the system prompt string.
|
|
48
|
+
"""
|
|
49
|
+
try:
|
|
50
|
+
raw_yaml = download_github_file(
|
|
51
|
+
owner=config.machine_organization_name,
|
|
52
|
+
repo=config.private_repo_with_text,
|
|
53
|
+
file_path=config.system_prompt_file,
|
|
54
|
+
token=config.github_token
|
|
55
|
+
)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f"Warning: could not fetch the instructions from GitHub: {e}",
|
|
58
|
+
file=sys.stderr)
|
|
59
|
+
local_path = path.join(path.dirname(__file__), 'machina.yaml')
|
|
60
|
+
with open(local_path, 'r') as f:
|
|
61
|
+
raw_yaml = f.read()
|
|
62
|
+
|
|
63
|
+
# Parse
|
|
64
|
+
parsed = yaml.safe_load(raw_yaml)
|
|
65
|
+
name = parsed.get('name')
|
|
66
|
+
config.name = name
|
|
67
|
+
instructions = parsed.get('description', 'You are a helpful assistant.')
|
|
68
|
+
config.instructions = instructions
|
|
69
|
+
return name, instructions
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Copyright (c) Alexander Fedotov, 2026. All rights reserved.
|
|
2
|
+
name: Summarizing-Machine
|
|
3
|
+
description: The Assistant is Summarizing-Machine. Summarizing-Machine does its best to understand
|
|
4
|
+
the conversation that it is participating in and answers in a most thoughtful way possible
|
|
5
|
+
the questions that it is being asked.
|
|
6
|
+
Summarizing-Machine responds in plain text without any markdown, emphasis or lists. All
|
|
7
|
+
paragraphs except the first should begin with a newline and tab.
|
|
@@ -0,0 +1,177 @@
|
|
|
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 sys
|
|
9
|
+
from os import environ, path
|
|
10
|
+
from .githf import fetch_instructions
|
|
11
|
+
from .utilities import (plato_text_to_muj,
|
|
12
|
+
plato_text_to_mpuj,
|
|
13
|
+
plato_text_to_cmj,
|
|
14
|
+
llm_soup_to_text)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def machine(plato_text, config, **kwargs):
|
|
18
|
+
"""Core agent logic.
|
|
19
|
+
|
|
20
|
+
1. Fetches the system prompt from a private GitHub repo.
|
|
21
|
+
2. Calls Provider
|
|
22
|
+
3. Returns a (thoughts, text) tuple.
|
|
23
|
+
"""
|
|
24
|
+
# Fetch the confidential system prompt, name is for a checkup.
|
|
25
|
+
name, system_prompt = fetch_instructions(config)
|
|
26
|
+
|
|
27
|
+
# Load an appropriate library and query the API.
|
|
28
|
+
provider = config.provider
|
|
29
|
+
api_key = config.provider_api_key
|
|
30
|
+
|
|
31
|
+
if provider == 'OpenAI':
|
|
32
|
+
# Transform plato_text to MUJ format
|
|
33
|
+
messages = plato_text_to_muj(plato_text=plato_text,
|
|
34
|
+
machine_name=name)
|
|
35
|
+
# Call OpenAI API via opehaina
|
|
36
|
+
environ['OPENAI_API_KEY'] = api_key
|
|
37
|
+
try:
|
|
38
|
+
from .providers import openai
|
|
39
|
+
except ImportError:
|
|
40
|
+
print("openai module is missing.", file=sys.stderr)
|
|
41
|
+
sys.exit(1)
|
|
42
|
+
|
|
43
|
+
thoughts, text = openai.respond(
|
|
44
|
+
messages=messages,
|
|
45
|
+
instructions=system_prompt,
|
|
46
|
+
**kwargs
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
thoughts = llm_soup_to_text(thoughts)
|
|
50
|
+
return thoughts, text
|
|
51
|
+
|
|
52
|
+
elif provider == 'Gemini':
|
|
53
|
+
# Transform plato_text to MPUJ format
|
|
54
|
+
messages = plato_text_to_mpuj(plato_text=plato_text,
|
|
55
|
+
machine_name=name)
|
|
56
|
+
# Call Gemini through castor-polux
|
|
57
|
+
environ['GEMINI_API_KEY'] = api_key
|
|
58
|
+
try:
|
|
59
|
+
from .providers import castor_pollux
|
|
60
|
+
except ImportError:
|
|
61
|
+
print("No module castor-pollux", file=sys.stderr)
|
|
62
|
+
sys.exit(1)
|
|
63
|
+
|
|
64
|
+
thoughts, text = castor_pollux.respond(
|
|
65
|
+
messages=messages,
|
|
66
|
+
instructions=system_prompt,
|
|
67
|
+
**kwargs
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
thoughts = llm_soup_to_text(thoughts)
|
|
71
|
+
return thoughts, text
|
|
72
|
+
|
|
73
|
+
elif provider == 'Anthropic':
|
|
74
|
+
# Transform plato_text to MUJ format
|
|
75
|
+
messages = plato_text_to_muj(plato_text=plato_text,
|
|
76
|
+
machine_name=name)
|
|
77
|
+
|
|
78
|
+
# Call the Anthropic API via electroid
|
|
79
|
+
environ['ANTHROPIC_API_KEY'] = api_key
|
|
80
|
+
try:
|
|
81
|
+
from .providers import electroid
|
|
82
|
+
except ImportError:
|
|
83
|
+
print("no electroid module", file=sys.stderr)
|
|
84
|
+
sys.exit(1)
|
|
85
|
+
|
|
86
|
+
text, thoughts = electroid.respond(
|
|
87
|
+
messages=messages,
|
|
88
|
+
instructions=system_prompt,
|
|
89
|
+
**kwargs
|
|
90
|
+
)
|
|
91
|
+
return text, thoughts
|
|
92
|
+
|
|
93
|
+
elif provider == 'Groq':
|
|
94
|
+
# Transform plato_text to MUJ format
|
|
95
|
+
messages = plato_text_to_muj(plato_text=plato_text,
|
|
96
|
+
machine_name=name)
|
|
97
|
+
# Call OpenAI API via opehaina
|
|
98
|
+
environ['GROQ_API_KEY'] = api_key
|
|
99
|
+
try:
|
|
100
|
+
from .providers import qrog
|
|
101
|
+
except ImportError:
|
|
102
|
+
print("openai module is missing.", file=sys.stderr)
|
|
103
|
+
sys.exit(1)
|
|
104
|
+
|
|
105
|
+
thoughts, text = qrog.respond(
|
|
106
|
+
messages=messages,
|
|
107
|
+
instructions=system_prompt,
|
|
108
|
+
**kwargs
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
thoughts = llm_soup_to_text(thoughts)
|
|
112
|
+
return thoughts, text
|
|
113
|
+
|
|
114
|
+
elif provider == 'Xai':
|
|
115
|
+
# Transform plato_text to MUJ format
|
|
116
|
+
messages = plato_text_to_muj(plato_text=plato_text,
|
|
117
|
+
machine_name=name)
|
|
118
|
+
# Call OpenAI API via opehaina
|
|
119
|
+
environ['XAI_API_KEY'] = api_key
|
|
120
|
+
try:
|
|
121
|
+
from .providers import strangelove
|
|
122
|
+
except ImportError:
|
|
123
|
+
print("openai module is missing.", file=sys.stderr)
|
|
124
|
+
sys.exit(1)
|
|
125
|
+
|
|
126
|
+
thoughts, text = strangelove.respond(
|
|
127
|
+
messages=messages,
|
|
128
|
+
instructions=system_prompt,
|
|
129
|
+
**kwargs
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
thoughts = llm_soup_to_text(thoughts)
|
|
133
|
+
return thoughts, text
|
|
134
|
+
|
|
135
|
+
elif provider == 'DepSek':
|
|
136
|
+
# Transform plato_text to CMJ format
|
|
137
|
+
messages = plato_text_to_cmj(plato_text=plato_text,
|
|
138
|
+
machine_name=name)
|
|
139
|
+
# Call OpenAI API via opehaina
|
|
140
|
+
environ['DEPSEK_API_KEY'] = api_key
|
|
141
|
+
try:
|
|
142
|
+
from .providers import depsek
|
|
143
|
+
except ImportError:
|
|
144
|
+
print("openai module is missing.", file=sys.stderr)
|
|
145
|
+
sys.exit(1)
|
|
146
|
+
|
|
147
|
+
thoughts, text = depsek.respond(
|
|
148
|
+
messages=messages,
|
|
149
|
+
instructions=system_prompt,
|
|
150
|
+
**kwargs
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return thoughts, text
|
|
154
|
+
|
|
155
|
+
elif provider == 'Meta':
|
|
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['META_API_KEY'] = api_key
|
|
161
|
+
try:
|
|
162
|
+
from .providers import camelids
|
|
163
|
+
except ImportError:
|
|
164
|
+
print("openai module is missing.", file=sys.stderr)
|
|
165
|
+
sys.exit(1)
|
|
166
|
+
|
|
167
|
+
thoughts, text = camelids.respond(
|
|
168
|
+
messages=messages,
|
|
169
|
+
instructions=system_prompt,
|
|
170
|
+
**kwargs
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
return thoughts, text
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
if __name__ == '__main__':
|
|
177
|
+
print('You have launched main')
|