Skip to content

Commit

Permalink
Update with Ruff recommendation
Browse files Browse the repository at this point in the history
  • Loading branch information
adiazpinto committed Jan 23, 2025
1 parent 260ff57 commit b749caf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions plugins/RadCoPilot_Slicer/RadCoPilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def __init__(self, *args, **kwargs):

class RadCoPilotWidget(ScriptedLoadableModuleWidget, VTKObservationMixin):
def __init__(self, parent=None):
"""
Called when the user opens the module the first time and the widget is initialized.
"""Called when the user opens the module the first time and the widget is initialized.
"""
ScriptedLoadableModuleWidget.__init__(self, parent)
VTKObservationMixin.__init__(self) # needed for parameter node observation
Expand Down Expand Up @@ -124,8 +123,7 @@ def __init__(self, parent=None):
self.optionsNameIndex = 0

def setup(self):
"""
Called when the user opens the module the first time and the widget is initialized.
"""Called when the user opens the module the first time and the widget is initialized.
"""
ScriptedLoadableModuleWidget.setup(self)

Expand Down
22 changes: 7 additions & 15 deletions plugins/RadCoPilot_Slicer/RadCoPilotLib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,35 @@


class RadCoPilotClient:
"""
Basic RadCoPilot Client to invoke infer API over http/https
"""
"""Basic RadCoPilot Client to invoke infer API over http/https."""

def __init__(self, server_url=None, tmpdir=None, client_id=None):
"""
:param server_url: Server URL for RadCoPilot (e.g. http://127.0.0.1:8000)
""":param server_url: Server URL for RadCoPilot. (e.g. http://127.0.0.1:8000).
:param tmpdir: Temp directory to save temporary files. If None then it uses tempfile.tempdir
:param client_id: Client ID that will be added for all basic requests
"""

self._server_url = server_url.rstrip("/").strip() if server_url is not None else server_url
# self._tmpdir = tmpdir if tmpdir else tempfile.tempdir if tempfile.tempdir else "/tmp"
# self._client_id = client_id
# self._headers = {}

def get_server_url(self):
"""
Return server url
"""Return server url.
:return: the url for monailabel server
"""
return self._server_url

def set_server_url(self, server_url):
"""
Set url for monailabel server
"""Set url for monailabel server.
:param server_url: server url for monailabel
"""
self._server_url = server_url.rstrip("/").strip()

def info(self):
"""
Invoke /info/ request over RadCoPilot Server
"""Invoke /info/ request over RadCoPilot Server.
:return: string response
"""
Expand All @@ -73,12 +67,10 @@ def info(self):
return response_text # The API returns a string, so we don't need to parse it as JSON

def getAnswer(self, inputText):
"""
Invoke request over RadCoPilot Server
"""Invoke request over RadCoPilot Server.
:return: json response
"""

selector = "/v1/chat/completions/"
url = f"{self._server_url}{selector}"

Expand Down

0 comments on commit b749caf

Please sign in to comment.