tina-python 0.7.2__tar.gz → 0.7.3__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 (61) hide show
  1. {tina_python-0.7.2/tina_python.egg-info → tina_python-0.7.3}/PKG-INFO +1 -1
  2. {tina_python-0.7.2 → tina_python-0.7.3}/pyproject.toml +1 -1
  3. {tina_python-0.7.2 → tina_python-0.7.3}/tina/__init__.py +1 -1
  4. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/agent_runtime.py +24 -4
  5. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/multimodal_agent.py +9 -0
  6. {tina_python-0.7.2 → tina_python-0.7.3}/tina/llm/base_multimodal_api.py +25 -3
  7. {tina_python-0.7.2 → tina_python-0.7.3}/tina/llm/files_api.py +15 -2
  8. {tina_python-0.7.2 → tina_python-0.7.3/tina_python.egg-info}/PKG-INFO +1 -1
  9. {tina_python-0.7.2 → tina_python-0.7.3}/LICENSE +0 -0
  10. {tina_python-0.7.2 → tina_python-0.7.3}/MANIFEST.in +0 -0
  11. {tina_python-0.7.2 → tina_python-0.7.3}/README.md +0 -0
  12. {tina_python-0.7.2 → tina_python-0.7.3}/setup.cfg +0 -0
  13. {tina_python-0.7.2 → tina_python-0.7.3}/setup.py +0 -0
  14. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/__init__.py +0 -0
  15. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/agent.py +0 -0
  16. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/__init__.py +0 -0
  17. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/agent_response.py +0 -0
  18. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/context_manager.py +0 -0
  19. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/events.py +0 -0
  20. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/executor.py +0 -0
  21. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/keyword_actions.py +0 -0
  22. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/prompt.py +0 -0
  23. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/state.py +0 -0
  24. {tina_python-0.7.2 → tina_python-0.7.3}/tina/agent/core/tools.py +0 -0
  25. {tina_python-0.7.2 → tina_python-0.7.3}/tina/core/__init__.py +0 -0
  26. {tina_python-0.7.2 → tina_python-0.7.3}/tina/core/error.py +0 -0
  27. {tina_python-0.7.2 → tina_python-0.7.3}/tina/core/logger.py +0 -0
  28. {tina_python-0.7.2 → tina_python-0.7.3}/tina/llm/__init__.py +0 -0
  29. {tina_python-0.7.2 → tina_python-0.7.3}/tina/llm/base_api.py +0 -0
  30. {tina_python-0.7.2 → tina_python-0.7.3}/tina/mcp/__init__.py +0 -0
  31. {tina_python-0.7.2 → tina_python-0.7.3}/tina/mcp/client.py +0 -0
  32. {tina_python-0.7.2 → tina_python-0.7.3}/tina/mcp/mcp_tools_executor.py +0 -0
  33. {tina_python-0.7.2 → tina_python-0.7.3}/tina/py.typed +0 -0
  34. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/__init__.py +0 -0
  35. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/agent_worker.py +0 -0
  36. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/coding_context.py +0 -0
  37. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/coding_tools.py +0 -0
  38. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/deepseek.py +0 -0
  39. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/doc_parser.py +0 -0
  40. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/env_reader.py +0 -0
  41. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/__init__.py +0 -0
  42. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/environment.py +0 -0
  43. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/message.py +0 -0
  44. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/message_bus.py +0 -0
  45. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/web/__init__.py +0 -0
  46. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multi_agent/web/server.py +0 -0
  47. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/multimodal_formatter.py +0 -0
  48. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/output_parser.py +0 -0
  49. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/run_agent_in_cli.py +0 -0
  50. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/session_store.py +0 -0
  51. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/tui/__init__.py +0 -0
  52. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/tui/context_manager.py +0 -0
  53. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/tui/token.py +0 -0
  54. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/tui/tui.py +0 -0
  55. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/type_mapper.py +0 -0
  56. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/url.py +0 -0
  57. {tina_python-0.7.2 → tina_python-0.7.3}/tina/utils/usage.py +0 -0
  58. {tina_python-0.7.2 → tina_python-0.7.3}/tina_python.egg-info/SOURCES.txt +0 -0
  59. {tina_python-0.7.2 → tina_python-0.7.3}/tina_python.egg-info/dependency_links.txt +0 -0
  60. {tina_python-0.7.2 → tina_python-0.7.3}/tina_python.egg-info/requires.txt +0 -0
  61. {tina_python-0.7.2 → tina_python-0.7.3}/tina_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tina-python
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: tina is in your computer!
5
5
  Home-page: https://gitee.com/wang-churi/tina
