ai-pipeline-core 0.2.7__py3-none-any.whl → 0.2.8__py3-none-any.whl

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.
@@ -118,7 +118,7 @@ from .prompt_manager import PromptManager
118
118
  from .settings import Settings
119
119
  from .tracing import TraceInfo, TraceLevel, set_trace_cost, trace
120
120
 
121
- __version__ = "0.2.7"
121
+ __version__ = "0.2.8"
122
122
 
123
123
  __all__ = [
124
124
  # Config/Settings
@@ -61,11 +61,11 @@ class FlowOptions(BaseSettings):
61
61
  """
62
62
 
63
63
  core_model: ModelName = Field(
64
- default="gpt-5",
64
+ default="gemini-2.5-pro",
65
65
  description="Primary model for complex analysis and generation tasks.",
66
66
  )
67
67
  small_model: ModelName = Field(
68
- default="gpt-5-mini",
68
+ default="grok-4-fast",
69
69
  description="Fast, cost-effective model for simple tasks and orchestration.",
70
70
  )
71
71
 
@@ -108,6 +108,38 @@ def _process_messages(
108
108
  return processed_messages
109
109
 
110
110
 
111
+ def _remove_cache_control(
112
+ messages: list[ChatCompletionMessageParam],
113
+ ) -> list[ChatCompletionMessageParam]:
114
+ """Remove cache control directives from messages.
115
+
116
+ Internal utility that strips cache_control fields from both message-level
117
+ and content-level entries. Used in retry logic when cache-related errors
118
+ occur during LLM API calls.
119
+
120
+ Args:
121
+ messages: List of messages that may contain cache_control directives.
122
+
123
+ Returns:
124
+ The same message list (modified in-place) with all cache_control
125
+ fields removed from both messages and their content items.
126
+
127
+ Note:
128
+ This function modifies the input list in-place but also returns it
129
+ for convenience. Handles both list-based content (multipart) and
130
+ string content (simple messages).
131
+ """
132
+ for message in messages:
133
+ if content := message.get("content"):
134
+ if isinstance(content, list):
135
+ for item in content:
136
+ if "cache_control" in item:
137
+ del item["cache_control"]
138
+ if "cache_control" in message:
139
+ del message["cache_control"]
140
+ return messages # type: ignore
141
+
142
+
111
143
  def _model_name_to_openrouter_model(model: ModelName) -> str:
112
144
  """Convert a model name to an OpenRouter model name.
113
145
 
@@ -242,7 +274,7 @@ async def _generate_with_retry(
242
274
  if not context and not messages:
243
275
  raise ValueError("Either context or messages must be provided")
244
276
 
245
- if "gemini" in model.lower() and context.approximate_tokens_count < 5000:
277
+ if "gemini" in model.lower() and context.approximate_tokens_count < 10000:
246
278
  # Bug fix for minimum explicit context size for Gemini models
247
279
  options.cache_ttl = None
248
280
 
@@ -272,6 +304,8 @@ async def _generate_with_retry(
272
304
  if not isinstance(e, asyncio.TimeoutError):
273
305
  # disable cache if it's not a timeout because it may cause an error
274
306
  completion_kwargs["extra_body"]["cache"] = {"no-cache": True}
307
+ # sometimes there are issues with cache so cache is removed in case of failure
308
+ processed_messages = _remove_cache_control(processed_messages)
275
309
 
276
310
  logger.warning(
277
311
  f"LLM generation failed (attempt {attempt + 1}/{options.retries}): {e}",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-pipeline-core
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Core utilities for AI-powered processing pipelines using prefect
5
5
  Project-URL: Homepage, https://github.com/bbarwik/ai-pipeline-core
6
6
  Project-URL: Repository, https://github.com/bbarwik/ai-pipeline-core
@@ -1,4 +1,4 @@
1
- ai_pipeline_core/__init__.py,sha256=SCyd40nB8yF10KylHMBhEdpF0slV35OTsIePEKi9GP8,5720
1
+ ai_pipeline_core/__init__.py,sha256=NMpeyF-rJdNnNWfi9eoOgWNnk7kOVHqvSZq3cnyDuCI,5720
2
2
  ai_pipeline_core/exceptions.py,sha256=vx-XLTw2fJSPs-vwtXVYtqoQUcOc0JeI7UmHqRqQYWU,1569
3
3
  ai_pipeline_core/pipeline.py,sha256=fWTVmrnOEIFge6o2NUYW2ndGef5UurpL8_fK5tkXbzI,28700
4
4
  ai_pipeline_core/prefect.py,sha256=91ZgLJHsDsRUW77CpNmkKxYs3RCJuucPM3pjKmNBeDg,2199
@@ -16,10 +16,10 @@ ai_pipeline_core/documents/temporary_document.py,sha256=Sam344Mm5AlZTm3_l01YdDWe
16
16
  ai_pipeline_core/documents/utils.py,sha256=ZyJNjFN7ihWno0K7dJZed7twYmmPLA0z40UzFw1A3A8,5465
17
17
  ai_pipeline_core/flow/__init__.py,sha256=2BfWYMOPYW5teGzwo-qzpn_bom1lxxry0bPsjVgcsCk,188
18
18
  ai_pipeline_core/flow/config.py,sha256=3PCDph2n8dj-txqAvd9Wflbi_6lmfXFR9rUhM-szGSQ,18887
19
- ai_pipeline_core/flow/options.py,sha256=2rKR2GifhXcyw8avI_oiEDMLC2jm5Qzpw8z56pbxUMo,2285
19
+ ai_pipeline_core/flow/options.py,sha256=zn3N5DgYtlxLq0AvXfana3UOhym7A3XCheQSBIIarZE,2295
20
20
  ai_pipeline_core/llm/__init__.py,sha256=3B_vtEzxrzidP1qOUNQ4RxlUmxZ2MBKQcUhQiTybM9g,661
21
21
  ai_pipeline_core/llm/ai_messages.py,sha256=Onin3UPdbJQNl3WfY3-_jE5KRmF-ciXsa5K6UPOiy5s,14410
22
- ai_pipeline_core/llm/client.py,sha256=385nKrr5fbDha8lNe9AbGLJ9Eszzo3_ArC22WWd8T_s,23646
22
+ ai_pipeline_core/llm/client.py,sha256=Da1NgGzfIkFRw_aDASK36MMdKe3DXaj5_3wMg0gR-Hk,24999
23
23
  ai_pipeline_core/llm/model_options.py,sha256=uRNIHfVeh2sgt1mZBiOUx6hPQ6GKjB8b7TytZJ6afKg,11768
24
24
  ai_pipeline_core/llm/model_response.py,sha256=6kEr9ss3UGlykvtWAvh1l55rGw2-wyVup3QJhm0Oggc,13264
25
25
  ai_pipeline_core/llm/model_types.py,sha256=2J4Qsb1x21I4eo_VPeaMMOW8shOGPqzJuoGjTLcBFPM,2791
@@ -35,7 +35,7 @@ ai_pipeline_core/storage/storage.py,sha256=ClMr419Y-eU2RuOjZYd51dC0stWQk28Vb56Pv
35
35
  ai_pipeline_core/utils/__init__.py,sha256=TJSmEm1Quf-gKwXrxM96u2IGzVolUyeNNfLMPoLstXI,254
36
36
  ai_pipeline_core/utils/deploy.py,sha256=rAtRuwkmGkc-fqvDMXpt08OzLrD7KTDMAmLDC9wYg7Y,13147
37
37
  ai_pipeline_core/utils/remote_deployment.py,sha256=cPTgnS5InK08qiWnuPz3e8YKjoT3sPBloSaDfNTzghs,10137
38
- ai_pipeline_core-0.2.7.dist-info/METADATA,sha256=Ec4yFJTtt8qFtQD4Hg7KXT2VO80_i8JmLbwfXNia2GE,15159
39
- ai_pipeline_core-0.2.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
40
- ai_pipeline_core-0.2.7.dist-info/licenses/LICENSE,sha256=kKj8mfbdWwkyG3U6n7ztB3bAZlEwShTkAsvaY657i3I,1074
41
- ai_pipeline_core-0.2.7.dist-info/RECORD,,
38
+ ai_pipeline_core-0.2.8.dist-info/METADATA,sha256=Sl_8s24ar0lwa7iio4d0QYDhzsmAIGHHqOKuXnFxP7s,15159
39
+ ai_pipeline_core-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
40
+ ai_pipeline_core-0.2.8.dist-info/licenses/LICENSE,sha256=kKj8mfbdWwkyG3U6n7ztB3bAZlEwShTkAsvaY657i3I,1074
41
+ ai_pipeline_core-0.2.8.dist-info/RECORD,,