augllm 2.3.2__tar.gz → 2.3.4__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.
Files changed (32) hide show
  1. {augllm-2.3.2/src/augllm.egg-info → augllm-2.3.4}/PKG-INFO +2 -2
  2. {augllm-2.3.2 → augllm-2.3.4}/pyproject.toml +2 -2
  3. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/mlx_interface.py +12 -4
  4. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/mlx_llm.py +13 -8
  5. {augllm-2.3.2 → augllm-2.3.4/src/augllm.egg-info}/PKG-INFO +2 -2
  6. {augllm-2.3.2 → augllm-2.3.4}/src/augllm.egg-info/SOURCES.txt +0 -1
  7. {augllm-2.3.2 → augllm-2.3.4}/src/augllm.egg-info/requires.txt +1 -1
  8. augllm-2.3.2/src/augllm/mlx/mlx_llm copy.py +0 -100
  9. {augllm-2.3.2 → augllm-2.3.4}/LICENSE +0 -0
  10. {augllm-2.3.2 → augllm-2.3.4}/README.md +0 -0
  11. {augllm-2.3.2 → augllm-2.3.4}/setup.cfg +0 -0
  12. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/__init__.py +0 -0
  13. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/llama_cpp/interface copy 2.py +0 -0
  14. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/llama_cpp/interface copy.py +0 -0
  15. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/llama_cpp/interface.py +0 -0
  16. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/llm/interface.py +0 -0
  17. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/llm/llm.py +0 -0
  18. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/media_controller_pil.py +0 -0
  19. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/mlx_like_stream.py +0 -0
  20. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/prompt_builder.py +0 -0
  21. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/mlx/toggle_hf_progress_bar.py +0 -0
  22. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/augmented_llm.py +0 -0
  23. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/function_calling.py +0 -0
  24. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/image_controller.py +0 -0
  25. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/llm_interface.py +0 -0
  26. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/media_controller_base64.py +0 -0
  27. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/ollama_llm.py +0 -0
  28. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/prompt_builder.py +0 -0
  29. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/tool.py +0 -0
  30. {augllm-2.3.2 → augllm-2.3.4}/src/augllm/ollama/tool_handler.py +0 -0
  31. {augllm-2.3.2 → augllm-2.3.4}/src/augllm.egg-info/dependency_links.txt +0 -0
  32. {augllm-2.3.2 → augllm-2.3.4}/src/augllm.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: augllm
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: This is LLM interface library.
5
5
  Requires-Python: >=3.13
6
6
  Description-Content-Type: text/markdown
@@ -10,7 +10,7 @@ Requires-Dist: av>=17.0.0
10
10
  Requires-Dist: huggingface-hub>=1.4.1
11
11
  Requires-Dist: librosa>=0.11.0
12
12
  Requires-Dist: llama-cpp-python[server]>=0.3.16
13
- Requires-Dist: mlx-lm>=0.30.7
13
+ Requires-Dist: mlx-lm>=0.31.2
14
14
  Requires-Dist: mlx-vlm>=0.3.12
15
15
  Requires-Dist: ollama>=0.6.1
16
16
  Requires-Dist: openai>=2.24.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "augllm"
3
- version = "2.3.2"
3
+ version = "2.3.4"
4
4
  description = "This is LLM interface library."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -10,7 +10,7 @@ dependencies = [
10
10
  "huggingface-hub>=1.4.1",
11
11
  "librosa>=0.11.0",
12
12
  "llama-cpp-python[server]>=0.3.16",
13
- "mlx-lm>=0.30.7",
13
+ "mlx-lm>=0.31.2",
14
14
  "mlx-vlm>=0.3.12",
15
15
  "ollama>=0.6.1",
16
16
  "openai>=2.24.0",
@@ -24,11 +24,13 @@ class MlxLLMInterface:
24
24
  top_p: float = 1.0,
25
25
  min_p: float = 0.0,
26
26
  max_tokens: int = 8192,
27
- enable_thinking: bool = False
27
+ enable_thinking: bool = False,
28
+ keep_alive: bool = False # モデルをメモリに保持するか
28
29
  ):
29
30
  self.model_path = model_path
30
31
  self.use_vision = use_vision
31
32
  self.enable_thinking = enable_thinking
33
+ self.keep_alive = keep_alive
32
34
 
33
35
  # サンプリングパラメータの保持
34
36
  self.temp = temp
@@ -47,6 +49,11 @@ class MlxLLMInterface:
47
49
 