6
6
  Author: 王出日
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tina-python"
7
- version = "0.7.2"
7
+ version = "0.7.3"
8
8
  description = "tina is in your computer!"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.10"
@@ -21,4 +21,4 @@ __all__ = [
21
21
  "AgentEvents",
22
22
  "FilesAPI",
23
23
  ]
24
- __version__ = "0.7.2"
24
+ __version__ = "0.7.3"
@@ -573,10 +573,15 @@ class ToolCallingMutilemodalAgentRuntime(BaseAgentRuntime):
573
573
  top_p: float = 0.9,
574
574
  top_k: int = 1,
575
575
  min_p: float = 0.0,
576
+ file_id: str | list[str] = None,
576
577
  ) -> dict:
577
578
  self._reset_keyword_buffer()
578
579
  self.context_manager.add_user_message(
579
- instruction=instruction, image=image, audio=audio, url=url
580
+ instruction=instruction,
581
+ image=image,
582
+ audio=audio,
583
+ url=url,
584
+ file_id=file_id,
580
585
  )
581
586
  counter = 0
582
587
  while counter < self.max_tool_loop:
@@ -632,10 +637,15 @@ class ToolCallingMutilemodalAgentRuntime(BaseAgentRuntime):
632
637
  top_p: float = 0.9,
633
638
  top_k: int = 1,
634
639
  min_p: float = 0,
640
+ file_id: str | list[str] = None,
635
641
  ) -> Generator[dict, None, None]:
636
642
  self._reset_keyword_buffer()
637
643
  self.context_manager.add_user_message(
638
- instruction=instruction, image=image, audio=audio, url=url
644
+ instruction=instruction,
645
+ image=image,
646
+ audio=audio,
647
+ url=url,
648
+ file_id=file_id,
639
649
  )
640
650
  counter = 0
641
651
  while counter < self.max_tool_loop:
@@ -755,10 +765,15 @@ class ToolCallingMutilemodalAgentRuntime(BaseAgentRuntime):
755
765
  top_p=0.9,
756
766
  top_k=1,
757
767
  min_p=0,
768
+ file_id: str | list[str] = None,
758
769
  ):
759
770
  self._reset_keyword_buffer()
760
771
  self.context_manager.add_user_message(
761
- instruction=instruction, image=image, audio=audio, url=url
772
+ instruction=instruction,
773
+ image=image,
774
+ audio=audio,
775
+ url=url,
776
+ file_id=file_id,
762
777
  )
763
778
  counter = 0
764
779
  while counter < self.max_tool_loop:
@@ -815,10 +830,15 @@ class ToolCallingMutilemodalAgentRuntime(BaseAgentRuntime):
815
830
  top_p=0.9,
816
831
  top_k=1,
817
832
  min_p=0,
833
+ file_id: str | list[str] = None,
818
834
  ):
819
835
  self._reset_keyword_buffer()
820
836
  self.context_manager.add_user_message(
821
- instruction=instruction, image=image, audio=audio, url=url
837
+ instruction=instruction,
838
+ image=image,
839
+ audio=audio,
840
+ url=url,
841
+ file_id=file_id,
822
842
  )
823
843
  counter = 0
824
844
  while counter < self.max_tool_loop:
@@ -151,6 +151,7 @@ class MultimodalAgent(Agent):
151
151
  top_p: float = 0.9,
152
152
  top_k: int = 1,
153
153
  min_p: float = 0.0,
154
+ file_id: str | list[str] = None,
154
155
  stream: Literal[True] = True,
155
156
  ) -> Generator[AgentResponse, None, None]: ...
156
157
 
@@ -165,6 +166,7 @@ class MultimodalAgent(Agent):
165
166
  top_p: float = 0.9,
166
167
  top_k: int = 1,
167
168
  min_p: float = 0.0,
169
+ file_id: str | list[str] = None,
168
170
  stream: Literal[False] = False,
169
171
  ) -> AgentResponse: ...
170
172
  def predict(
@@ -177,6 +179,7 @@ class MultimodalAgent(Agent):
177
179
  top_p: float = 0.9,
178
180
  top_k: int = 1,
179
181
  min_p: float = 0.0,
182
+ file_id: str | list[str] = None,
180
183
  stream: bool = True,
181
184
  ):
