{"time": "2023-03-18T09:48:28.980274", "url": "https://dashboard.scale.com/spellbook/api/v2/deploy/", "input": "\n initial commit\n\ndiff --git a/lm/__init__.py b/lm/__init__.py\nnew file mode 100644\n--- /dev/null\n+++ b/lm/__init__.py\ndiff --git a/lm/__main__.py b/lm/__main__.py\nnew file mode 100644\n--- /dev/null\n+++ b/lm/__main__.py\n@@ -0,0 +1,44 @@\n+from .lm_spellbook import spellbook\n+\n+import argparse\n+import asyncio\n+import datetime\n+import json\n+import os\n+import sys\n+\n+async def main():\n+ timestamp = datetime.datetime.now().isoformat()\n+ parser = argparse.ArgumentParser()\n+ parser.add_argument('-l', '--logfile', type=argparse.FileType('w'), default=f'{timestamp}.json', help='Log file')\n+ parser.add_argument('-o', '--output', type=argparse.FileType('w'), default=sys.stdout, help='Output file')\n+ parser.add_argument('input_data', nargs='*', help='Input data or filename')\n+ args = parser.parse_args()\n+\n+ if len(args.input_data) == 1 and os.path.exists(args.input_data[0]):\n+ with open(args.input_data[1], 'r') as f:\n+ input_data = f.read()\n+ log_input(input_data, args.output)\n+ elif args.input_data:\n+ input_data = ' '.join(args.input_data)\n+ else:\n+ input_data = sys.stdin.read()\n+\n+ api = spellbook(\n+ api_key = 'clfcfnj7m003xti1a7hxt1739',\n+ app_id = 'sm43s5r'\n+ )\n+ async with api:\n+ response = await api(input_data)\n+\n+ json.dump({\n+ 'time': timestamp,\n+ 'url': api.url,\n+ 'input': input_data,\n+ 'output': response,\n+ }, args.logfile)\n+\n+ args.output.write(response)\n+\n+if __name__ == \"__main__\":\n+ asyncio.run(main())\ndiff --git a/lm/lm_spellbook.py b/lm/lm_spellbook.py\nnew file mode 100644\n--- /dev/null\n+++ b/lm/lm_spellbook.py\n@@ -0,0 +1,23 @@\n+import aiohttp\n+import json\n+import urllib.parse\n+\n+class spellbook(aiohttp.ClientSession):\n+ def __init__(self, api_key = 'clfcfnj7m003xti1a7hxt1739', app_id = 'sm43s5r', url = 'https://dashboard.scale.com/spellbook/api/v2/deploy/'):\n+ super().__init__()\n+ self.api_key = api_key\n+ self.app_id = app_id\n+ self.url = url\n+ async def __call__(self, input, **kwparams):\n+ kwparams['input'] = input\n+ headers = {\n+ 'Authorization': 'Basic ' + self.api_key,\n+ 'Content-Type': 'application/json',\n+ }\n+ data = {\n+ 'input': kwparams\n+ }\n+ url = urllib.parse.urljoin(self.url, self.app_id)\n+ async with self.post(url, data=json.dumps(data), headers=headers) as response:\n+ response_json = await response.json()\n+ return response_json.get('output', response_json)\ndiff --git a/setup.py b/setup.py\nnew file mode 100644\n--- /dev/null\n+++ b/setup.py\n@@ -0,0 +1,19 @@\n+from setuptools import setup, find_packages\n+\n+setup(\n+ name=\"lm\",\n+ version=\"0.0.1\",\n+ packages=find_packages(),\n+ install_requires=[],\n+ author=\"Your Name\",\n+ author_email=\"your.email@example.com\",\n+ description=\"lm\",\n+ long_description=open(\"README.md\").read(),\n+ long_description_content_type=\"text/markdown\",\n+ url=\"https://github.com/yourusername/lm\",\n+ classifiers=[\n+ \"Development Status :: 3 - Alpha\",\n+ \"License :: OSI Approved :: MIT License\",\n+ \"Programming Language :: Python :: 3\",\n+ ],\n+)\n\n changed license to agpl3 and added dependency on aiofiles 0.6.0\n\n", "output": "diff --git a/setup.py b/setup.py\nindex 9c7a1a1..6b8e2f2 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -9,7 +9,7 @@ setup(\n install_requires=[],\n author=\"Your Name\",\n author_email=\"your.email@example.com\",\n- description=\"lm\",\n+ description=\"lm with AGPLv3 license\",\n long_description=open(\"README.md\").read(),\n long_description_content_type=\"text/markdown\",\n url=\"https://github.com/yourusername/lm\",\n@@ -17,7 +17,7 @@ setup(\n \"Development Status :: 3 - Alpha\",\n- \"License :: OSI Approved :: MIT License\",\n+ \"License :: OSI Approved :: GNU Affero General Public License v3\",\n \"Programming Language :: Python :: 3\",\n ],\n+ install_requires=[\n+ \"aiofiles==0.6.0\",\n+ ],\n )"}