Skip to content

Commit

Permalink
cli entries for create run deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed May 10, 2024
1 parent 8a4a355 commit 466ec4e
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 99 deletions.
13 changes: 0 additions & 13 deletions .githooks/pre-commit

This file was deleted.

29 changes: 0 additions & 29 deletions .vscode/launch.json

This file was deleted.

48 changes: 34 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Hal9: Create and Deploy GenAI Chatbots
# Hal9: Create and Share Generative Apps

[![Hal9 PyPi Downloads](https://img.shields.io/pypi/dm/hal9?label=PyPI)](https://pypi.org/project/hal9/)

Create and deploy Large Language Model (LLM) chatbots in seconds.
- **Open:** Use any LLM like OpenAI, LLama, Gemini, Groq, etc. and open libraries like LangChain.
- **Intuitive:** No need to learn a chat framework, simply use stdin and stdout.
- **Scalable:** Engineers can esily integrate your chatbot with Docker or use Hal9's self-service enterprise cloud.
Create and deploy generative (LLMs and [difussers](https://github.com/huggingface/diffusers)) applications (chatbots and APIs) in seconds.
- **Open:** Use any model (OpenAI, Llama, Groq, Midjourney) and any library like (LangChainl, DSPy).
- **Intuitive:** No need to learn an app framework (streamlit, flask), simply use stdin and stdout.
- **Scalable:** Engineers can esily integrate your app with Docker or use Hal9's self-service enterprise cloud.

Focus on AI (RAG, fine-tuning, aligment, training) and skip engineering tasks (frontend development, backend integration, deployment, operations).

## Getting started

Expand All @@ -14,22 +16,25 @@ To create and deploy a chatbot in 10 seconds run the following:
```bash
pip install hal9

hal9 create my-project
hal9 deploy my-project
hal9 create chatbot
hal9 deploy chatbot
```

To customize, read the following sections.
To customize further, read the following sections.

## Creation

By default `hal9 create` we will use OpenAI, you can choose your template as follows:
By default `hal9 create` we will use the OpenAI template, you can choose different ones as follows:

```bash
hal9 create my-project --template openai
hal9 create my-project --template midjourney
hal9 create my-project --template groq
hal9 create my-project --template langchain
```

A template provides ready to use code with specific technologies and use cases. If you already have code, you can skip this step.

Send a PR if you want to add additional templates.

## Development
Expand All @@ -44,20 +49,29 @@ cd my-project
pip install -r requirements.txt

export OPENAI_KEY=YOUR_OPENAI_KEY
python app.py
```

If you customized your template with `--template` make sure to set the correct key, for example `export GROQ_KEY=YOUR_GROQ_KEY`.

## Runtime

Run your application as follows,

```python
python app.py
```

Use the command line tool to enter prompts, type `<enter>` twice to send the prompt to your code. Replies will be streamed back to console.

We decided to use a simple chat interface to help AI teams focus what matters: Retrieval Augmented Generation (RAG) workflows. The interactivity and backend can be left to the engineering team or services like Hal9.
From the parent folder, you can also run your application as follows:

```bash
hal9 run my-project
```

## Deployment

We currently support Docker and Hal9 Cloud, but community can send PR's with additional technologies or providers.
We currently support Docker and `hal9.com`. Developers can send PR's with additional technologies or providers.

### Docker

Expand All @@ -72,8 +86,14 @@ Your backend and frontend engineers can then easily consume this as an API. You

### Hal9

To deploy to Hal9's cloud run:
To deploy to `hal9.com` run:

```bash
hal9 deploy my-project --target hal9.com
```

When Hal9 runs in your own cloud you can replace `--target hal9.com` with the correct domain, for example:

```bash
hal9 deploy my-project --email email@email.com
hal9 deploy my-project --target hal9.acme.com
```
2 changes: 1 addition & 1 deletion python/hal9/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from hal9.core import *
from hal9.api import *
56 changes: 56 additions & 0 deletions python/hal9/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import requests
import time
import tempfile
import sys
import runpy

def create(path :str, template :str) -> str:
"""Create an application
Parameters
----------
path : str
Path to the application.
template : str
The template to use.
"""

print(f'Project created! {name}')

def run(path :str) -> str:
"""Run an application
Parameters
----------
path : str
Path to the application.
"""

print(f'Project created! {name}')

def deploy(path :str, target :str) -> str:
"""Deploy an application
Parameters
----------
path : str
Path to the application.
target : str
The deployment target, defaults to 'hal9.com'.
"""

response = requests.post('https://api.hal9.com/api/v1/deploy', json = {
'name': 'name',
'title': 'title',
'description': 'description',
'access': 'access',
'code': 'code',
'prompt': 'prompt',
'thumbnail': 'thumbnail',
'token': 'token',
'user': 'user',
})

if not response.ok:
print('Failed to deploy')
exit()
50 changes: 50 additions & 0 deletions python/hal9/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import click
from collections import OrderedDict
from hal9.api import *

@click.group()
def cli():
"""
Create and Deploy Generative Applications
Use this tool to create apps from templates that use Generative AI,
run them locally and deploy them to the cloud.
"""
pass

@click.command()
@click.argument('path')
def create(path):
"""
Create Project
PATH: The path for the new project. Required argument.
"""
print(f'Creating: {path}')

@click.command()
@click.argument('path')
def run(path):
"""
Run Project
PATH: The path to the project. Required argument.
"""
print(f'Running {path}')

@click.command()
@click.argument('path')
def deploy(path):
"""
Deploy Project
PATH: The path to the project. Required argument.
"""
print(f'Deploying {path}')

cli.add_command(create)
cli.add_command(run)
cli.add_command(deploy)

if __name__ == "__main__":
cli()
41 changes: 0 additions & 41 deletions python/hal9/core.py

This file was deleted.

6 changes: 5 additions & 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.0.0"
version = "2.0.1"
description = ""
authors = ["Javier Luraschi <[email protected]>"]
readme = "README.md"
Expand All @@ -9,6 +9,10 @@ readme = "README.md"
python = ">=3.8,<3.9.7 || >3.9.7,<4.0"
requests = "^2.28.2"

click = "^8.1.7"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
hal9 = "hal9.cli:cli"

0 comments on commit 466ec4e

Please sign in to comment.