182
185
  """
@@ -192,6 +195,7 @@ class MultimodalAgent(Agent):
192
195
  top_p,
193
196
  top_k,
194
197
  min_p,
198
+ file_id,
195
199
  )
196
200
  else:
197
201
 
@@ -204,6 +208,7 @@ class MultimodalAgent(Agent):
204
208
  top_p,
205
209
  top_k,
206
210
  min_p,
211
+ file_id,
207
212
  )
208
213
 
209
214
  async def apredict(
@@ -216,6 +221,7 @@ class MultimodalAgent(Agent):
216
221
  top_p: float = 0.9,
217
222
  top_k: int = 1,
218
223
  min_p: float = 0.0,
224
+ file_id: str | list[str] = None,
219
225
  ) -> AsyncGenerator[AgentResponse, None]:
220
226
  """
221
227
  异步版本的 predict,默认流式输出
@@ -229,6 +235,7 @@ class MultimodalAgent(Agent):
229
235
  top_p,
230
236
  top_k,
231
237
  min_p,
238
+ file_id,
232
239
  ):
233
240
  yield AgentResponse(**chunk)
234
241
 
@@ -242,6 +249,7 @@ class MultimodalAgent(Agent):
242
249
  top_p: float = 0.9,
243
250
  top_k: int = 1,
244
251
  min_p: float = 0.0,
252
+ file_id: str | list[str] = None,
245
253
  ) -> AgentResponse:
246
254
  result = await self.runtime.arun_prediction_no_stream(
247
255
  instruction,
@@ -252,5 +260,6 @@ class MultimodalAgent(Agent):
252
260
  top_p,
253
261
  top_k,
254
262
  min_p,
263
+ file_id,
255
264
  )
256
265
  return AgentResponse(**result)
@@ -49,15 +49,23 @@ class BaseMultimodalAPI(BaseAPI):
49
49
  role: str = "user",
50
50
  sys_prompt: str = "你的工作非常出色!",
51
51
  messages: list = None,
52
+ input_file_id: Union[str, list[str]] = None,
52
53
  ) -> list:
53
- """准备多模态消息列表,支持单/多文本、图片、音频"""
54
+ """准备多模态消息列表,支持单/多文本、图片、音频、file_id"""
54
55
  if messages is None:
55
56
  messages = [{"role": "system", "content": sys_prompt}]
56
57
  if input_text is not None or any(
57
- _input is not None for _input in [input_image, input_audio, input_url]
58
+ _input is not None
59
+ for _input in [input_image, input_audio, input_url, input_file_id]
58
60
  ):
59
61
  user_message = build_multimodal_message(
60
- input_text, input_image, input_audio, input_url, image_detail, role
62
+ input_text,
63
+ input_image,
64
+ input_audio,
65
+ input_url,
66
+ image_detail,
67
+ role,
68
+ input_file_id=input_file_id,
61
69
  )
62
70
  if user_message is not None:
63
71
  messages.append(user_message)
@@ -86,6 +94,7 @@ class BaseMultimodalAPI(BaseAPI):
86
94
  json_format: str = "{}",
87
95
  tools: list = None,
88
96
  timeout: int = 180,
97
+ input_file_id: Union[str, list[str]] = None,
89
98
  **kwargs,
90
99
  ):
91
100
  """
@@ -141,6 +150,7 @@ class BaseMultimodalAPI(BaseAPI):
141
150
  json_format=json_format,
142
151
  tools=tools,
143
152
  timeout=timeout,
153
+ input_file_id=input_file_id,
144
154
  **kwargs,
145
155
  )
146
156
  else:
@@ -164,6 +174,7 @@ class BaseMultimodalAPI(BaseAPI):
164
174
  json_format=json_format,
165
175
  tools=tools,
166
176
  timeout=timeout,
177
+ input_file_id=input_file_id,
167
178
  **kwargs,
168
179
  )
169
180
 
@@ -188,6 +199,7 @@ class BaseMultimodalAPI(BaseAPI):
188
199
  json_format: str = "{}",
189
200
  tools: list = None,
190
201
  timeout: int = 180,
202
+ input_file_id: Union[str, list[str]] = None,
191
203
  **kwargs,
192
204
  ) -> dict:
193
205
  """
@@ -230,6 +242,7 @@ class BaseMultimodalAPI(BaseAPI):
230
242
  role,
231
243
  sys_prompt,
232
244
  messages,
245
+ input_file_id,
233
246
  )
234
247
  payload = self._prepare_payload(
235
248
  messages=prepared_messages,
@@ -288,6 +301,7 @@ class BaseMultimodalAPI(BaseAPI):
288
301
  json_format: str = "{}",
289
302
  tools: list = None,
290
303
  timeout: int = 180,
304
+ input_file_id: Union[str, list[str]] = None,
291
305
  **kwargs,
292
306
  ) -> Generator[dict, None, None]:
