praisonaiagents 0.0.108__py3-none-any.whl → 0.0.109__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.
- praisonaiagents/agent/agent.py +42 -3
- {praisonaiagents-0.0.108.dist-info → praisonaiagents-0.0.109.dist-info}/METADATA +1 -1
- {praisonaiagents-0.0.108.dist-info → praisonaiagents-0.0.109.dist-info}/RECORD +5 -5
- {praisonaiagents-0.0.108.dist-info → praisonaiagents-0.0.109.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.108.dist-info → praisonaiagents-0.0.109.dist-info}/top_level.txt +0 -0
praisonaiagents/agent/agent.py
CHANGED
@@ -373,7 +373,9 @@ class Agent:
|
|
373
373
|
user_id: Optional[str] = None,
|
374
374
|
reasoning_steps: bool = False,
|
375
375
|
guardrail: Optional[Union[Callable[['TaskOutput'], Tuple[bool, Any]], str]] = None,
|
376
|
-
max_guardrail_retries: int = 3
|
376
|
+
max_guardrail_retries: int = 3,
|
377
|
+
base_url: Optional[str] = None,
|
378
|
+
api_key: Optional[str] = None
|
377
379
|
):
|
378
380
|
"""Initialize an Agent instance.
|
379
381
|
|
@@ -457,6 +459,10 @@ class Agent:
|
|
457
459
|
description string for LLM-based validation. Defaults to None.
|
458
460
|
max_guardrail_retries (int, optional): Maximum number of retry attempts when guardrail
|
459
461
|
validation fails before giving up. Defaults to 3.
|
462
|
+
base_url (Optional[str], optional): Base URL for custom LLM endpoints (e.g., Ollama).
|
463
|
+
If provided, automatically creates a custom LLM instance. Defaults to None.
|
464
|
+
api_key (Optional[str], optional): API key for LLM provider. If not provided,
|
465
|
+
falls back to environment variables. Defaults to None.
|
460
466
|
|
461
467
|
Raises:
|
462
468
|
ValueError: If all of name, role, goal, backstory, and instructions are None.
|
@@ -503,10 +509,40 @@ class Agent:
|
|
503
509
|
# Check for model name in environment variable if not provided
|
504
510
|
self._using_custom_llm = False
|
505
511
|
|
512
|
+
# If base_url is provided, always create a custom LLM instance
|
513
|
+
if base_url:
|
514
|
+
try:
|
515
|
+
from ..llm.llm import LLM
|
516
|
+
# Handle different llm parameter types with base_url
|
517
|
+
if isinstance(llm, dict):
|
518
|
+
# Merge base_url and api_key into the dict
|
519
|
+
llm_config = llm.copy()
|
520
|
+
llm_config['base_url'] = base_url
|
521
|
+
if api_key:
|
522
|
+
llm_config['api_key'] = api_key
|
523
|
+
self.llm_instance = LLM(**llm_config)
|
524
|
+
else:
|
525
|
+
# Create LLM with model string and base_url
|
526
|
+
model_name = llm or os.getenv('OPENAI_MODEL_NAME', 'gpt-4o')
|
527
|
+
self.llm_instance = LLM(
|
528
|
+
model=model_name,
|
529
|
+
base_url=base_url,
|
530
|
+
api_key=api_key
|
531
|
+
)
|
532
|
+
self._using_custom_llm = True
|
533
|
+
except ImportError as e:
|
534
|
+
raise ImportError(
|
535
|
+
"LLM features requested but dependencies not installed. "
|
536
|
+
"Please install with: pip install \"praisonaiagents[llm]\""
|
537
|
+
) from e
|
506
538
|
# If the user passes a dictionary (for advanced configuration)
|
507
|
-
|
539
|
+
elif isinstance(llm, dict) and "model" in llm:
|
508
540
|
try:
|
509
541
|
from ..llm.llm import LLM
|
542
|
+
# Add api_key if provided and not in dict
|
543
|
+
if api_key and 'api_key' not in llm:
|
544
|
+
llm = llm.copy()
|
545
|
+
llm['api_key'] = api_key
|
510
546
|
self.llm_instance = LLM(**llm) # Pass all dict items as kwargs
|
511
547
|
self._using_custom_llm = True
|
512
548
|
except ImportError as e:
|
@@ -519,7 +555,10 @@ class Agent:
|
|
519
555
|
try:
|
520
556
|
from ..llm.llm import LLM
|
521
557
|
# Pass the entire string so LiteLLM can parse provider/model
|
522
|
-
|
558
|
+
llm_params = {'model': llm}
|
559
|
+
if api_key:
|
560
|
+
llm_params['api_key'] = api_key
|
561
|
+
self.llm_instance = LLM(**llm_params)
|
523
562
|
self._using_custom_llm = True
|
524
563
|
|
525
564
|
# Ensure tools are properly accessible when using custom LLM
|
@@ -3,7 +3,7 @@ praisonaiagents/approval.py,sha256=UJ4OhfihpFGR5CAaMphqpSvqdZCHi5w2MGw1MByZ1FQ,9
|
|
3
3
|
praisonaiagents/main.py,sha256=_-XE7_Y7ChvtLQMivfNFrrnAhv4wSSDhH9WJMWlkS0w,16315
|
4
4
|
praisonaiagents/session.py,sha256=d-CZPYikOHb0q-H9f_IWKJsypnQfz1YKeLLkyxs6oDo,15532
|
5
5
|
praisonaiagents/agent/__init__.py,sha256=j0T19TVNbfZcClvpbZDDinQxZ0oORgsMrMqx16jZ-bA,128
|
6
|
-
praisonaiagents/agent/agent.py,sha256=
|
6
|
+
praisonaiagents/agent/agent.py,sha256=VILZRrFbUJFF_gtATMfx-fpqoBMMwyiRmvBWo9592Ds,112093
|
7
7
|
praisonaiagents/agent/image_agent.py,sha256=-5MXG594HVwSpFMcidt16YBp7udtik-Cp7eXlzLE1fY,8696
|
8
8
|
praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
|
9
9
|
praisonaiagents/agents/agents.py,sha256=C_yDdJB4XUuwKA9DrysAtAj3zSYT0IKtfCT4Pxo0oyI,63309
|
@@ -51,7 +51,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
|
|
51
51
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
52
52
|
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
53
53
|
praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
|
54
|
-
praisonaiagents-0.0.
|
55
|
-
praisonaiagents-0.0.
|
56
|
-
praisonaiagents-0.0.
|
57
|
-
praisonaiagents-0.0.
|
54
|
+
praisonaiagents-0.0.109.dist-info/METADATA,sha256=978n4Xm55N1ZwIQYE4vtLBVqsIuCylWFOEW1bWZTa6g,1669
|
55
|
+
praisonaiagents-0.0.109.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
56
|
+
praisonaiagents-0.0.109.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
57
|
+
praisonaiagents-0.0.109.dist-info/RECORD,,
|
File without changes
|
File without changes
|