Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bioimage-io/bioimageio-chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Mar 27, 2024
2 parents c0cc0a8 + a391350 commit d801d7b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
36 changes: 33 additions & 3 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ A chatbot extension object is a dictionary with the following keys:
The following is a chatbot extension object defined in Python:
```python


def get_schema():
return {
"my_tool": {
"type": "object",
"title": "my_tool",
"description": "my tool",
"properties": {
"my_param": {
"type": "number",
Expand All @@ -34,7 +37,6 @@ def my_tool(config):
print(config["my_param"])
return {"result": "success"}


chatbot_extension = {
"id": "my-extension",
"type": "bioimageio-chatbot-extension",
Expand All @@ -59,6 +61,8 @@ const chatbotExtension = {
return {
my_tool: {
type: "object",
title: "my_tool",
description: "my tool",
properties: {
my_param: {
type: "number",
Expand Down Expand Up @@ -119,24 +123,50 @@ Below are examples demonstrating how to serve an extension with Hypha using both
### Serve Chatbot Extension with Hypha in JavaScript

```javascript
const server = await api.connectToServer({server_url: "https://chat.bioimage.io"});
const token = await login({server_url: "https://chat.bioimage.io"})
const server = await connectToServer({server_url: "https://chat.bioimage.io", token});
const svc = await server.registerService(chatbotExtension);
console.log(`Extension service registered with id: ${svc.id}, you can visit the service at: https://chat.bioimage.io/public/apps/bioimageio-chatbot-client/chat?extension=${svc.id}`);
```

**IMPORTANT: The above hypha service can only be accessed by the same user who registered the service, below you will find a section about making it public**

### Serve Chatbot Extension with Hypha in Python

```python
from imjoy_rpc.hypha import connect_to_server, login

server_url = "https://chat.bioimage.io"
server = await connect_to_server({"server_url": server_url})
token = await login({"server_url": server_url})
server = await connect_to_server({"server_url": server_url, "token": token})
svc = await server.register_service(chatbot_extension)
print(f"Extension service registered with id: {svc.id}, you can visit the service at: {server_url}/public/apps/bioimageio-chatbot-client/chat?extension={svc.id}")
```

After registering the extension with Hypha, you can access the chatbot with the extension by visiting the following URL: `https://chat.bioimage.io/public/apps/bioimageio-chatbot-client/chat?extension=<extension_id>`, where `<extension_id>` is the ID of the registered extension service.

**IMPORTANT: The above hypha service can only be accessed by the same user who registered the service, below you will find a section about making it public**

### Making Chatbot Extension Public

To make it public, you need to set the visibility of the chatbot extension service to `public`.

See the example below:

```python
from imjoy_rpc.hypha import connect_to_server, login

server_url = "https://chat.bioimage.io"
token = await login({"server_url": server_url})
server = await connect_to_server({"server_url": server_url, "token": token})
# Below, we set the visibility to public
chatbot_extension['config'] = {"visibility": "public"}
svc = await server.register_service(chatbot_extension)
print(f"Extension service registered with id: {svc.id}, you can visit the service at: {server_url}/public/apps/bioimageio-chatbot-client/chat?extension={svc.id}")
```

You can also implement authorization logic in the tool function, see [hypha service authorization](https://ha.amun.ai/#/?id=service-authorization).

## Tutorial

For an in-depth understanding, refer to [our detailed tutorial](./bioimage-chatbot-extension-tutorial.ipynb), accessible directly through the ImJoy Jupyter Notebook in your browser without installation. [Click here to launch the notebook](https://imjoy-notebook.netlify.app/lab/index.html?load=https://raw.githubusercontent.com/bioimage-io/bioimageio-chatbot/main/docs/bioimage-chatbot-extension-tutorial.ipynb&open=1).
Expand Down
13 changes: 6 additions & 7 deletions knowledge-base-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ collections:
format: markdown
- name: BioImage.IO
id: bioimage.io
source: https://github.com/bioimage-io/bioimage.io/archive/refs/heads/main.zip
source: https://github.com/bioimage-io/bioimage.io/archive/8ce3559d80f500eb34e1f75d9ea776d6efed5aef.zip
directory: docs
description: A platform for sharing and deploying deep learning models in bioimaging.
base_url: https://bioimage.io/docs/
Expand All @@ -25,14 +25,14 @@ collections:
format: markdown
- name: bio.tools
id: bio.tools
source: https://github.com/research-software-ecosystem/content/archive/refs/heads/master.zip
source: https://github.com/research-software-ecosystem/content/archive/954c3b2da10e951b2fbcf17825013c1c44ceddf6.zip
directory: data
description: A repository for research software tools with metadata.
base_url: https://bio.tools
format: json
- name: ImJoy
id: imjoy
source: https://github.com/imjoy-team/ImJoy/archive/refs/heads/master.zip
source: https://github.com/imjoy-team/ImJoy/archive/c255d9cda9dc19d441fb7cf1eaca806e5ec71af8.zip
directory: docs
description: A plugin powered hybrid computing platform for deploying deep learning applications such as advanced image analysis tools.
base_url: https://imjoy.io/docs/#/
Expand All @@ -59,7 +59,7 @@ collections:
format: markdown
- name: Introduction to Bioimage Analysis
id: book-itba
source: https://github.com/bioimagebook/bioimagebook.github.io/archive/refs/heads/main.zip
source: https://github.com/bioimagebook/bioimagebook.github.io/archive/9519fb297cece3a131718a36f642ba463c41b160.zip
directory: chapters
description: "A book written by Pete Bankhead about introduction to bioimage analysis, including practical exercises and Jupyter Book content"
base_url: https://bioimagebook.github.io/
Expand Down Expand Up @@ -120,20 +120,19 @@ collections:
format: pdf
- name: ITK
id: itk
source: https://github.com/InsightSoftwareConsortium/ITK/archive/refs/heads/master.zip
source: https://github.com/InsightSoftwareConsortium/ITK/archive/4d750726d06ba28c601b8a4bfac8780baa395ff1.zip
directory: Documentation/docs
description: "ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions"
base_url: https://docs.itk.org
format: markdown
- name: ITK-Wasm
id: itkwasm
source: https://github.com/InsightSoftwareConsortium/itk-wasm/archive/refs/heads/main.zip
source: https://github.com/InsightSoftwareConsortium/itk-wasm/archive/169a2e0eed6b30d91c59081643668ef13045bb93.zip
directory: docs
description: "High-performance spatial analysis in a web browser, Node.js, and across programming languages and hardware architectures"
base_url: https://wasm.itk.org
format: markdown


additional_channels:
- name: "biii.eu"
id: biii.eu
Expand Down

0 comments on commit d801d7b

Please sign in to comment.