Skip to content

Commit

Permalink
support full extension id
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Apr 11, 2024
1 parent 1e7998d commit 5923089
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions public/chat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1386,14 +1386,19 @@ <h3 class="text-center">Welcome to BioImage.IO Chatbot</h3>
try {
console.log("Getting extension service:", ext)
let svcId, extServer;
debugger
// format my_workspace/client:[email protected]
if(ext.includes("@")){
svcId = ext.split("@")[0]
const serverUrl = ext.split("@")[1]
// Full service url format: https://ai.imjoy.io/<workspace>/services/<service_id>
if(ext.startsWith("http")){
// service id should be resolved to "<workspace>/<service_id>" (remove services)
let url = new URL(ext);
let pathParts = url.pathname.split('/');
let workspace = pathParts[1]; // assuming the workspace is the first part of the path
let serviceId = pathParts[3]; // assuming the service ID is the third part of the path
svcId = `${workspace}/${serviceId}`;

const serverUrl = url.origin;
try{
const server = await hyphaWebsocketClient.connectToServer({
"server_url": `https://${serverUrl}`,
"server_url": serverUrl,
"token": token,
})
extServer = server
Expand All @@ -1409,7 +1414,7 @@ <h3 class="text-center">Welcome to BioImage.IO Chatbot</h3>
extServer = server
}
const extSvc = await extServer.getService(svcId)
console.log("Got extension service:", ext, extSvc)
console.log("Got extension service:", svcId, extSvc)
extSvc._rintf = true
extSvc.id = extSvc.id.split(":")[1]
await _registerExtension(extSvc)
Expand Down

0 comments on commit 5923089

Please sign in to comment.