48
50
  #---------------------------------------------------------
49
51
  def _load_model(self):
52
+
53
+ # モデルが既にロードされている場合はスキップ
54
+ if self.model is not None:
55
+ return
56
+
50
57
  # 指定されたパラメータでサンプラーを固定
51
58
  self.sampler = make_sampler(
52
59
  temp=self.temp,
@@ -64,7 +71,7 @@ class MlxLLMInterface:
64
71
 
65
72
  #---------------------------------------------------------
66
73
  def _free_model(self):
67
- # メモリの明示的な解放(M4 Maxのユニファイドメモリをクリーンアップ)
74
+ # メモリの明示的な解放
68
75
  self.model = None
69
76
  self.tokenizer = None
70
77
  self.processor = None
@@ -146,5 +153,6 @@ class MlxLLMInterface:
146
153
  yield SimpleNamespace(text=full_text)
147
154
 
148
155
  finally:
149
- # 2. 推論終了後に必ずモデルを解放
150
- self._free_model()
156
+ # 2. keep_alive が False の場合のみ、推論終了後に解放
157
+ if not self.keep_alive:
158
+ self._free_model()
@@ -16,7 +16,8 @@ class MlxLLM:
16
16
  top_p: float = 1.0,
17
17
  min_p: float = 0.0,
18
18
  max_tokens: int = 8192,
19
- enable_thinking: bool = False
19
+ enable_thinking: bool = False,
20
+ keep_alive: bool = False # ← 追加:モデルをメモリに保持するか
20
21
  ):
21
22
  # LLMの初期化
22
23
  self.llm = MlxLLMInterface(
@@ -27,7 +28,8 @@ class MlxLLM:
27
28
  top_p=top_p,
28
29
  min_p=min_p,
29
30
  max_tokens=max_tokens,
30
- enable_thinking=enable_thinking
31
+ enable_thinking=enable_thinking,
32
+ keep_alive=False
31
33
  )
32
34
 
33
35
  #-----------------------------------------------------------------------------
@@ -40,10 +42,14 @@ class MlxLLM:
40
42
  images: Optional[List] = None
41
43
  ) -> Dict:
42
44
 
43
- # (元の実装をそのまま維持。VLMのパッチやタグ付け処理など)
45
+ # 画像が含まれる場合
44
46
  if images and self.llm.use_vision:
45
- pass # ※元のコードのタグ付与処理などがここに入ります
46
-
47
+ content = [{"type": "text", "text": text}]
48
+ for _ in images:
49
+ content.append({"type": "image"})
50
+ return {"role": role, "content": content}
51
+
52
+ # テキストのみの場合
47
53
  return {"role": role, "content": text}
48
54
 
49
55
  #-----------------------------------------------------------------------------
@@ -52,10 +58,9 @@ class MlxLLM:
52
58
  def respond(
53
59
  self,
54
60
  user_text: str,
55
- media_paths: Union[str, List[str]] = None, # 変更: user_images -> media_paths
61
+ media_paths: Union[str, List[str]] = None,
56
62
  system_prompt: str = None,
57
63
  stream: bool = False,
58
- think: Optional[bool] = None, # thinkモデル用のフラグ
59
64
  save_frames: bool = False, # フレーム保存フラグ
60
65
  save_dir: str = "output/frames" # 保存先フォルダ
61
66
  ):
@@ -67,7 +72,7 @@ class MlxLLM:
67
72
  if system_prompt:
68
73
  messages.append(self._build_message(role="system", text=system_prompt))
69
74
 
70
- # 変更: メディア処理 (PIL Imageのリストへ変換)
75
+ # メディア処理 (PIL Imageのリストへ変換)
71
76
  pil_user_images = []
72
77
  if media_paths:
