asp-chef-cli 0.5.0__tar.gz → 0.5.2__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.
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/PKG-INFO +2 -1
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/cli.py +5 -1
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/routers/dumbo.py +41 -2
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/pyproject.toml +2 -1
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/LICENSE +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/README.md +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/__init__.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/__main__.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/__init__.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/dependencies.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/main.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/routers/__init__.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/routers/clingo.py +0 -0
- {asp_chef_cli-0.5.0 → asp_chef_cli-0.5.2}/asp_chef_cli/server/routers/opa.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: asp-chef-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
4
4
|
Summary: A simple CLI to run ASP Chef recipes
|
|
5
5
|
Author: Mario Alviano
|
|
6
6
|
Author-email: mario.alviano@gmail.com
|
|
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.13
|
|
10
10
|
Requires-Dist: dumbo-asp (>=0.4.0,<0.5.0)
|
|
11
11
|
Requires-Dist: fastapi (>=0.129.0,<0.130.0)
|
|
12
|
+
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
12
13
|
Requires-Dist: opa-python (>=0.0.9,<0.0.10)
|
|
13
14
|
Requires-Dist: pytest-playwright (>=0.7.2,<0.8.0)
|
|
14
15
|
Requires-Dist: uvicorn (>=0.40.0,<0.41.0)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import fileinput
|
|
3
|
+
import os
|
|
3
4
|
from enum import Enum
|
|
4
5
|
from typing import Optional
|
|
5
6
|
|
|
@@ -174,9 +175,12 @@ def command_server(
|
|
|
174
175
|
port: int = typer.Option(8000, "--port", "-p",
|
|
175
176
|
help="An available port to listen for incoming requests"),
|
|
176
177
|
reload: bool = typer.Option(False, "--reload",
|
|
177
|
-
help="Reload server if source code changes (for development)")
|
|
178
|
+
help="Reload server if source code changes (for development)"),
|
|
179
|
+
ollama_port: int = typer.Option(11434, "--ollama-port",
|
|
180
|
+
help="Port where Ollama is listening (for Ollama integration)"),
|
|
178
181
|
) -> None:
|
|
179
182
|
"""
|
|
180
183
|
Run a server for @dumbo/* operations.
|
|
181
184
|
"""
|
|
185
|
+
os.environ["ASP_CHEF_CLI__OLLAMA_URL"] = f"http://127.0.0.1:{ollama_port}"
|
|
182
186
|
uvicorn.run("asp_chef_cli.server.main:app", host=host, port=port, reload=reload)
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import json as json_module
|
|
2
|
+
import os
|
|
2
3
|
import shutil
|
|
3
4
|
import subprocess
|
|
4
5
|
from collections import defaultdict
|
|
6
|
+
from typing import Optional, Dict, Final
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
5
9
|
from dumbo_asp.primitives.models import Model
|
|
6
10
|
from dumbo_asp.primitives.rules import SymbolicRule
|
|
7
11
|
from dumbo_asp.primitives.templates import Template
|
|
8
12
|
from dumbo_asp.queries import explanation_graph, pack_xasp_navigator_url
|
|
9
|
-
from fastapi import APIRouter
|
|
10
|
-
from
|
|
13
|
+
from fastapi import APIRouter, Response
|
|
14
|
+
from fastapi.responses import StreamingResponse
|
|
11
15
|
|
|
12
16
|
from ..dependencies import *
|
|
13
17
|
|
|
@@ -265,3 +269,38 @@ async def _(json):
|
|
|
265
269
|
})
|
|
266
270
|
|
|
267
271
|
return res
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
OLLAMA_URL = os.getenv("ASP_CHEF_CLI__OLLAMA_URL", "http://127.0.0.1:11434")
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@router.api_route("/ollama/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
|
|
278
|
+
async def ollama_proxy(path: str, request: Request):
|
|
279
|
+
url = f"{OLLAMA_URL}/{path.lstrip('/')}"
|
|
280
|
+
method = request.method
|
|
281
|
+
params = request.query_params
|
|
282
|
+
|
|
283
|
+
body = await request.body()
|
|
284
|
+
headers = dict(request.headers)
|
|
285
|
+
headers.pop("host", None)
|
|
286
|
+
headers.pop("content-length", None) # Let httpx recalculate it
|
|
287
|
+
|
|
288
|
+
async def generate_stream():
|
|
289
|
+
async with httpx.AsyncClient(timeout=None) as client:
|
|
290
|
+
async with client.stream(
|
|
291
|
+
method=method,
|
|
292
|
+
url=url,
|
|
293
|
+
params=params,
|
|
294
|
+
headers=headers,
|
|
295
|
+
content=body,
|
|
296
|
+
) as rp_resp:
|
|
297
|
+
async for chunk in rp_resp.aiter_bytes():
|
|
298
|
+
yield chunk
|
|
299
|
+
|
|
300
|
+
try:
|
|
301
|
+
return StreamingResponse(
|
|
302
|
+
generate_stream(),
|
|
303
|
+
media_type="application/octet-stream"
|
|
304
|
+
)
|
|
305
|
+
except httpx.ConnectError:
|
|
306
|
+
return Response(content="Ollama not running", status_code=503)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "asp-chef-cli"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.2"
|
|
4
4
|
description = "A simple CLI to run ASP Chef recipes"
|
|
5
5
|
authors = ["Mario Alviano <mario.alviano@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -12,6 +12,7 @@ dumbo-asp = "^0.4.0"
|
|
|
12
12
|
uvicorn = "^0.40.0"
|
|
13
13
|
fastapi = "^0.129.0"
|
|
14
14
|
opa-python = "^0.0.9"
|
|
15
|
+
httpx = "^0.28.1"
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
[build-system]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|