aiqtoolkit 1.2.0a20250530__py3-none-any.whl → 1.2.0a20250531__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.
Potentially problematic release.
This version of aiqtoolkit might be problematic. Click here for more details.
- aiq/agent/react_agent/agent.py +34 -1
- aiq/agent/react_agent/prompt.py +1 -6
- aiq/agent/react_agent/register.py +5 -21
- aiq/llm/aws_bedrock_llm.py +56 -0
- aiq/llm/register.py +1 -0
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/METADATA +1 -1
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/RECORD +12 -11
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/WHEEL +0 -0
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/entry_points.txt +0 -0
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/licenses/LICENSE.md +0 -0
- {aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/top_level.txt +0 -0
aiq/agent/react_agent/agent.py
CHANGED
|
@@ -26,7 +26,8 @@ from langchain_core.messages.ai import AIMessage
|
|
|
26
26
|
from langchain_core.messages.base import BaseMessage
|
|
27
27
|
from langchain_core.messages.human import HumanMessage
|
|
28
28
|
from langchain_core.messages.tool import ToolMessage
|
|
29
|
-
from langchain_core.prompts
|
|
29
|
+
from langchain_core.prompts import ChatPromptTemplate
|
|
30
|
+
from langchain_core.prompts import MessagesPlaceholder
|
|
30
31
|
from langchain_core.runnables.config import RunnableConfig
|
|
31
32
|
from langchain_core.tools import BaseTool
|
|
32
33
|
from pydantic import BaseModel
|
|
@@ -42,6 +43,9 @@ from aiq.agent.base import AgentDecision
|
|
|
42
43
|
from aiq.agent.dual_node import DualNodeAgent
|
|
43
44
|
from aiq.agent.react_agent.output_parser import ReActOutputParser
|
|
44
45
|
from aiq.agent.react_agent.output_parser import ReActOutputParserException
|
|
46
|
+
from aiq.agent.react_agent.prompt import SYSTEM_PROMPT
|
|
47
|
+
from aiq.agent.react_agent.prompt import USER_PROMPT
|
|
48
|
+
from aiq.agent.react_agent.register import ReActAgentWorkflowConfig
|
|
45
49
|
|
|
46
50
|
logger = logging.getLogger(__name__)
|
|
47
51
|
|
|
@@ -320,3 +324,32 @@ class ReActAgentGraph(DualNodeAgent):
|
|
|
320
324
|
logger.exception("%s %s", AGENT_LOG_PREFIX, error_text)
|
|
321
325
|
raise ValueError(error_text)
|
|
322
326
|
return True
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def create_react_agent_prompt(config: ReActAgentWorkflowConfig) -> ChatPromptTemplate:
|
|
330
|
+
"""
|
|
331
|
+
Create a ReAct Agent prompt from the config.
|
|
332
|
+
|
|
333
|
+
Args:
|
|
334
|
+
config (ReActAgentWorkflowConfig): The config to use for the prompt.
|
|
335
|
+
|
|
336
|
+
Returns:
|
|
337
|
+
ChatPromptTemplate: The ReAct Agent prompt.
|
|
338
|
+
"""
|
|
339
|
+
# the ReAct Agent prompt can be customized via config option system_prompt and additional_instructions.
|
|
340
|
+
|
|
341
|
+
if config.system_prompt:
|
|
342
|
+
prompt_str = config.system_prompt
|
|
343
|
+
else:
|
|
344
|
+
prompt_str = SYSTEM_PROMPT
|
|
345
|
+
|
|
346
|
+
if config.additional_instructions:
|
|
347
|
+
prompt_str += f" {config.additional_instructions}"
|
|
348
|
+
|
|
349
|
+
valid_prompt = ReActAgentGraph.validate_system_prompt(prompt_str)
|
|
350
|
+
if not valid_prompt:
|
|
351
|
+
logger.exception("%s Invalid system_prompt", AGENT_LOG_PREFIX)
|
|
352
|
+
raise ValueError("Invalid system_prompt")
|
|
353
|
+
prompt = ChatPromptTemplate([("system", prompt_str), ("user", USER_PROMPT),
|
|
354
|
+
MessagesPlaceholder(variable_name='agent_scratchpad', optional=True)])
|
|
355
|
+
return prompt
|
aiq/agent/react_agent/prompt.py
CHANGED
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
16
|
# flake8: noqa
|
|
17
|
-
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
18
|
-
from langchain_core.prompts.chat import MessagesPlaceholder
|
|
19
17
|
|
|
20
18
|
SYSTEM_PROMPT = """
|
|
21
19
|
Answer the following questions as best you can. You may ask the human to use the following tools:
|
|
@@ -37,10 +35,7 @@ Use the following format once you have the final answer:
|
|
|
37
35
|
Thought: I now know the final answer
|
|
38
36
|
Final Answer: the final answer to the original input question
|
|
39
37
|
"""
|
|
38
|
+
|
|
40
39
|
USER_PROMPT = """
|
|
41
40
|
Question: {question}
|
|
42
41
|
"""
|
|
43
|
-
|
|
44
|
-
# This is the prompt - (ReAct Agent prompt)
|
|
45
|
-
react_agent_prompt = ChatPromptTemplate([("system", SYSTEM_PROMPT), ("user", USER_PROMPT),
|
|
46
|
-
MessagesPlaceholder(variable_name='agent_scratchpad', optional=True)])
|
|
@@ -63,29 +63,13 @@ class ReActAgentWorkflowConfig(FunctionBaseConfig, name="react_agent"):
|
|
|
63
63
|
async def react_agent_workflow(config: ReActAgentWorkflowConfig, builder: Builder):
|
|
64
64
|
from langchain.schema import BaseMessage
|
|
65
65
|
from langchain_core.messages import trim_messages
|
|
66
|
-
from langchain_core.prompts import ChatPromptTemplate
|
|
67
|
-
from langchain_core.prompts import MessagesPlaceholder
|
|
68
66
|
from langgraph.graph.graph import CompiledGraph
|
|
69
67
|
|
|
70
|
-
from aiq.agent.react_agent.
|
|
71
|
-
|
|
72
|
-
from .agent import
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# the ReAct Agent prompt comes from prompt.py, and can be customized there or via config option system_prompt.
|
|
77
|
-
if config.system_prompt:
|
|
78
|
-
_prompt_str = config.system_prompt
|
|
79
|
-
if config.additional_instructions:
|
|
80
|
-
_prompt_str += f" {config.additional_instructions}"
|
|
81
|
-
valid_prompt = ReActAgentGraph.validate_system_prompt(config.system_prompt)
|
|
82
|
-
if not valid_prompt:
|
|
83
|
-
logger.exception("%s Invalid system_prompt", AGENT_LOG_PREFIX)
|
|
84
|
-
raise ValueError("Invalid system_prompt")
|
|
85
|
-
prompt = ChatPromptTemplate([("system", config.system_prompt), ("user", USER_PROMPT),
|
|
86
|
-
MessagesPlaceholder(variable_name='agent_scratchpad', optional=True)])
|
|
87
|
-
else:
|
|
88
|
-
prompt = react_agent_prompt
|
|
68
|
+
from aiq.agent.react_agent.agent import ReActAgentGraph
|
|
69
|
+
from aiq.agent.react_agent.agent import ReActGraphState
|
|
70
|
+
from aiq.agent.react_agent.agent import create_react_agent_prompt
|
|
71
|
+
|
|
72
|
+
prompt = create_react_agent_prompt(config)
|
|
89
73
|
|
|
90
74
|
# we can choose an LLM for the ReAct agent in the config file
|
|
91
75
|
llm = await builder.get_llm(config.llm_name, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
from pydantic import AliasChoices
|
|
17
|
+
from pydantic import ConfigDict
|
|
18
|
+
from pydantic import Field
|
|
19
|
+
|
|
20
|
+
from aiq.builder.builder import Builder
|
|
21
|
+
from aiq.builder.llm import LLMProviderInfo
|
|
22
|
+
from aiq.cli.register_workflow import register_llm_provider
|
|
23
|
+
from aiq.data_models.llm import LLMBaseConfig
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AWSBedrockModelConfig(LLMBaseConfig, name="aws_bedrock"):
|
|
27
|
+
"""An AWS Bedrock llm provider to be used with an LLM client."""
|
|
28
|
+
|
|
29
|
+
model_config = ConfigDict(protected_namespaces=())
|
|
30
|
+
|
|
31
|
+
# Completion parameters
|
|
32
|
+
model_name: str = Field(validation_alias=AliasChoices("model_name", "model"),
|
|
33
|
+
serialization_alias="model",
|
|
34
|
+
description="The model name for the hosted AWS Bedrock.")
|
|
35
|
+
temperature: float = Field(default=0.0, ge=0.0, le=1.0, description="Sampling temperature in [0, 1].")
|
|
36
|
+
max_tokens: int | None = Field(default=1024,
|
|
37
|
+
gt=0,
|
|
38
|
+
description="Maximum number of tokens to generate."
|
|
39
|
+
"This field is ONLY required when using AWS Bedrock with Langchain.")
|
|
40
|
+
context_size: int | None = Field(default=1024,
|
|
41
|
+
gt=0,
|
|
42
|
+
description="Maximum number of tokens to generate."
|
|
43
|
+
"This field is ONLY required when using AWS Bedrock with LlamaIndex.")
|
|
44
|
+
|
|
45
|
+
# Client parameters
|
|
46
|
+
region_name: str | None = Field(default="None", description="AWS region to use.")
|
|
47
|
+
base_url: str | None = Field(
|
|
48
|
+
default=None, description="Bedrock endpoint to use. Needed if you don't want to default to us-east-1 endpoint.")
|
|
49
|
+
credentials_profile_name: str | None = Field(
|
|
50
|
+
default=None, description="The name of the profile in the ~/.aws/credentials or ~/.aws/config files.")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@register_llm_provider(config_type=AWSBedrockModelConfig)
|
|
54
|
+
async def aws_bedrock_model(llm_config: AWSBedrockModelConfig, builder: Builder):
|
|
55
|
+
|
|
56
|
+
yield LLMProviderInfo(config=llm_config, description="A AWS Bedrock model for use with an LLM client.")
|
aiq/llm/register.py
CHANGED
|
@@ -3,10 +3,10 @@ aiq/agent/base.py,sha256=xN4dlt5tKlINialduBbMEIuh_XC2x5-hz5JCkPjRGb0,2931
|
|
|
3
3
|
aiq/agent/dual_node.py,sha256=JGrXJrYLLiEMh-4Bd1k3mC-X6vgQgUXIR7qAHWfkZH0,2346
|
|
4
4
|
aiq/agent/register.py,sha256=EATlFFl7ov5HNGySLcPv1T7jzV-Jy-jPVkUzSXDT-7s,1005
|
|
5
5
|
aiq/agent/react_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
aiq/agent/react_agent/agent.py,sha256=
|
|
6
|
+
aiq/agent/react_agent/agent.py,sha256=ssqpoBz_6pV9WR6XMzs20CSE9qQgM6t7n3iQd9rqBUQ,20091
|
|
7
7
|
aiq/agent/react_agent/output_parser.py,sha256=m7K6wRwtckBBpAHqOf3BZ9mqZLwrP13Kxz5fvNxbyZE,4219
|
|
8
|
-
aiq/agent/react_agent/prompt.py,sha256=
|
|
9
|
-
aiq/agent/react_agent/register.py,sha256=
|
|
8
|
+
aiq/agent/react_agent/prompt.py,sha256=iGPBU6kh1xbp4QsU1p3o4A0JDov23J1EVM3HSAX6S0A,1713
|
|
9
|
+
aiq/agent/react_agent/register.py,sha256=CnaEd-DVuBF6WXWeHfEsDOWpfACybyA5vXFT7Xp1rK0,7297
|
|
10
10
|
aiq/agent/reasoning_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
aiq/agent/reasoning_agent/reasoning_agent.py,sha256=1grbjv8c3neFgcTAl8qYeyPJ3B6gcEqkR6I68LOFPT8,9453
|
|
12
12
|
aiq/agent/rewoo_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -161,9 +161,10 @@ aiq/front_ends/mcp/tool_converter.py,sha256=Pgb06Gtb8MVWeV_dAaI4Tl0Hono_mSuJAHRx
|
|
|
161
161
|
aiq/front_ends/simple_base/__init__.py,sha256=Xs1JQ16L9btwreh4pdGKwskffAw1YFO48jKrU4ib_7c,685
|
|
162
162
|
aiq/front_ends/simple_base/simple_front_end_plugin_base.py,sha256=HzcJFHZUZFnZJdw4YcRTG6nQbTDoBQSgKO6vwifSomk,1684
|
|
163
163
|
aiq/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
|
+
aiq/llm/aws_bedrock_llm.py,sha256=ZbYnT0vf36xCsnGAxDAQ3ugnV1SdcPXVKVxhhXsjdg0,2773
|
|
164
165
|
aiq/llm/nim_llm.py,sha256=l5dJk4MCzEbIKJnbGen9Zq7tpCEew4OXKeYqDodFXF0,2116
|
|
165
166
|
aiq/llm/openai_llm.py,sha256=ytdcyJTgeuOElfEJzJszSqO2Ck5msDIUJO55oVmugMg,2152
|
|
166
|
-
aiq/llm/register.py,sha256=
|
|
167
|
+
aiq/llm/register.py,sha256=GMsFzhupP_rwSVkIoJUT8j0CRhWyC4X58ihnO_l9OkM,899
|
|
167
168
|
aiq/llm/utils/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
|
|
168
169
|
aiq/llm/utils/env_config_value.py,sha256=SBpppIRszDXNcEEG2L6kVojY7LH_EpHfK7bu92TGrE4,3568
|
|
169
170
|
aiq/llm/utils/error.py,sha256=gFFDG_v_3hBZVWpcD7HWkno-NBHDjXae7qDGnfiCNwA,820
|
|
@@ -307,10 +308,10 @@ aiq/utils/reactive/base/observer_base.py,sha256=UAlyAY_ky4q2t0P81RVFo2Bs_R7z5Nde
|
|
|
307
308
|
aiq/utils/reactive/base/subject_base.py,sha256=Ed-AC6P7cT3qkW1EXjzbd5M9WpVoeN_9KCe3OM3FLU4,2521
|
|
308
309
|
aiq/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
309
310
|
aiq/utils/settings/global_settings.py,sha256=U9TCLdoZsKq5qOVGjREipGVv9e-FlStzqy5zv82_VYk,7454
|
|
310
|
-
aiqtoolkit-1.2.
|
|
311
|
-
aiqtoolkit-1.2.
|
|
312
|
-
aiqtoolkit-1.2.
|
|
313
|
-
aiqtoolkit-1.2.
|
|
314
|
-
aiqtoolkit-1.2.
|
|
315
|
-
aiqtoolkit-1.2.
|
|
316
|
-
aiqtoolkit-1.2.
|
|
311
|
+
aiqtoolkit-1.2.0a20250531.dist-info/licenses/LICENSE-3rd-party.txt,sha256=8o7aySJa9CBvFshPcsRdJbczzdNyDGJ8b0J67WRUQ2k,183936
|
|
312
|
+
aiqtoolkit-1.2.0a20250531.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
313
|
+
aiqtoolkit-1.2.0a20250531.dist-info/METADATA,sha256=U1D2_22-0FolvonqJJpIsfXPiMjti1EqStCYYceYlo8,20174
|
|
314
|
+
aiqtoolkit-1.2.0a20250531.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
315
|
+
aiqtoolkit-1.2.0a20250531.dist-info/entry_points.txt,sha256=gRlPfR5g21t328WNEQ4CcEz80S1sJNS8A7rMDYnzl4A,452
|
|
316
|
+
aiqtoolkit-1.2.0a20250531.dist-info/top_level.txt,sha256=fo7AzYcNhZ_tRWrhGumtxwnxMew4xrT1iwouDy_f0Kc,4
|
|
317
|
+
aiqtoolkit-1.2.0a20250531.dist-info/RECORD,,
|
|
File without changes
|
{aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{aiqtoolkit-1.2.0a20250530.dist-info → aiqtoolkit-1.2.0a20250531.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|