73
78
  pil_user_images = process_media_to_pil(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: augllm
3
- Version: 2.3.2
3
+ Version: 2.3.4
4
4
  Summary: This is LLM interface library.
5
5
  Requires-Python: >=3.13
6
6
  Description-Content-Type: text/markdown
@@ -10,7 +10,7 @@ Requires-Dist: av>=17.0.0
10
10
  Requires-Dist: huggingface-hub>=1.4.1
11
11
  Requires-Dist: librosa>=0.11.0
12
12
  Requires-Dist: llama-cpp-python[server]>=0.3.16
13
- Requires-Dist: mlx-lm>=0.30.7
13
+ Requires-Dist: mlx-lm>=0.31.2
14
14
  Requires-Dist: mlx-vlm>=0.3.12
15
15
  Requires-Dist: ollama>=0.6.1
16
16
  Requires-Dist: openai>=2.24.0
@@ -15,7 +15,6 @@ src/augllm/llm/llm.py
15
15
  src/augllm/mlx/media_controller_pil.py
16
16
  src/augllm/mlx/mlx_interface.py
17
17
  src/augllm/mlx/mlx_like_stream.py
18
- src/augllm/mlx/mlx_llm copy.py
19
18
  src/augllm/mlx/mlx_llm.py
20
19
  src/augllm/mlx/prompt_builder.py
21
20
  src/augllm/mlx/toggle_hf_progress_bar.py
@@ -3,7 +3,7 @@ av>=17.0.0
3
3
  huggingface-hub>=1.4.1
4
4
  librosa>=0.11.0
5
5
  llama-cpp-python[server]>=0.3.16
6
- mlx-lm>=0.30.7
6
+ mlx-lm>=0.31.2
7
7
  mlx-vlm>=0.3.12
8
8
  ollama>=0.6.1
9
9
  openai>=2.24.0
@@ -1,100 +0,0 @@
1
-
2
- from typing import List, Optional, Dict
3
- from mlx_vlm.utils import load_image
4
- from .mlx_interface import MlxLLMInterface
5
- #--------------------------------------------------------------------------------------------
6
- # LLM推論を制御するメインクラス
7
- #--------------------------------------------------------------------------------------------
8
- class MlxLLM:
9
-
10
- def __init__(
11
- self,
12
- model_path: str,
13
- use_vision: bool = False,
14
- temp: float = 0.0,
15
- top_k: int = -1,
16
- top_p: float = 1.0,
17
- min_p: float = 0.0,
18
- max_tokens: int = 8192,
19
- enable_thinking: bool = False
20
- ):
21
- # LLMの初期化
22
- self.llm = MlxLLMInterface(
23
- model_path=model_path,
24
- use_vision=use_vision,
25
- temp=temp,
26
- top_k=top_k,
27
- top_p=top_p,
28
- min_p=min_p,
29
- max_tokens=max_tokens,
30
- enable_thinking=enable_thinking
31
- )
32
-
33
- #-----------------------------------------------------------------------------
34
- # MLX/VLM形式のメッセージ構造を構築する共通メソッド
35
- #-----------------------------------------------------------------------------
36
- def _build_message(
37
- self,
38
- role: str,
39
- text: str,
40
- images: Optional[List] = None
41
- ) -> Dict:
42
-
43
- # 画像があり、かつVLMインターフェースが有効な場合
44
- if images and self.llm.use_vision:
45
- content = [{"type": "text", "text": text}]
46
- for _ in images:
47
- content.append({"type": "image"})
48
- return {"role": role, "content": content}
49
-
50
- # 通常のテキストのみの場合
51
- return {"role": role, "content": text}
52
-
53
- #-----------------------------------------------------------------------------
54
- # ユーザー入力に対してツール実行と回答生成を行うメインメソッド
55
- #-----------------------------------------------------------------------------
56
- def respond(
57
- self,
58
- user_text: str,
59
- user_images: List = None,
60
- system_prompt: str = None,
61
- stream: bool = False,
62
- think: Optional[bool] = None, # thinkモデル用のフラグ
63
- save_frames: bool = False, # フレーム保存フラグ
64
- save_dir: str = "output/frames" # 保存先フォルダ
65
- ):
66
-
67
- # 初期化
68
- messages = []
69
-
70
- # システムプロンプト
71
- if system_prompt:
72
- messages.append(self._build_message(role="system", text=system_prompt))
73
-
74
- # ユーザー画像の処理
75
- user_images = user_images or []
76
- pil_user_images = [load_image(str(p)) for p in user_images]
77
-
78
- # ユーザー入力
79
- messages.append(self._build_message(role="user", text=user_text, images=pil_user_images))
80
-
81
- # 回答生成フェーズ
82
- full_reply = ""
83
- generator = self.llm.generate(
84
- messages=messages,
85
- images=pil_user_images if pil_user_images else None,
86
- stream=stream
87
- )
88
-
89
- # ストリーミング応答
90
- if stream:
91
- for response in generator:
92
- chunk = response.text
93
- full_reply += chunk
94
- yield chunk
95
-
96
- # 一括応答
97
- else:
98
- for response in generator:
99
- full_reply += response.text
100
- yield full_reply
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes