Skip to content

Commit 32559e0

Browse files
authored
Merge pull request #66
* Remove sub-optimal model warning, update model list and dependencies … * Bump version to v2025.06.25 in setup.cfg
1 parent e60f329 commit 32559e0

File tree

11 files changed

+34
-45
lines changed

11 files changed

+34
-45
lines changed

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = napari-chatgpt
3-
version = v2024.10.18.1
3+
version = v2025.06.25
44
description = A napari plugin to process and analyse images with chatGPT.
55
long_description = file: README.md
66
long_description_content_type = text/markdown
@@ -55,7 +55,7 @@ install_requires =
5555
xarray
5656
arbol
5757
playwright
58-
duckduckgo-search==6.3.2
58+
duckduckgo-search==8.0.4
5959
ome-zarr
6060
transformers
6161
cryptography

src/napari_chatgpt/_widget.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,6 @@ def _start_omega(self):
422422
# Model selected:
423423
main_llm_model_name = self.model_combo_box.currentText()
424424

425-
# Warn users with a modal window that the selected model might be sub-optimal:
426-
if 'gpt-4' not in main_llm_model_name and 'claude-3-opus' not in main_llm_model_name:
427-
aprint("Warning: you did not select a gpt-4 level model. Omega's cognitive and coding abilities will be degraded.")
428-
show_warning_dialog(f"You have selected this model: '{main_llm_model_name}'. "
429-
f"This is not a GPT4 or Claude-3-opus level model. "
430-
f"Omega's cognitive and coding abilities will be degraded. "
431-
f"It might even completely fail or be too slow. "
432-
f"Please visit <a href='https://github.com/royerlab/napari-chatgpt/wiki/OpenAIKey'>our wiki</a> "
433-
f"for information on how to gain access to GPT4 (or Claude-3).")
434-
435425
# Set tool LLM model name via configuration file.
436426
tool_llm_model_name = self.config.get('tool_llm_model_name', 'same')
437427
if tool_llm_model_name.strip() == 'same':

src/napari_chatgpt/omega/tools/instructions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
- If you need to get the selected layer in the napari viewer, use the following code: `viewer.layers.selection.active`.
2424
- napari layers do not have a 'type' field, if you need to check the type of a layer, use for example the following code: `isinstance(layer, napari.layers.Shapes)`.
2525
- If you need to rotate the viewer camera to a specific set of angles, use the following code: `viewer.camera.angles = (angle_z, angle_y, angle_x)` .
26+
- When required, import 'ArrayLike' from 'numpy.typing'.
27+
2628
"""
2729

src/napari_chatgpt/omega/tools/napari/cell_nuclei_segmentation_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _get_segmentation_prompt() -> str:
179179
- Assume that the functions 'cellpose_segmentation()', 'stardist_segmentation()', and 'classic_segmentation()' are available and within scope of your code.
180180
- DO NOT add the segmentation to the napari viewer, this is done automatically by the system.
181181
- DO NOT directly use the Cellpose or StarDist APIs: 'models.cellpose(...', 'model.predict_instances(...', etc.
182-
- Response must be only the python function: 'segment(viewer)->ArrayLike'.
182+
- Response must be only the python function: 'segment(viewer)' that returns an array.
183183
- Convert arrays to float type before processing. Intermediate or local arrays should be of type float. Constants for: np.full(), np.ones(), np.zeros(), ... should be floats (for example 1.0).
184184
- If the request mentions 'this/that/the image/layer' then most likely it refers to the last added image or layer.
185185
- Convert the segmented image to 'np.uint32' before returning the segmentation.

src/napari_chatgpt/omega/tools/napari/widget_maker_tool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
```
9797
- If you need to import other libraries, do so outside of the function.
9898
99-
100-
10199
"""
102100

103101
_code_prefix = """
Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
from arbol import asection
22

33

4-
5-
6-
def get_anthropic_model_list() -> list:
4+
def get_anthropic_model_list() -> list[str]:
75
"""
8-
Get the list of all Anthropic models.
9-
10-
Parameters
11-
----------
12-
filter : str
13-
Filter to apply to the list of models.
14-
Returns
15-
-------
16-
list
17-
List of models.
6+
Return a list of all *current, non-deprecated* Anthropic Claude models.
187
8+
Snapshot dates ensure deterministic behaviour. Last verified: 2025-06-25.
199
"""
20-
21-
with asection("Enumerating all Anthropic models:"):
22-
model_list = []
23-
24-
model_list.append('claude-3-opus-20240229')
25-
model_list.append('claude-3-sonnet-20240229')
26-
model_list.append('claude-3-haiku-20240307')
27-
model_list.append('claude-3-5-sonnet-20240620')
28-
29-
return model_list
30-
31-
32-
10+
with asection("Enumerating active Anthropic models"):
11+
return [
12+
"claude-3-opus-20240229",
13+
"claude-3-haiku-20240307",
14+
"claude-3-5-sonnet-20240620",
15+
"claude-3-5-sonnet-20241022",
16+
"claude-3-5-haiku-20241022",
17+
"claude-3-7-sonnet-20250219",
18+
"claude-sonnet-4-20250514",
19+
"claude-opus-4-20250514",
20+
]

src/napari_chatgpt/utils/api_keys/api_key.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def set_api_key(api_name: str) -> bool:
4646
aprint(f"Requesting key from user via user interface...")
4747
api_key = request_if_needed_api_key_dialog(api_name)
4848

49+
4950
# Potentially releases the Qt app, MUST BE KEPT!:
5051
app = None
5152

src/napari_chatgpt/utils/openai/default_model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ def model_key(model):
3030
# Use the length of the model name as a secondary sorting criterion
3131
length = len(model)
3232
# Sort by main version (descending), then by length (ascending)
33-
return (-float(main_version), length)
33+
try:
34+
key = (-float(main_version), length)
35+
except Exception:
36+
# If conversion to float fails, return a tuple that ensures this model is sorted last
37+
key = (float('inf'), length)
38+
39+
return key
3440

3541
sorted_model_list = sorted(model_list, key=model_key)
3642

src/napari_chatgpt/utils/openai/gpt_vision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from napari_chatgpt.utils.openai.model_list import get_openai_model_list
55

66

7-
def is_gpt_vision_available(vision_model_name: str = 'gpt-4-vision-preview') -> bool:
7+
def is_gpt_vision_available(vision_model_name: str = 'gpt-4') -> bool:
88
"""
99
Check if GPT-vision is available.
1010
@@ -29,7 +29,7 @@ def is_gpt_vision_available(vision_model_name: str = 'gpt-4-vision-preview') ->
2929

3030
def describe_image(image_path: str,
3131
query: str = 'Here is an image, please carefully describe it in detail.',
32-
model: str = "gpt-4-vision-preview",
32+
model: str = "gpt-4o",
3333
max_tokens: int = 4096,
3434
number_of_tries: int = 4,
3535
) -> str:

src/napari_chatgpt/utils/openai/model_list.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def get_openai_model_list(filter: str = 'gpt', verbose: bool = False) -> list:
4848
if verbose:
4949
aprint(model_id)
5050

51+
# Remove any models that contain the following substrings:
52+
model_list = [m for m in model_list if
53+
not any(x in m for x in ['vision', 'instruct', 'turbo-instruct', 'preview', 'realtime', 'audio', 'transcribe', 'image'])]
54+
5155
return model_list
5256

5357
except Exception as e:

0 commit comments

Comments
 (0)