nvidia-nat-crewai 1.4.0a20251015__py3-none-any.whl → 1.4.0a20251021__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.
@@ -154,13 +154,16 @@ class CrewAIProfilerHandler(BaseProfilerCallback):
154
154
  seconds_between_calls = int(now - self.last_call_ts)
155
155
  model_name = kwargs.get('model', "")
156
156
 
157
- model_input = ""
157
+ model_input = []
158
158
  try:
159
159
  for message in kwargs.get('messages', []):
160
- model_input += message.get('content', "")
160
+ content = message.get('content', "")
161
+ model_input.append("" if content is None else str(content))
161
162
  except Exception as e:
162
163
  logger.exception("Error getting model input: %s", e)
163
164
 
165
+ model_input = "".join(model_input)
166
+
164
167
  # Record the start event
165
168
  input_stats = IntermediateStepPayload(
166
169
  event_type=IntermediateStepType.LLM_START,
@@ -177,14 +180,17 @@ class CrewAIProfilerHandler(BaseProfilerCallback):
177
180
  # Call the original litellm.completion(...)
178
181
  output = original_func(*args, **kwargs)
179
182
 
180
- model_output = ""
183
+ model_output = []
181
184
  try:
182
185
  for choice in output.choices:
183
186
  msg = choice.model_extra["message"]
184
- model_output += msg.get('content', "")
187
+ content = msg.get('content', "")
188
+ model_output.append("" if content is None else str(content))
185
189
  except Exception as e:
186
190
  logger.exception("Error getting model output: %s", e)
187
191
 
192
+ model_output = "".join(model_output)
193
+
188
194
  now = time.time()
189
195
  # Record the end event
190
196
  output_stats = IntermediateStepPayload(
nat/plugins/crewai/llm.py CHANGED
@@ -30,6 +30,7 @@ from nat.llm.utils.thinking import BaseThinkingInjector
30
30
  from nat.llm.utils.thinking import FunctionArgumentWrapper
31
31
  from nat.llm.utils.thinking import patch_with_thinking
32
32
  from nat.utils.exception_handlers.automatic_retries import patch_with_retry
33
+ from nat.utils.responses_api import validate_no_responses_api
33
34
  from nat.utils.type_utils import override
34
35
 
35
36
  ModelType = TypeVar("ModelType")
@@ -41,8 +42,17 @@ def _patch_llm_based_on_config(client: ModelType, llm_config: LLMBaseConfig) ->
41
42
 
42
43
  @override
43
44
  def inject(self, messages: list[dict[str, str]], *args, **kwargs) -> FunctionArgumentWrapper:
44
- new_messages = [{"role": "system", "content": self.system_prompt}] + messages
45
- return FunctionArgumentWrapper(new_messages, *args, **kwargs)
45
+ # Attempt to inject the system prompt into the first system message
46
+ for i, message in enumerate(messages):
47
+ if message["role"] == "system":
48
+ if self.system_prompt not in message["content"]:
49
+ messages = list(messages)
50
+ messages[i] = {"role": "system", "content": f"{message['content']}\n{self.system_prompt}"}
51
+ break
52
+ else:
53
+ messages = list(messages)
54
+ messages.insert(0, {"role": "system", "content": self.system_prompt})
55
+ return FunctionArgumentWrapper(messages, *args, **kwargs)
46
56
 
47
57
  if isinstance(llm_config, RetryMixin):
48
58
  client = patch_with_retry(client,
@@ -65,6 +75,8 @@ async def azure_openai_crewai(llm_config: AzureOpenAIModelConfig, _builder: Buil
65
75
 
66
76
  from crewai import LLM
67
77
 
78
+ validate_no_responses_api(llm_config, LLMFrameworkEnum.CREWAI)
79
+
68
80
  # https://docs.crewai.com/en/concepts/llms#azure
69
81
 
70
82
  api_key = llm_config.api_key or os.environ.get("AZURE_OPENAI_API_KEY") or os.environ.get("AZURE_API_KEY")
@@ -84,13 +96,7 @@ async def azure_openai_crewai(llm_config: AzureOpenAIModelConfig, _builder: Buil
84
96
 
85
97
  client = LLM(
86
98
  **llm_config.model_dump(
87
- exclude={
88
- "type",
89
- "api_key",
90
- "azure_endpoint",
91
- "azure_deployment",
92
- "thinking",
93
- },
99
+ exclude={"type", "api_key", "azure_endpoint", "azure_deployment", "thinking", "api_type"},
94
100
  by_alias=True,
95
101
  exclude_none=True,
96
102
  ),
@@ -105,6 +111,8 @@ async def nim_crewai(llm_config: NIMModelConfig, _builder: Builder):
105
111
 
106
112
  from crewai import LLM
107
113
 
114
+ validate_no_responses_api(llm_config, LLMFrameworkEnum.CREWAI)
115
+
108
116
  # Because CrewAI uses a different environment variable for the API key, we need to set it here manually
109
117
  if llm_config.api_key is None and "NVIDIA_NIM_API_KEY" not in os.environ:
110
118
  nvidia_api_key = os.getenv("NVIDIA_API_KEY")
@@ -112,7 +120,9 @@ async def nim_crewai(llm_config: NIMModelConfig, _builder: Builder):
112
120
  os.environ["NVIDIA_NIM_API_KEY"] = nvidia_api_key
113
121
 
114
122
  client = LLM(
115
- **llm_config.model_dump(exclude={"type", "model_name", "thinking"}, by_alias=True, exclude_none=True),
123
+ **llm_config.model_dump(exclude={"type", "model_name", "thinking", "api_type"},
124
+ by_alias=True,
125
+ exclude_none=True),
116
126
  model=f"nvidia_nim/{llm_config.model_name}",
117
127
  )
118
128
 
@@ -124,7 +134,9 @@ async def openai_crewai(llm_config: OpenAIModelConfig, _builder: Builder):
124
134
 
125
135
  from crewai import LLM
126
136
 
127
- client = LLM(**llm_config.model_dump(exclude={"type", "thinking"}, by_alias=True, exclude_none=True))
137
+ validate_no_responses_api(llm_config, LLMFrameworkEnum.CREWAI)
138
+
139
+ client = LLM(**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
128
140
 
129
141
  yield _patch_llm_based_on_config(client, llm_config)
130
142
 
@@ -134,6 +146,8 @@ async def litellm_crewai(llm_config: LiteLlmModelConfig, _builder: Builder):
134
146
 
135
147
  from crewai import LLM
136
148
 
137
- client = LLM(**llm_config.model_dump(exclude={"type", "thinking"}, by_alias=True, exclude_none=True))
149
+ validate_no_responses_api(llm_config, LLMFrameworkEnum.CREWAI)
150
+
151
+ client = LLM(**llm_config.model_dump(exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True))
138
152
 
139
153
  yield _patch_llm_based_on_config(client, llm_config)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nvidia-nat-crewai
3
- Version: 1.4.0a20251015
3
+ Version: 1.4.0a20251021
4
4
  Summary: Subpackage for CrewAI integration in NeMo Agent toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -16,7 +16,7 @@ Requires-Python: <3.14,>=3.11
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE-3rd-party.txt
18
18
  License-File: LICENSE.md
19
- Requires-Dist: nvidia-nat[litellm]==v1.4.0a20251015
19
+ Requires-Dist: nvidia-nat[litellm]==v1.4.0a20251021
20
20
  Requires-Dist: crewai~=0.193.2
21
21
  Dynamic: license-file
22
22
 
@@ -0,0 +1,13 @@
1
+ nat/meta/pypi.md,sha256=T68FnThRzDGFf1LR8u-okM-r11-skSnKqSyI6HOktQY,1107
2
+ nat/plugins/crewai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nat/plugins/crewai/crewai_callback_handler.py,sha256=il537F5tD9pFL1P9Q38ReOZasD-GgcBrm8BX_w0-xdo,8582
4
+ nat/plugins/crewai/llm.py,sha256=FqJZBYlOERcS2FoAZbrinNgY56TFfYPpE2Gq4txMc_M,6335
5
+ nat/plugins/crewai/register.py,sha256=_R3bhGmz___696_NwyIcpw3koMBiWqIFoWEFJ0VAgXs,831
6
+ nat/plugins/crewai/tool_wrapper.py,sha256=BNKEPQQCLKtXNzGDAKBLCdmGJXe9lBOVI1hObha8hoI,1569
7
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
8
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
9
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/METADATA,sha256=4PawAUpniHnM3ft9WTytf1lgSItqSVPpmALE3iIw8wQ,1922
10
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/entry_points.txt,sha256=YF5PUdQGr_OUDXB4TykElHJTsKT8yKkuE0bMX5n_RXs,58
12
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
13
+ nvidia_nat_crewai-1.4.0a20251021.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- nat/meta/pypi.md,sha256=T68FnThRzDGFf1LR8u-okM-r11-skSnKqSyI6HOktQY,1107
2
- nat/plugins/crewai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- nat/plugins/crewai/crewai_callback_handler.py,sha256=m5u0RqUd94F0iIuUvknhVHn1SxYltg3lxAhN_3AogPQ,8334
4
- nat/plugins/crewai/llm.py,sha256=T57f7hZ5Aa4MUdc6PJLfU6TkF_dO87DWh2KvyAsCt7g,5493
5
- nat/plugins/crewai/register.py,sha256=_R3bhGmz___696_NwyIcpw3koMBiWqIFoWEFJ0VAgXs,831
6
- nat/plugins/crewai/tool_wrapper.py,sha256=BNKEPQQCLKtXNzGDAKBLCdmGJXe9lBOVI1hObha8hoI,1569
7
- nvidia_nat_crewai-1.4.0a20251015.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
8
- nvidia_nat_crewai-1.4.0a20251015.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
9
- nvidia_nat_crewai-1.4.0a20251015.dist-info/METADATA,sha256=X8fdQKjCOFYcJJ4QOG30k4CsMdB1HupTXtlAOjmJRb0,1922
10
- nvidia_nat_crewai-1.4.0a20251015.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- nvidia_nat_crewai-1.4.0a20251015.dist-info/entry_points.txt,sha256=YF5PUdQGr_OUDXB4TykElHJTsKT8yKkuE0bMX5n_RXs,58
12
- nvidia_nat_crewai-1.4.0a20251015.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
13
- nvidia_nat_crewai-1.4.0a20251015.dist-info/RECORD,,