diff --git a/docker-compose/README.md b/docker-compose/README.md
index 7ef5bf440..74b9b9f81 100644
--- a/docker-compose/README.md
+++ b/docker-compose/README.md
@@ -45,7 +45,7 @@ This directory contains a Docker Compose setup for running Hypha Server with Min
The Hypha Server provides the backend API for the Hypha application.
-- Image: `ghcr.io/amun-ai/hypha:0.20.51`
+- Image: `ghcr.io/amun-ai/hypha:0.20.54`
- Port: 9520
- Data: Stored in the local directory `./data/hypha`
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index 193fd09bd..65aded35e 100644
--- a/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -2,7 +2,7 @@ version: '3.8'
services:
hypha-server:
- image: ghcr.io/amun-ai/hypha:0.20.51
+ image: ghcr.io/amun-ai/hypha:0.20.54
ports:
- "${HYPHA_PORT:-9527}:9527"
environment:
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
index e5d84e0d4..8d4db3e42 100644
--- a/docs/_sidebar.md
+++ b/docs/_sidebar.md
@@ -3,6 +3,7 @@
* [Hypha RPC](/hypha-rpc)
* [Migration Guide](/migration-guide)
* [Service Type Annotation](/service-type-annotation)
+ * [Service Load Balancing](/service-load-balancing)
* [Serverless Functions](/serverless-functions)
* [Serve ASGI Web Apps](/asgi-apps)
* [Launch Service](/launch-service)
diff --git a/docs/artifact-manager.md b/docs/artifact-manager.md
index 0caba2e84..c6e4d87a2 100644
--- a/docs/artifact-manager.md
+++ b/docs/artifact-manager.md
@@ -689,7 +689,7 @@ manifest = await artifact_manager.read(artifact_id="other_workspace/example-data
---
-### `list(artifact_id: str=None, keywords: List[str] = None, filters: dict = None, mode: str = "AND", offset: int = 0, limit: int = 100, order_by: str = None, silent: bool = False, stage: bool = False) -> list`
+### `list(parent_id: str=None, keywords: List[str] = None, filters: dict = None, mode: str = "AND", offset: int = 0, limit: int = 100, order_by: str = None, silent: bool = False, stage: bool = False) -> list`
Retrieve a list of child artifacts within a specified collection, supporting keyword-based fuzzy search, field-specific filters, and flexible ordering. This function allows detailed control over the search and pagination of artifacts in a collection, including staged artifacts if specified.
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 442e8a889..3662f8d4f 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -183,10 +183,10 @@ pip install hypha-rpc
The following code registers a service called "Hello World" with the ID "hello-world" and a function called `hello()`. The function takes a single argument, `name`, and prints "Hello" followed by the name. The function also returns a string containing "Hello" followed by the name.
-We provide two versions of the code: an asynchronous version for native CPython or Pyodide-based Python in the browser (without thread support), and a synchronous version for native Python with thread support (more details about the [synchronous wrapper](/hypha-rpc?id=synchronous-wrapper)):
+We provide three versions of the code: an asynchronous version for native CPython or Pyodide-based Python in the browser (without thread support), a synchronous version for native Python with thread support (more details about the [synchronous wrapper](/hypha-rpc?id=synchronous-wrapper)), and a JavaScript version for web browsers:
-#### ** Asynchronous Worker **
+#### ** Asynchronous Server **
```python
import asyncio
@@ -212,7 +212,7 @@ async def start_server(server_url):
print(f'You can use this service using the service id: {svc.id}')
- print(f"You can also test the service via the HTTP proxy: {server_url}/{server.config.workspace}/services/{svc.id}/hello?name=John")
+ print(f"You can also test the service via the HTTP proxy: {server_url}/{server.config.workspace}/services/{svc.id.split('/')[1]}/hello?name=John")
# Keep the server running
await server.serve()
@@ -222,7 +222,7 @@ if __name__ == "__main__":
asyncio.run(start_server(server_url))
```
-#### ** Synchronous Worker **
+#### ** Synchronous Server **
```python
from hypha_rpc.sync import connect_to_server
@@ -247,15 +247,77 @@ def start_server(server_url):
print(f'You can use this service using the service id: {svc.id}')
- print(f"You can also test the service via the HTTP proxy: {server_url}/{server.config.workspace}/services/{svc.id}/hello?name=John")
+ print(f"You can also test the service via the HTTP proxy: {server_url}/{server.config.workspace}/services/{svc.id.split('/')[1]}/hello?name=John")
if __name__ == "__main__":
server_url = "http://localhost:9527"
start_server(server_url)
```
+
+#### ** JavaScript Server **
+
+First, install the `hypha-rpc` library:
+
+```bash
+npm install hypha-rpc
+```
+
+Or include it via CDN in your HTML file:
+
+```html
+
+```
+
+Then use the following JavaScript code to register a service:
+
+```javascript
+const serverUrl = "https://hypha.aicell.io"
+
+const loginCallback = (context) => {
+ window.open(context.login_url);
+};
+
+async function startServer(serverUrl) {
+ // Log in and connect to the Hypha server
+ const token = await hyphaWebsocketClient.login({
+ server_url: serverUrl,
+ login_callback: loginCallback,
+ });
+
+ const server = await hyphaWebsocketClient.connectToServer({
+ server_url: serverUrl,
+ token: token,
+ });
+
+ // Define a service method
+ function hello(name, context) {
+ console.log("Hello " + name);
+ return "Hello " + name;
+ }
+
+ // Register the service with the server
+ const myService = await server.registerService({
+ id: "hello-world",
+ name: "Hello World",
+ description: "A simple hello world service",
+ config: {
+ visibility: "public",
+ require_context: true,
+ },
+ hello: hello, // or just `hello,` in modern JS
+ });
+
+ console.log(`Hello world service registered at workspace: ${server.config.workspace}, id: ${myService.id}`);
+ console.log(`You can use this service using the service id: ${myService.id}`);
+ console.log(`You can also test the service via the HTTP proxy: ${serverUrl}/${server.config.workspace}/services/${myService.id.split('/')[1]}/hello?name=John`);
+}
+
+// Start the server
+startServer(serverUrl);
+```
-Run the server via `python hello-world-worker.py` and keep it running. You can now access the service from a client script. You will see the service ID printed in the console, which you can use to access the service.
+Run the server script and keep it running. You can now access the service from a client script. You will see the service ID printed in the console, which you can use to access the service.
Tips: You don't need to run the client script on the same server. If you want to connect to the server from another computer, make sure to change the `server_url` to an URL with the external IP or domain name of the server.
@@ -334,7 +396,7 @@ svc = await get_remote_service("http://localhost:9527/ws-user-scintillating-lawy
Include the following script in your HTML file to load the `hypha-rpc` client:
```html
-
+
```
Use the following code in JavaScript to connect to the server and access an existing service:
@@ -343,7 +405,7 @@ Use the following code in JavaScript to connect to the server and access an exis
async function main(){
const server = await hyphaWebsocketClient.connectToServer({"server_url": "http://localhost:9527"})
// NOTE: You need to replace the service id with the actual id you obtained when registering the service
- const svc = await server.get_service("ws-user-scintillating-lawyer-94336986/YLNzuQvQHVqMAyDzmEpFgF:hello-world")
+ const svc = await server.getService("ws-user-scintillating-lawyer-94336986/YLNzuQvQHVqMAyDzmEpFgF:hello-world")
const ret = await svc.hello("John")
console.log(ret)
}
diff --git a/docs/migration-guide.md b/docs/migration-guide.md
index 160648f11..36a7c1766 100644
--- a/docs/migration-guide.md
+++ b/docs/migration-guide.md
@@ -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.51` is compatible with Hypha server version `0.20.51`.
+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.54` is compatible with Hypha server version `0.20.54`.
#### 2. Change the imports to use `hypha-rpc`
@@ -128,10 +128,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
-
+
```
-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.51` is compatible with Hypha server version `0.20.51`.
+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.54` is compatible with Hypha server version `0.20.54`.
#### 2. Change the connection method and use camelCase for service function names
@@ -149,7 +149,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
-
+
+
+
+
+