autonomous-app 0.3.48__py3-none-any.whl → 0.3.49__py3-none-any.whl
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.
- autonomous/__init__.py +1 -1
- autonomous/ai/models/local_model.py +74 -52
- autonomous/ai/models/mock_model.py +1 -9
- {autonomous_app-0.3.48.dist-info → autonomous_app-0.3.49.dist-info}/METADATA +1 -1
- {autonomous_app-0.3.48.dist-info → autonomous_app-0.3.49.dist-info}/RECORD +7 -7
- {autonomous_app-0.3.48.dist-info → autonomous_app-0.3.49.dist-info}/WHEEL +0 -0
- {autonomous_app-0.3.48.dist-info → autonomous_app-0.3.49.dist-info}/top_level.txt +0 -0
autonomous/__init__.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import random
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
|
+
from PIL import Image
|
|
7
8
|
from pydub import AudioSegment
|
|
8
9
|
|
|
9
10
|
from autonomous import log
|
|
@@ -119,7 +120,7 @@ class LocalAIModel(AutoModel):
|
|
|
119
120
|
},
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
log("==== LocalAI JSON Payload ====", payload, _print=True)
|
|
123
124
|
|
|
124
125
|
result_text = ""
|
|
125
126
|
try:
|
|
@@ -139,7 +140,7 @@ class LocalAIModel(AutoModel):
|
|
|
139
140
|
):
|
|
140
141
|
params = result_dict.pop("parameters")
|
|
141
142
|
result_dict.update(params)
|
|
142
|
-
|
|
143
|
+
log("==== LocalAI JSON Result ====", result_dict, _print=True)
|
|
143
144
|
return result_dict
|
|
144
145
|
|
|
145
146
|
except Exception as e:
|
|
@@ -242,64 +243,60 @@ class LocalAIModel(AutoModel):
|
|
|
242
243
|
log(f"TTS Error: {e}", _print=True)
|
|
243
244
|
return None
|
|
244
245
|
|
|
245
|
-
# ... inside LocalAIModel class ...
|
|
246
|
-
|
|
247
246
|
def _get_dimensions(self, aspect_ratio):
|
|
248
247
|
"""
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
Returns a tuple: ((base_w, base_h), (target_w, target_h))
|
|
249
|
+
|
|
250
|
+
1. base_*: The resolution sent to SDXL (approx 1024x1024).
|
|
251
|
+
2. target_*: The final resolution to resize/upscale to.
|
|
251
252
|
"""
|
|
252
|
-
|
|
253
|
+
# Standard SDXL buckets (approx 1MP)
|
|
254
|
+
# We use these for the initial generation to ensure good composition.
|
|
255
|
+
sdxl_base = {
|
|
253
256
|
"1:1": (1024, 1024),
|
|
254
|
-
"
|
|
255
|
-
"
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"3
|
|
265
|
-
|
|
257
|
+
"Portrait": (896, 1152), # 3:4
|
|
258
|
+
"Landscape": (1216, 832), # 3:2 or 16:9 approx
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
# The Logic: Define the target, map it to the closest SDXL base
|
|
262
|
+
# Format: "Key": ((Base_W, Base_H), (Target_W, Target_H))
|
|
263
|
+
resolutions = {
|
|
264
|
+
# Standard
|
|
265
|
+
"1:1": ((832, 832), (1024, 1024)),
|
|
266
|
+
"3:4": ((832, 1152), (1664, 2304)),
|
|
267
|
+
"4:3": ((1152, 832), (2304, 1664)),
|
|
268
|
+
# High Res (The logic changes here)
|
|
269
|
+
"16:9": ((1216, 832), (2048, 1152)),
|
|
270
|
+
"9:16": ((832, 1216), (1152, 2048)),
|
|
271
|
+
# 2K Tier
|
|
272
|
+
"2K": ((1216, 832), (2048, 1152)), # Base is 1216x832 -> Upscale to 2K
|
|
273
|
+
"2KPortrait": ((832, 1216), (1152, 2048)),
|
|
274
|
+
# 4K Tier (The generated image will be upscaled ~3x)
|
|
275
|
+
"4K": ((1216, 832), (3840, 2160)),
|
|
276
|
+
"4KPortrait": ((832, 1216), (2160, 3840)),
|
|
266
277
|
}
|
|
267
|
-
|
|
268
|
-
|
|
278
|
+
|
|
279
|
+
# Default to 1:1 if unknown
|
|
280
|
+
return resolutions.get(aspect_ratio, ((832, 832), (1024, 1024)))
|
|
269
281
|
|
|
270
282
|
def generate_image(
|
|
271
283
|
self, prompt, negative_prompt="", files=None, aspect_ratio="2KPortrait"
|
|
272
284
|
):
|
|
273
|
-
#
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
#
|
|
277
|
-
#
|
|
278
|
-
# "Keep visual elements and style. Under 50 words."
|
|
279
|
-
# )
|
|
280
|
-
# new_prompt = self.generate_text(
|
|
281
|
-
# message=prompt, additional_instructions=summary_instruction, context={}
|
|
282
|
-
# )
|
|
283
|
-
# if new_prompt and len(new_prompt) > 10:
|
|
284
|
-
# prompt = new_prompt
|
|
285
|
-
|
|
286
|
-
# 2. Resolution Calculation
|
|
287
|
-
width, height = self._get_dimensions(aspect_ratio)
|
|
288
|
-
|
|
289
|
-
# 3. Construct Payload
|
|
290
|
-
# We send both the abstract params (for logging/metadata)
|
|
291
|
-
# and the concrete pixels (for the engine).
|
|
285
|
+
# 1. Resolution Calculation
|
|
286
|
+
(base_w, base_h), (target_w, target_h) = self._get_dimensions(aspect_ratio)
|
|
287
|
+
|
|
288
|
+
# 2. Construct Base Generation Payload
|
|
289
|
+
# We tell the AI to generate the smaller, stable size first.
|
|
292
290
|
data = {
|
|
293
291
|
"prompt": prompt,
|
|
294
292
|
"negative_prompt": negative_prompt,
|
|
295
293
|
"aspect_ratio": aspect_ratio,
|
|
296
|
-
"width":
|
|
297
|
-
"height":
|
|
294
|
+
"width": base_w,
|
|
295
|
+
"height": base_h,
|
|
298
296
|
}
|
|
299
297
|
|
|
300
298
|
try:
|
|
301
|
-
# Handle Files (
|
|
302
|
-
# requests.post expects a list of tuples for multiple files with same key
|
|
299
|
+
# Handle Input Files (for Img2Img)
|
|
303
300
|
files_list = []
|
|
304
301
|
if files and isinstance(files, dict):
|
|
305
302
|
for fn, f_bytes in files.items():
|
|
@@ -307,20 +304,45 @@ class LocalAIModel(AutoModel):
|
|
|
307
304
|
file_obj = io.BytesIO(f_bytes)
|
|
308
305
|
else:
|
|
309
306
|
file_obj = f_bytes
|
|
310
|
-
# Appending to list instead of overwriting dict key
|
|
311
307
|
files_list.append(("files", (fn, file_obj, "image/png")))
|
|
312
308
|
|
|
313
|
-
#
|
|
309
|
+
# 3. Step 1: Generate Base Image
|
|
310
|
+
url = f"{self._media_url}/generate-image"
|
|
314
311
|
if files_list:
|
|
315
|
-
response = requests.post(
|
|
316
|
-
f"{self._media_url}/generate-image", data=data, files=files_list
|
|
317
|
-
)
|
|
312
|
+
response = requests.post(url, data=data, files=files_list)
|
|
318
313
|
else:
|
|
319
|
-
response = requests.post(
|
|
314
|
+
response = requests.post(url, data=data)
|
|
320
315
|
|
|
321
316
|
response.raise_for_status()
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
image_content = response.content
|
|
318
|
+
|
|
319
|
+
# 4. Step 2: Upscale (If necessary)
|
|
320
|
+
if (base_w, base_h) != (target_w, target_h):
|
|
321
|
+
log(
|
|
322
|
+
f"Requesting AI Upscale: {base_w}x{base_h} -> {target_w}x{target_h}...",
|
|
323
|
+
_print=True,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
# Prepare payload for the /upscale route
|
|
327
|
+
upscale_data = {
|
|
328
|
+
"prompt": prompt, # Reuse prompt to guide texture generation
|
|
329
|
+
"width": target_w, # Explicitly tell server the target size
|
|
330
|
+
"height": target_h,
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
# Send the image we just generated back to the server as a file
|
|
334
|
+
upscale_files = {
|
|
335
|
+
"file": ("generated.png", io.BytesIO(image_content), "image/png")
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
upscale_response = requests.post(
|
|
339
|
+
f"{self._media_url}/upscale", data=upscale_data, files=upscale_files
|
|
340
|
+
)
|
|
341
|
+
upscale_response.raise_for_status()
|
|
342
|
+
image_content = upscale_response.content
|
|
343
|
+
|
|
344
|
+
log("==== LocalAI Image Generation Complete ====", data, _print=True)
|
|
345
|
+
return image_content
|
|
324
346
|
|
|
325
347
|
except Exception as e:
|
|
326
348
|
log(f"Image Gen Error: {e}", _print=True)
|
|
@@ -38,15 +38,7 @@ class MockAIModel(AutoModel):
|
|
|
38
38
|
log(f"⚡ [MOCK] Generating JSON for prompt: {message[:50]}...", _print=True)
|
|
39
39
|
|
|
40
40
|
# 1. Default Mock Object
|
|
41
|
-
mock_response = {
|
|
42
|
-
"name": "The Mockingbird Tavern",
|
|
43
|
-
"description": "A glitchy, holographic tavern that only exists in offline mode. The ale tastes like static.",
|
|
44
|
-
"backstory": "Created by a developer at 30,000 feet, this tavern serves as a placeholder for real content. It was built on the ruins of a NullReferenceException.",
|
|
45
|
-
"appearance": "Wireframe walls with textures that haven't loaded yet.",
|
|
46
|
-
"secrets": "If you look closely at the bartender, you can see he is just a looping IF statement.",
|
|
47
|
-
"tags": ["offline", "dev-mode", "test"],
|
|
48
|
-
"type": "Location",
|
|
49
|
-
}
|
|
41
|
+
mock_response = {}
|
|
50
42
|
|
|
51
43
|
# 2. Heuristic: If the user provided a context with 'name', use it.
|
|
52
44
|
# This makes the mock feel slightly responsive.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: autonomous-app
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.49
|
|
4
4
|
Summary: Containerized application framework built on Flask with additional libraries and tools for rapid development of web applications.
|
|
5
5
|
Author-email: Steven A Moore <samoore@binghamton.edu>
|
|
6
6
|
Project-URL: homepage, https://github.com/Sallenmoore/autonomous
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
autonomous/__init__.py,sha256=
|
|
1
|
+
autonomous/__init__.py,sha256=XGXFrTg7DO3ttlW08eI9G75X0y7yM3h6ZXxAj2KCRpY,95
|
|
2
2
|
autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
|
|
3
3
|
autonomous/logger.py,sha256=NQtgEaTWNAWfLSgqSP7ksXj1GpOuCgoUV711kSMm-WA,2022
|
|
4
4
|
autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -9,8 +9,8 @@ autonomous/ai/jsonagent.py,sha256=NpF-bJXolTBeW9xVdeEfdNwzdlaaRMjFwo_s-d9ApLM,11
|
|
|
9
9
|
autonomous/ai/textagent.py,sha256=0y2Hvb9pup1OnsA51hGPcD8yllZOZtztDLQvCNYABaw,1043
|
|
10
10
|
autonomous/ai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
autonomous/ai/models/gemini.py,sha256=JtMw1RatDuTtDaVe5sp_t-nOdWbGvJzljWHhNh9o3yk,13107
|
|
12
|
-
autonomous/ai/models/local_model.py,sha256
|
|
13
|
-
autonomous/ai/models/mock_model.py,sha256=
|
|
12
|
+
autonomous/ai/models/local_model.py,sha256=2LN_ZU6AI-Od9_glNTfGyc5k0iLGOkAV_9PftFeZdd8,13057
|
|
13
|
+
autonomous/ai/models/mock_model.py,sha256=IT4ip821ZewDOFbHrAFJ3Ks_OUIN-Z0lEF6oGs5j4WU,3061
|
|
14
14
|
autonomous/apis/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
|
|
15
15
|
autonomous/apis/version_control/GHOrganization.py,sha256=mi2livdsGurKiifbvuLwiFbdDzL77IlEfhwEa-tG77I,1155
|
|
16
16
|
autonomous/apis/version_control/GHRepo.py,sha256=hTFHMkxSbSlVELfh8S6mq6ijkIKPRQO-Q5775ZjRKD4,4622
|
|
@@ -56,7 +56,7 @@ autonomous/taskrunner/__init__.py,sha256=ughX-QfWBas5W3aB2SiF887SWJ3Dzc2X43Yxtmp
|
|
|
56
56
|
autonomous/taskrunner/autotasks.py,sha256=2zRaqHYqfdlgC_BQm6B6D2svN1ukyWeJJHwweZFHVoo,2616
|
|
57
57
|
autonomous/taskrunner/task_router.py,sha256=W09HtRUuhwlnGxM5w4l6Hzw6mfS6L4ljWiMzD3ZVFeU,601
|
|
58
58
|
autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
|
|
59
|
-
autonomous_app-0.3.
|
|
60
|
-
autonomous_app-0.3.
|
|
61
|
-
autonomous_app-0.3.
|
|
62
|
-
autonomous_app-0.3.
|
|
59
|
+
autonomous_app-0.3.49.dist-info/METADATA,sha256=71ctrlODRH8BeFdFWduyRHV8Qj2ROSvFYyHk_QJfIaY,3024
|
|
60
|
+
autonomous_app-0.3.49.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
61
|
+
autonomous_app-0.3.49.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
|
|
62
|
+
autonomous_app-0.3.49.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|