293
307
  """
@@ -330,6 +344,7 @@ class BaseMultimodalAPI(BaseAPI):
330
344
  role,
331
345
  sys_prompt,
332
346
  messages,
347
+ input_file_id,
333
348
  )
334
349
  payload = self._prepare_payload(
335
350
  messages=prepared_messages,
@@ -373,6 +388,7 @@ class BaseMultimodalAPI(BaseAPI):
373
388
  json_format: str = "{}",
374
389
  tools: list = None,
375
390
  timeout: int = 180,
391
+ input_file_id: Union[str, list[str]] = None,
376
392
  **kwargs,
377
393
  ):
378
394
  """
@@ -428,6 +444,7 @@ class BaseMultimodalAPI(BaseAPI):
428
444
  json_format=json_format,
429
445
  tools=tools,
430
446
  timeout=timeout,
447
+ input_file_id=input_file_id,
431
448
  **kwargs,
432
449
  )
433
450
  else:
@@ -451,6 +468,7 @@ class BaseMultimodalAPI(BaseAPI):
451
468
  json_format=json_format,
452
469
  tools=tools,
453
470
  timeout=timeout,
471
+ input_file_id=input_file_id,
454
472
  **kwargs,
455
473
  )
456
474
 
@@ -475,6 +493,7 @@ class BaseMultimodalAPI(BaseAPI):
475
493
  json_format: str = "{}",
476
494
  tools: list = None,
477
495
  timeout: int = 180,
496
+ input_file_id: Union[str, list[str]] = None,
478
497
  **kwargs,
479
498
  ) -> dict:
480
499
  """
@@ -517,6 +536,7 @@ class BaseMultimodalAPI(BaseAPI):
517
536
  role,
518
537
  sys_prompt,
519
538
  messages,
539
+ input_file_id,
520
540
  )
521
541
  payload = self._prepare_payload(
522
542
  messages=prepared_messages,
@@ -578,6 +598,7 @@ class BaseMultimodalAPI(BaseAPI):
578
598
  json_format: str = "{}",
579
599
  tools: list = None,
580
600
  timeout: int = 180,
601
+ input_file_id: Union[str, list[str]] = None,
581
602
  **kwargs,
582
603
  ) -> AsyncGenerator[dict, None]:
583
604
  """
@@ -622,6 +643,7 @@ class BaseMultimodalAPI(BaseAPI):
622
643
  role,
623
644
  sys_prompt,
624
645
  messages,
646
+ input_file_id,
625
647
  )
626
648
  payload = self._prepare_payload(
627
649
  messages=prepared_messages,
@@ -312,12 +312,25 @@ class FilesAPI:
312
312
  resp = await self.aclient.get(self._file_url(file_id), headers=self._headers())
313
313
  return self._handle(resp, self._file_url(file_id))
314
314
 
315
+ # 「文件不存在」的判定:OpenAI 返回 404,但 DeepSeek 对不存在的 file_id
316
+ # 返回 400 + invalid_request_error("file_id does not exist...")。
317
+ _NOT_FOUND_HINTS = ("does not exist", "not found", "not_found")
318
+
319
+ def _is_missing(self, resp: "httpx.Response") -> bool:
320
+ """该响应是否表示「文件不存在」"""
321
+ if resp.status_code == 404:
322
+ return True
323
+ if resp.status_code == 400:
324
+ body = (resp.text or "").lower()
325
+ return any(hint in body for hint in self._NOT_FOUND_HINTS)
326
+ return False
327
+
315
328
  def exists(self, file_id: str) -> bool:
316
329
  url = self._file_url(file_id)
317
330
  resp = self.client.get(url, headers=self._headers())
318
331
  if resp.status_code == 200:
319
332
  return True
320
- if resp.status_code == 404:
333
+ if self._is_missing(resp):
321
334
  return False
322
335
  raise APIRequestFailed(url, resp.status_code, resp.text)
323
336
 
@@ -326,7 +339,7 @@ class FilesAPI:
326
339
  resp = await self.aclient.get(url, headers=self._headers())
327
340
  if resp.status_code == 200:
328
341
  return True
329
- if resp.status_code == 404:
342
+ if self._is_missing(resp):
330
343
  return False
331
344
  raise APIRequestFailed(url, resp.status_code, resp.text)
332
345
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tina-python
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: tina is in your computer!
5
5
  Home-page: https://gitee.com/wang-churi/tina
6
6
  Author: 王出日
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes