Skip to content

Commit

Permalink
Add basic web UI (#652)
Browse files Browse the repository at this point in the history
* support revoke token

* support revoke token

* fix url

* small fix

* Simplify http endpoints

* Remove workspaces

* Fix test services

* Fix login

* Support basic web UI

* fix permission

* upgrade hypha-rpc

* fix permission check

* Fix register_service options

* Add /info endpoint
  • Loading branch information
oeway authored Aug 14, 2024
1 parent ba5e616 commit 692723a
Show file tree
Hide file tree
Showing 46 changed files with 2,013 additions and 875 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Hypha Change Log

### 0.20.15

- Add `revoke_token` to the workspace api.
- Simplify http endpoints to a fixed pattern such as "{workspace}/services/*" and "{workspace}/apps/*".
- To avoid naming convension, workspace names now must contain at least one hyphens, and only lowercase letters, numbers and hyphens are allowed.

### 0.20.14

- Make `get_service` more restricted to support only service id string, see [migration guide](./docs/migration-guide.md) for more details.
- Clean up http endpoints for the services.
- Remove local cache of the server apps, we now always use s3 as the primary storage.

### 0.20.12

- New Feature: In order to support large language models' function calling feature, hypha support built-in type annotation. With `hypha-rpc>=0.20.12`, we also support type annotation for the service functions in JSON Schema format. In Python, you can use `Pydantic` or simple python type hint, or directly write the json schema for Javascript service functions. This allows you to specify the inputs spec for functions.
- Add type support for the `hypha` module. It allows you to register a type in the workspace using `register_service_type`, `get_service_type`, `list_service_types`. When registering a new service, you can specify the type and enable type check for the service. The type check will be performed when calling the service function. The type check is only available in Python.
- Fix reconnecton issue in the client.
- Support case conversion, which allows converting the service functions to snake_case or camelCase in `get_service` (Python) or `getService` (JavaScript).
- **Breaking Changes**: In Python, all the function names uses snake case, and in JavaScript, all the function names uses camel case. For example, you should call `server.getService` instead of `server.get_service` in JavaScript, and `server.get_service` instead of `server.getService` in Python.
- **Breaking Changes**: The new version of Hypha (0.20.0+) improves the RPC connection to make it more stable and secure, most importantly it supports automatic reconnection when the connection is lost. This also means breaking changes to the previous version. In the new version you will need a new library called `hypha-rpc` (instead of the hypha submodule in the `imjoy-rpc` module) to connect to the server.

54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
# Hypha

![PyPI](https://img.shields.io/pypi/v/hypha.svg?style=popout)

<img src="./docs/img/hypha-logo-black.svg" width="320" alt="Hypha">

# Hypha
**Hypha** is a generative AI-powered application framework designed for large-scale data management, AI model serving, and real-time communication. Hypha allows the creation of computational platforms consisting of both computational and user interface components.

## Key Features

- **Generative AI-Powered:** Leverage the power of generative AI to build advanced data management and AI model serving solutions.
- **Hypha-RPC:** Utilize [hypha-rpc](https://github.com/oeway/hypha-rpc), a bidirectional remote procedure call system, enabling seamless communication and integration across distributed components.
- **Real-Time Communication:** Support for real-time communication within virtual workspaces, similar to platforms like Zoom.
- **Scalable and Flexible:** Connect and orchestrate various compute services, AI models, tools, and services running on distributed locations.
- **GenAI-Powered Automation:** Build GenAI-powered automation platforms and agentic workflows, enabling fully autonomous agent systems.

## How It Works

Hypha acts as a hub that connects different components through **Hypha-RPC**. Users and programmatic clients connect to the platform in virtual workspaces, where they can seamlessly make remote procedure calls (RPC) as if they are calling local functions. Developers can integrate all types of compute services, including AI models, tools, and services, across distributed locations.

### Virtual Workspaces

- Hypha's virtual workspaces are akin to Zoom rooms, where clients (users and programmatic) can connect and interact.
- Within these workspaces, all clients can perform seamless RPCs, facilitating easy and efficient collaboration and computation.

### Integration with Compute Services

- Hypha supports the integration of various compute services, including AI models and data analytics tools.
- These services, when connected to the platform, can be understood and orchestrated by large language models (LLMs), paving the way for creating next-generation GenAI-powered automation platforms and agentic workflows.

## Use Cases

- **Research Institutions:** Build integrated platforms for data management and AI-powered services.
- **AI-Powered Automation:** Create autonomous agent systems and GenAI-powered automation platforms.
- **Data Services:** Facilitate scalable and efficient data services and analytics through distributed computing.

Hypha is an application framework for large-scale data management and AI model serving, it allows creating computational platforms consists of computational and user interface components.
## Getting Started

Hypha server act as a hub for connecting different components through [hypya-rpc](https://github.com/oeway/hypha-rpc).
To get started with Hypha, follow the installation and setup instructions in the [documentation](https://docs.amun.ai).

## Change log
## License

### 0.20.14
Hypha is released under the MIT License. See the [LICENSE](./LICENSE) file for more details.

- Make `get_service` more restricted to support only service id string, see [migration guide](./docs/migration-guide.md) for more details.
- Clean up http endpoints for the services, now we also support /services/:service_id/:function_name
- Remove local cache of the server apps, we now always use s3 as the primary storage.
## Contributing

### 0.20.12
We welcome contributions from the community. Please see our [Contributing Guidelines](./CONTRIBUTING.md) for more information.

- New Feature: In order to support large language models' function calling feature, hypha support built-in type annotation. With `hypha-rpc>=0.20.12`, we also support type annotation for the service functions in JSON Schema format. In Python, you can use `Pydantic` or simple python type hint, or directly write the json schema for Javascript service functions. This allows you to specify the inputs spec for functions.
- Add type support for the `hypha` module. It allows you to register a type in the workspace using `register_service_type`, `get_service_type`, `list_service_types`. When registering a new service, you can specify the type and enable type check for the service. The type check will be performed when calling the service function. The type check is only available in Python.
- Fix reconnecton issue in the client.
- Support case conversion, which allows converting the service functions to snake_case or camelCase in `get_service` (Python) or `getService` (JavaScript).
- **Breaking Changes**: In Python, all the function names uses snake case, and in JavaScript, all the function names uses camel case. For example, you should call `server.getService` instead of `server.get_service` in JavaScript, and `server.get_service` instead of `server.getService` in Python.
- **Breaking Changes**: The new version of Hypha (0.20.0+) improves the RPC connection to make it more stable and secure, most importantly it supports automatic reconnection when the connection is lost. This also means breaking changes to the previous version. In the new version you will need a new library called `hypha-rpc` (instead of the hypha submodule in the `imjoy-rpc` module) to connect to the server.
## Acknowledgments

We thank the contributors and community members who have helped make Hypha what it is today.
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ if __name__ == "__main__":
Include the following script in your HTML file to load the `hypha-rpc` client:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14/dist/hypha-rpc-websocket.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].19/dist/hypha-rpc-websocket.min.js"></script>
```

Use the following code in JavaScript to connect to the server and access an existing service:
Expand Down
10 changes: 5 additions & 5 deletions docs/hypha-quick-tour.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,28 @@
{
"data": {
"text/plain": [
"[{'id': 'public/workspace-manager:triton-client',\n",
"[{'id': 'public/ws:triton-client',\n",
" 'name': 'Triton Client',\n",
" 'type': 'triton-client',\n",
" 'config': {'visibility': 'public',\n",
" 'require_context': True,\n",
" 'workspace': 'public',\n",
" 'flags': []}},\n",
" {'id': 'public/workspace-manager:s3-storage',\n",
" {'id': 'public/ws:s3-storage',\n",
" 'name': 'S3 Storage',\n",
" 'type': 's3-storage',\n",
" 'config': {'visibility': 'public',\n",
" 'require_context': True,\n",
" 'workspace': 'public',\n",
" 'flags': []}},\n",
" {'id': 'public/workspace-manager:card',\n",
" {'id': 'public/ws:card',\n",
" 'name': 'Card',\n",
" 'type': 'card',\n",
" 'config': {'visibility': 'public',\n",
" 'require_context': True,\n",
" 'workspace': 'public',\n",
" 'flags': []}},\n",
" {'id': 'public/workspace-manager:server-apps',\n",
" {'id': 'public/ws:server-apps',\n",
" 'name': 'Server Apps',\n",
" 'type': 'server-apps',\n",
" 'config': {'visibility': 'public',\n",
Expand Down Expand Up @@ -268,7 +268,7 @@
],
"source": [
"url = await s3.generate_presigned_url(\n",
" info[\"bucket\"], info[\"prefix\"] + \"hello.txt\"\n",
" \"hello.txt\"\n",
")\n",
"print(url)\n",
"response = await fetch(url, method=\"GET\")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/hypha_data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def setup(self, server, service_id="data-store", visibility="public"):
"config": {"visibility": visibility, "require_context": False},
"get": self.http_get,
},
overwrite=True,
{"overwrite": True},
)

def get_url(self, obj_id: str):
Expand Down
10 changes: 5 additions & 5 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To connect to the server, instead of installing the `imjoy-rpc` module, you will
pip install -U hypha-rpc # new install
```

We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.14` is compatible with Hypha server version `0.20.14`.
We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.19` is compatible with Hypha server version `0.20.19`.

#### 2. Change the imports to use `hypha-rpc`

Expand Down Expand Up @@ -124,10 +124,10 @@ loop.run_forever()
To connect to the server, instead of using the `imjoy-rpc` module, you will need to use the `hypha-rpc` module. The `hypha-rpc` module is a standalone module that provides the RPC connection to the Hypha server. You can include it in your HTML using a script tag:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14/dist/hypha-rpc-websocket.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].19/dist/hypha-rpc-websocket.min.js"></script>
```

We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.14` is compatible with Hypha server version `0.20.14`.
We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.19` is compatible with Hypha server version `0.20.19`.

#### 2. Change the connection method and use camelCase for service function names

Expand All @@ -145,7 +145,7 @@ Here is a suggested list of search and replace operations to update your code:
Here is an example of how the updated code might look:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14/dist/hypha-rpc-websocket.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].19/dist/hypha-rpc-websocket.min.js"></script>
<script>
async function main(){
const server = await hyphaWebsocketClient.connectToServer({"server_url": "https://hypha.aicell.io"});
Expand Down Expand Up @@ -193,7 +193,7 @@ We created a tutorial to introduce this new feature: [service type annotation](.
Here is a quick example in JavaScript:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14/dist/hypha-rpc-websocket.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].19/dist/hypha-rpc-websocket.min.js"></script>

<script>
async function main(){
Expand Down
2 changes: 1 addition & 1 deletion docs/service-type-annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ if __name__ == "__main__":
**JavaScript Client: Service Usage**

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].14/dist/hypha-rpc-websocket.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].19/dist/hypha-rpc-websocket.min.js"></script>
<script>
async function main() {
const server = await hyphaWebsocketClient.connectToServer({"server_url": "https://hypha.aicell.io"});
Expand Down
2 changes: 1 addition & 1 deletion hypha/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.20.14"
"version": "0.20.19"
}
Loading

0 comments on commit 692723a

Please sign in to comment.