Skip to content

Commit cfdb104

Browse files
committed
WIP: serve Jupyternaut avatar to make it accessible from UI
1 parent 6001cf4 commit cfdb104

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

jupyter_ai_jupyternaut/extension_app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from asyncio import get_event_loop_policy
33
from jupyter_server.extension.application import ExtensionApp
44
from jupyter_server.serverapp import ServerApp
5+
import os
6+
from tornado.web import StaticFileHandler
57
from traitlets import List, Unicode, Dict
68
from traitlets.config import Config
79
from typing import TYPE_CHECKING
@@ -15,6 +17,10 @@
1517
if TYPE_CHECKING:
1618
from asyncio import AbstractEventLoop
1719

20+
JUPYTERNAUT_AVATAR_PATH = str(
21+
os.path.join(os.path.dirname(__file__), "static", "jupyternaut.svg")
22+
)
23+
1824
class JupyternautExtension(ExtensionApp):
1925
"""
2026
The Jupyternaut server extension.
@@ -34,6 +40,11 @@ class JupyternautExtension(ExtensionApp):
3440
(r"api/jupyternaut/models/chat/?", ChatModelsRestAPI),
3541
(r"api/jupyternaut/model-parameters/?", ModelParametersRestAPI),
3642
(r"api/jupyternaut/secrets/?", SecretsRestAPI),
43+
(
44+
r"api/jupyternaut/static/jupyternaut.svg()/?",
45+
StaticFileHandler,
46+
{"path": JUPYTERNAUT_AVATAR_PATH},
47+
),
3748
]
3849

3950
allowed_providers = List(

jupyter_ai_jupyternaut/jupyternaut/jupyternaut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs):
2323
def defaults(self):
2424
return PersonaDefaults(
2525
name="Jupyternaut",
26-
avatar_path="/api/ai/static/jupyternaut.svg",
26+
avatar_path="/api/jupyternaut/static/jupyternaut.svg",
2727
description="The standard agent provided by JupyterLab. Currently has no tools.",
2828
system_prompt="...",
2929
)
Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)