pygeai 0.3.2__py3-none-any.whl → 0.4.0__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.
- pygeai/__init__.py +1 -1
- pygeai/chat/ui.py +0 -1
- pygeai/cli/__init__.py +1 -1
- pygeai/cli/commands/chat.py +54 -56
- pygeai/cli/commands/lab/ai_lab.py +129 -466
- pygeai/cli/commands/lab/options.py +8 -0
- pygeai/cli/commands/lab/utils.py +13 -0
- pygeai/cli/geai.py +5 -2
- pygeai/cli/texts/help.py +12 -0
- pygeai/core/common/config.py +0 -2
- pygeai/core/common/exceptions.py +6 -0
- pygeai/lab/agents/clients.py +30 -61
- pygeai/lab/clients.py +20 -0
- pygeai/lab/managers.py +6 -58
- pygeai/lab/processes/clients.py +81 -129
- pygeai/lab/strategies/clients.py +11 -17
- pygeai/lab/tools/clients.py +59 -59
- pygeai/tests/integration/assistants/__init__.py +0 -0
- pygeai/tests/integration/assistants/rag/__init__.py +0 -0
- pygeai/tests/integration/assistants/rag/test_create_rag.py +72 -0
- pygeai/tests/integration/chat/__init__.py +0 -0
- pygeai/tests/integration/chat/test_generate_image.py +162 -0
- pygeai/tests/integration/lab/agents/test_create_agent.py +9 -13
- pygeai/tests/integration/lab/agents/test_publish_agent_revision.py +0 -1
- pygeai/tests/integration/lab/agents/test_update_agent.py +6 -15
- pygeai/tests/integration/lab/tools/__init__.py +0 -0
- pygeai/tests/integration/lab/tools/test_create_tool.py +292 -0
- pygeai/tests/integration/lab/tools/test_delete_tool.py +87 -0
- pygeai/tests/integration/lab/tools/test_get_parameter.py +98 -0
- pygeai/tests/integration/lab/tools/test_get_tool.py +91 -0
- pygeai/tests/integration/lab/tools/test_list_tools.py +106 -0
- pygeai/tests/integration/lab/tools/test_publish_tool_revision.py +119 -0
- pygeai/tests/integration/lab/tools/test_set_parameter.py +114 -0
- pygeai/tests/integration/lab/tools/test_update_tool.py +268 -0
- pygeai/tests/snippets/lab/agents/create_agent_edge_case.py +48 -0
- pygeai/tests/snippets/lab/agents/create_agent_without_instructions.py +48 -0
- pygeai/tests/snippets/lab/agents/get_sharing_link.py +1 -2
- pygeai/tests/snippets/lab/tools/create_tool.py +1 -1
- pygeai/tests/snippets/lab/tools/create_tool_edge_case.py +50 -0
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/METADATA +1 -1
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/RECORD +45 -25
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/WHEEL +0 -0
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/entry_points.txt +0 -0
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.3.2.dist-info → pygeai-0.4.0.dist-info}/top_level.txt +0 -0
pygeai/__init__.py
CHANGED
pygeai/chat/ui.py
CHANGED
pygeai/cli/__init__.py
CHANGED
pygeai/cli/commands/chat.py
CHANGED
|
@@ -13,12 +13,14 @@ from pygeai.chat.session import AgentChatSession
|
|
|
13
13
|
from pygeai.cli.commands import Command, Option, ArgumentsEnum
|
|
14
14
|
from pygeai.cli.commands.builders import build_help_text
|
|
15
15
|
from pygeai.cli.commands.common import get_messages, get_boolean_value, get_penalty_float_value
|
|
16
|
+
from pygeai.cli.commands.lab.utils import get_project_id
|
|
16
17
|
from pygeai.cli.texts.help import CHAT_HELP_TEXT
|
|
17
|
-
from pygeai.core.common.exceptions import MissingRequirementException, WrongArgumentError
|
|
18
|
+
from pygeai.core.common.exceptions import MissingRequirementException, WrongArgumentError, InvalidAgentException
|
|
18
19
|
from prompt_toolkit import PromptSession
|
|
19
20
|
from prompt_toolkit.history import InMemoryHistory
|
|
20
21
|
|
|
21
22
|
from pygeai.core.utils.console import Console
|
|
23
|
+
from pygeai.lab.agents.clients import AgentClient
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
def show_help():
|
|
@@ -359,71 +361,67 @@ def chat_with_agent(option_list: list):
|
|
|
359
361
|
if not agent_name:
|
|
360
362
|
raise MissingRequirementException(f"Agent name must be specified.")
|
|
361
363
|
|
|
364
|
+
project_id = get_project_id()
|
|
365
|
+
agent_data = AgentClient(project_id=project_id).get_agent(agent_id=agent_name)
|
|
366
|
+
if 'errors' in agent_data:
|
|
367
|
+
raise InvalidAgentException(f"There is no agent with that name: {agent_data.get('errors')}")
|
|
368
|
+
|
|
362
369
|
if use_gui:
|
|
363
370
|
try:
|
|
364
|
-
# Check if Streamlit is installed
|
|
365
371
|
import streamlit
|
|
366
372
|
except ImportError:
|
|
367
373
|
logger.error("Streamlit not installed")
|
|
368
374
|
Console.write_stderr("Streamlit is required for GUI mode. Install it with 'pip install streamlit'.")
|
|
369
375
|
sys.exit(1)
|
|
370
376
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
try:
|
|
378
|
+
ui_path = resources.files("pygeai.chat").joinpath("ui.py")
|
|
379
|
+
ui_file_path = str(ui_path)
|
|
380
|
+
|
|
381
|
+
# Add the top-level project root to PYTHONPATH
|
|
382
|
+
package_root = str(Path(ui_file_path).resolve().parents[2])
|
|
383
|
+
env = os.environ.copy()
|
|
384
|
+
env["PYTHONPATH"] = package_root + os.pathsep + env.get("PYTHONPATH", "")
|
|
385
|
+
|
|
386
|
+
streamlit_cmd = [
|
|
387
|
+
sys.executable, "-m", "streamlit", "run", ui_file_path,
|
|
388
|
+
"--server.address", "127.0.0.1",
|
|
389
|
+
"--", "--agent-name", agent_name
|
|
390
|
+
]
|
|
391
|
+
|
|
392
|
+
if platform.system() == "Linux":
|
|
393
|
+
streamlit_cmd.insert(5, "--server.headless=true")
|
|
394
|
+
|
|
395
|
+
process = subprocess.Popen(
|
|
396
|
+
streamlit_cmd,
|
|
397
|
+
stdout=subprocess.PIPE,
|
|
398
|
+
stderr=subprocess.PIPE,
|
|
399
|
+
text=True
|
|
400
|
+
)
|
|
378
401
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
# Add the top-level project root to PYTHONPATH
|
|
384
|
-
package_root = str(Path(ui_file_path).resolve().parents[2])
|
|
385
|
-
env = os.environ.copy()
|
|
386
|
-
env["PYTHONPATH"] = package_root + os.pathsep + env.get("PYTHONPATH", "")
|
|
387
|
-
|
|
388
|
-
streamlit_cmd = [
|
|
389
|
-
sys.executable, "-m", "streamlit", "run", ui_file_path,
|
|
390
|
-
"--server.address", "127.0.0.1",
|
|
391
|
-
"--", "--agent-name", agent_name
|
|
392
|
-
]
|
|
393
|
-
|
|
394
|
-
if platform.system() == "Linux":
|
|
395
|
-
streamlit_cmd.insert(5, "--server.headless=true")
|
|
396
|
-
|
|
397
|
-
process = subprocess.Popen(
|
|
398
|
-
streamlit_cmd,
|
|
399
|
-
stdout=subprocess.PIPE,
|
|
400
|
-
stderr=subprocess.PIPE,
|
|
401
|
-
text=True
|
|
402
|
-
)
|
|
403
|
-
|
|
404
|
-
url = "http://localhost:8501"
|
|
405
|
-
if platform.system() == "Linux":
|
|
406
|
-
Console.write_stdout(f"Open Streamlit app at {url} (or next port like 8502 if 8501 is taken)")
|
|
407
|
-
|
|
408
|
-
try:
|
|
409
|
-
stdout, stderr = process.communicate()
|
|
410
|
-
if stderr:
|
|
411
|
-
logger.error(f"Streamlit stderr:\n{stderr}")
|
|
412
|
-
Console.write_stderr(f"Streamlit error:\n{stderr}")
|
|
413
|
-
except KeyboardInterrupt:
|
|
414
|
-
process.terminate()
|
|
415
|
-
Console.write_stdout("Streamlit stopped.")
|
|
416
|
-
sys.exit(0)
|
|
402
|
+
url = "http://localhost:8501"
|
|
403
|
+
if platform.system() == "Linux":
|
|
404
|
+
Console.write_stdout(f"Open Streamlit app at {url} (or next port like 8502 if 8501 is taken)")
|
|
417
405
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
sys.exit(
|
|
406
|
+
try:
|
|
407
|
+
stdout, stderr = process.communicate()
|
|
408
|
+
if stderr:
|
|
409
|
+
logger.error(f"Streamlit stderr:\n{stderr}")
|
|
410
|
+
Console.write_stderr(f"Streamlit error:\n{stderr}")
|
|
411
|
+
except KeyboardInterrupt:
|
|
412
|
+
process.terminate()
|
|
413
|
+
Console.write_stdout("Streamlit stopped.")
|
|
414
|
+
sys.exit(0)
|
|
415
|
+
|
|
416
|
+
except FileNotFoundError:
|
|
417
|
+
logger.error("Could not locate pygeai/chat/ui.py")
|
|
418
|
+
Console.write_stderr("Streamlit UI file not found. Ensure pygeai is installed correctly.")
|
|
419
|
+
sys.exit(1)
|
|
420
|
+
except Exception as e:
|
|
421
|
+
logger.error(f"Streamlit error: {e}")
|
|
422
|
+
Console.write_stderr(
|
|
423
|
+
f"Failed to launch Streamlit. Check port with 'lsof -i :8501' and kill any process, or try {url}.")
|
|
424
|
+
sys.exit(1)
|
|
427
425
|
else:
|
|
428
426
|
chat_session = AgentChatSession(agent_name)
|
|
429
427
|
messages = list()
|