Skip to content

Commit

Permalink
[python] support running chainlit apps
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Sep 26, 2024
1 parent 9d0ed1d commit a1c298a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.7.8

- Add support to run chainlit applications

## 2.7.7

- Throw errors in `complete()` when tool fails to allow proper handling
Expand Down
3 changes: 2 additions & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
storage/
storage/
.chainlit
2 changes: 1 addition & 1 deletion python/hal9/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create(path :str, template :str):
@click.argument('path')
@click.option('--source', default=None, help='Main source file')
@click.option('--runtime', default=None, help='Runtime to use')
@click.option('--port', default=None, help='Port to use, optional')
@click.option('--port', default="8080", help='Port to use, optional')
def run(path :str, source :str = "app.py", runtime :str = "type", port :str = "8080"):
"""
Run Project
Expand Down
2 changes: 2 additions & 0 deletions python/hal9/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

from hal9.runtimes.image import run as run_image
from hal9.runtimes.python import run as run_python
from hal9.runtimes.chainlit import run as run_chainlit

runtime_types = {
"python": run_python,
"image": run_image,
"jpg": run_image,
"png": run_image,
"chainlit": run_chainlit,
}

def run(path :str, source :str = "app.py", runtime :str = "python", port :str = "8080") -> str:
Expand Down
10 changes: 10 additions & 0 deletions python/hal9/runtimes/chainlit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import subprocess
from pathlib import Path
import time

def run(source_path: Path, port :str):
command = ['chainlit', 'run', '-h', '--port', port, source_path]
print(command)

with subprocess.Popen(command) as proc:
proc.wait()
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hal9"
version = "2.7.7"
version = "2.7.8"
description = ""
authors = ["Javier Luraschi <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit a1c298a

Please sign in to comment.