pythoncharmers-meta 0.7.5__tar.gz → 0.7.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -160,3 +160,12 @@ cython_debug/
160
160
  # and can be added to the global gitignore or merged into this file. For a more nuclear
161
161
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
162
  #.idea/
163
+
164
+ # macOS rubbish:
165
+ .DS_Store
166
+ Icon?
167
+ # Emacs, VIM, and VS Code rubbish:
168
+ *~
169
+ *.swp
170
+ *.swo
171
+ .vscode/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythoncharmers-meta
3
- Version: 0.7.5
3
+ Version: 0.7.7
4
4
  Summary: Meta package with dependencies for Python Charmers training courses
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.10
@@ -9,6 +9,7 @@ Requires-Dist: diskcache>=5.6.3
9
9
  Requires-Dist: humanize>=4.10.0
10
10
  Requires-Dist: hvplot>=0.10.0
11
11
  Requires-Dist: ipython>=8.12.3
12
+ Requires-Dist: ipywidgets>=8.1.7
12
13
  Requires-Dist: isort>=5.13.2
13
14
  Requires-Dist: keyring>=25.4.1
14
15
  Requires-Dist: keyrings-cryptfile>=1.3.9
@@ -88,7 +89,9 @@ Requires-Dist: pyodbc>=5.2.0; extra == 'db'
88
89
  Requires-Dist: redis>=5.2.1; extra == 'db'
89
90
  Requires-Dist: sqlalchemy>=2.0.38; extra == 'db'
90
91
  Provides-Extra: dl
92
+ Requires-Dist: albumentations>=2.0.8; extra == 'dl'
91
93
  Requires-Dist: dataset>=1.5.2; extra == 'dl'
94
+ Requires-Dist: datasets>=2.2.1; extra == 'dl'
92
95
  Requires-Dist: diskcache>=5.6.3; extra == 'dl'
93
96
  Requires-Dist: eli5>=0.15.0; extra == 'dl'
94
97
  Requires-Dist: evaluate>=0.4.3; extra == 'dl'
@@ -100,7 +103,7 @@ Requires-Dist: scikit-learn>=1.6.1; extra == 'dl'
100
103
  Requires-Dist: skorch>=1.0.0; extra == 'dl'
101
104
  Requires-Dist: tensorboard>=2.18.0; extra == 'dl'
102
105
  Requires-Dist: textdistance[levenshtein]>=4.6.3; extra == 'dl'
103
- Requires-Dist: transformers>=4.49.0; extra == 'dl'
106
+ Requires-Dist: transformers[torch]>=4.49.0; extra == 'dl'
104
107
  Requires-Dist: xgboost>=2.1.1; extra == 'dl'
105
108
  Requires-Dist: yellowbrick>=1.5; extra == 'dl'
106
109
  Provides-Extra: docs
@@ -140,6 +143,7 @@ Requires-Dist: xarray>=2024.9.0; extra == 'gis'
140
143
  Requires-Dist: zarr>=2.18.3; extra == 'gis'
141
144
  Provides-Extra: ml
142
145
  Requires-Dist: eli5>=0.15.0; extra == 'ml'
146
+ Requires-Dist: glum>=3.1.2; extra == 'ml'
143
147
  Requires-Dist: joblib>=1.4.2; extra == 'ml'
144
148
  Requires-Dist: pyod>=2.0.5; extra == 'ml'
145
149
  Requires-Dist: scikit-learn>=1.6.1; extra == 'ml'
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pythoncharmers-meta"
3
- version = "0.7.5"
3
+ version = "0.7.7"
4
4
  description = "Meta package with dependencies for Python Charmers training courses"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -10,6 +10,7 @@ dependencies = [
10
10
  "humanize>=4.10.0",
11
11
  "hvplot>=0.10.0",
12
12
  "ipython>=8.12.3",
13
+ "ipywidgets>=8.1.7",
13
14
  "isort>=5.13.2",
14
15
  "keyring>=25.4.1",
15
16
  "keyrings-cryptfile>=1.3.9",
@@ -77,6 +78,7 @@ gis = [
77
78
  ]
78
79
  ml = [
79
80
  "eli5>=0.15.0",
81
+ "glum>=3.1.2",
80
82
  "joblib>=1.4.2",
81
83
  "pyod>=2.0.5",
82
84
  "scikit-learn>=1.6.1",
@@ -194,7 +196,9 @@ net = [
194
196
  "uvicorn>=0.34.0",
195
197
  ]
196
198
  dl = [
199
+ "albumentations>=2.0.8",
197
200
  "dataset>=1.5.2",
201
+ "datasets>=2.2.1",
198
202
  "diskcache>=5.6.3",
199
203
  "eli5>=0.15.0",
200
204
  "evaluate>=0.4.3",
@@ -206,7 +210,7 @@ dl = [
206
210
  "skorch>=1.0.0",
207
211
  "tensorboard>=2.18.0",
208
212
  "textdistance[Levenshtein]>=4.6.3",
209
- "transformers>=4.49.0",
213
+ "transformers[torch]>=4.49.0",
210
214
  "xgboost>=2.1.1",
211
215
  "yellowbrick>=1.5",
212
216
  ]
@@ -37,6 +37,7 @@ path and/or file that %code and %md query. To get help on these, run:
37
37
  # Import version from package metadata (single source of truth)
38
38
  try:
39
39
  from importlib.metadata import version, PackageNotFoundError
40
+
40
41
  try:
41
42
  __version__ = version("pythoncharmers-meta")
42
43
  except PackageNotFoundError:
@@ -47,6 +48,7 @@ except ImportError:
47
48
  # Python < 3.8 fallback
48
49
  try:
49
50
  import pkg_resources
51
+
50
52
  __version__ = pkg_resources.get_distribution("pythoncharmers-meta").version
51
53
  except Exception:
52
54
  __version__ = "unknown"
@@ -58,6 +60,7 @@ from .nb_magic import NotebookMagic
58
60
 
59
61
  try:
60
62
  from .ai_magic import AIMagic
63
+
61
64
  __all__.append("AIMagic")
62
65
  except Exception as e:
63
66
  print(e)
@@ -0,0 +1,61 @@
1
+ from IPython.core.magic import Magics, magics_class, line_cell_magic
2
+ from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
3
+ import llm
4
+
5
+
6
+ @magics_class
7
+ class AIMagic(Magics):
8
+ def __init__(self, shell, default_model_name="gpt-4o-mini"):
9
+ # You must call the parent constructor
10
+ super().__init__(shell)
11
+ self.default_model = llm.get_model(default_model_name)
12
+
13
+ @magic_arguments()
14
+ @argument("-m", "--model", type=str, help="Model name to use")
15
+ @argument("-t", "--temperature", type=float, help="Sampling temperature")
16
+ @argument(
17
+ "prompt",
18
+ nargs="*",
19
+ help="Prompt text (required for line magic, optional for cell magic)",
20
+ )
21
+ @line_cell_magic
22
+ def ai(self, line, cell=None):
23
+ # Parse arguments
24
+ args = parse_argstring(self.ai, line)
25
+ options = vars(args)
26
+
27
+ # Combine cell content and line prompt
28
+ line_prompt = " ".join(args.prompt)
29
+
30
+ # Check if we have any prompt content
31
+ if not line_prompt and cell is None:
32
+ print("Error: No prompt provided.")
33
+ print("\nUsage:")
34
+ print(" Line magic: %ai <prompt>")
35
+ print(" Cell magic: %%ai [prompt]")
36
+ print(" <cell content as prompt>")
37
+ print("\nOptions:")
38
+ print(" -m, --model <name> Model name to use")
39
+ print(" -t, --temperature <float> Sampling temperature")
40
+ print("\nExample:")
41
+ print(" %ai What is Python?")
42
+ print(" %ai -m gpt-4 Explain recursion")
43
+ return
44
+
45
+ prompt = line_prompt + ("" if cell is None else "\n\n" + cell)
46
+
47
+ if "model" in options:
48
+ model = llm.get_model(options["model"])
49
+ else:
50
+ model = self.default_model
51
+
52
+ # Prepare options to pass to llm
53
+ completion_args = {
54
+ k: v
55
+ for k, v in options.items()
56
+ if k not in {"prompt", "model"} and v is not None
57
+ }
58
+
59
+ # Call llm and return response
60
+ response = model.prompt(prompt, **completion_args)
61
+ print(response.text())
@@ -531,9 +531,6 @@ class NotebookMagic(Magics):
531
531
 
532
532
  Note: After running, convert the cell to Markdown with Esc M in Jupyter.
533
533
  """
534
- # Store original arg_s for better error messages
535
- original_arg_s = arg_s
536
-
537
534
  # Check for common mistakes (but not --list itself!)
538
535
  if "--list" not in arg_s and (
539
536
  "--lsit" in arg_s
@@ -542,9 +539,9 @@ class NotebookMagic(Magics):
542
539
  or "--lits" in arg_s
543
540
  ):
544
541
  raise UsageError(
545
- f"Invalid option. Did you mean '--list'?\n"
546
- f"Usage: %md --list or %md m1-m3 or %md -1 2-\n"
547
- f"See %md? for full documentation."
542
+ "Invalid option. Did you mean '--list'?\n"
543
+ "Usage: %md --list or %md m1-m3 or %md -1 2-\n"
544
+ "See %md? for full documentation."
548
545
  )
549
546
 
550
547
  # Check if user is trying to use old %mdat syntax
@@ -736,7 +733,7 @@ class NotebookMagic(Magics):
736
733
  if content_hash not in seen_content:
737
734
  seen_content.add(content_hash)
738
735
  contents.append(content)
739
- except (ValueError, IndexError) as e:
736
+ except (ValueError, IndexError):
740
737
  # Check if it's a markdown index that's out of range
741
738
  if "m" in arg.lower():
742
739
  all_markdown = get_markdown_cells(nb)
@@ -764,8 +761,8 @@ class NotebookMagic(Magics):
764
761
  )
765
762
  else:
766
763
  raise UsageError(
767
- f"No markdown cells found for the specified ranges.\n"
768
- f"Use '%md --list' to see available markdown cells."
764
+ "No markdown cells found for the specified ranges.\n"
765
+ "Use '%md --list' to see available markdown cells."
769
766
  )
770
767
  return
771
768