Skip to content

Commit

Permalink
improvements with tests and sqlite functions
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkulaga committed Jan 19, 2025
1 parent 3b9105a commit 2667583
Show file tree
Hide file tree
Showing 10 changed files with 255 additions and 84 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:

env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
GROQ_API_KEY_1: ${{ secrets.GROQ_API_KEY_1 }}
GROQ_API_KEY_2: ${{ secrets.GROQ_API_KEY_2 }}
GROQ_API_KEY_3: ${{ secrets.GROQ_API_KEY_3 }}
GROQ_API_KEY_4: ${{ secrets.GROQ_API_KEY_4 }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ cython_debug/

*.egg-info

config/agent_profiles.yaml #to deal with testing bug
./config/ #temporal config produced by tests
config/agent_profiles.yaml #to deal with testing bug
19 changes: 17 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ build:
tools:
python: "3.11"
commands:
- pip install poetry
# First modify all pyproject.toml files to use exact versions
- cp pyproject.toml pyproject.toml.bak
- |
sed -i \
Expand All @@ -16,12 +18,25 @@ build:
-e "s|{ path = \"router\", develop = true }|\"0.4.9\"|g" \
-e "s|{ path = \"examples\", develop = true }|\"0.4.9\"|g" \
pyproject.toml
# Build packages in order following build.sh approach
# First build core
- cd core && poetry build && cd ..
- pip install core/dist/*.whl
# Build and install other packages
- cd tools && poetry build && cd .. && pip install tools/dist/*.whl
- cd coding && poetry build && cd .. && pip install coding/dist/*.whl
- cd web && poetry build && cd .. && pip install web/dist/*.whl
- cd router && poetry build && cd .. && pip install router/dist/*.whl
- cd examples && poetry build && cd .. && pip install examples/dist/*.whl
# Build the meta-package
- touch ./just_agents/__init__.py
- poetry build
- pip install dist/*.whl
- rm ./just_agents/__init__.py

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
- requirements: docs/requirements.txt
30 changes: 0 additions & 30 deletions config/agent_profiles.yaml

This file was deleted.

14 changes: 10 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
'sphinx.ext.viewcode',
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx_autodoc_typehints'
'sphinx_autodoc_typehints',
'sphinx.ext.autoapi'
]

# Add after the existing extensions
Expand All @@ -20,8 +21,7 @@
'pydantic',
'requests',
'numpydoc',
'rich',
'just_agents'
'rich'
]

# Theme settings
Expand Down Expand Up @@ -52,4 +52,10 @@
myst_enable_extensions = [
"colon_fence",
"deflist"
]
]

# AutoAPI settings
autoapi_type = 'python'
autoapi_dirs = ['../']
autoapi_options = ['members', 'undoc-members', 'show-inheritance', 'show-module-summary']
autoapi_python_use_implicit_namespaces = True
4 changes: 3 additions & 1 deletion tests/test_chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def test_quering(open_genes_db):
goal=f"help users by using SQL syntax to form comands to work with the {open_genes_db} sqlite database",
task="formulate appropriate comands to operate in the given database.",
tools=[sqlite_query],
llm_options=LLAMA3_3)
llm_options=LLAMA3_3,
key_list_env="GROQ_API_KEY" # LOAD GROQ_API_KEY FROM ENVIRONMENT VARIABLES
)


response = agent.query("Show me all tables in the database")
Expand Down
4 changes: 1 addition & 3 deletions tests/test_pure_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pytest
from dotenv import load_dotenv



def get_current_weather(location: str):
"""
Gets the current weather in a given location
Expand Down Expand Up @@ -58,7 +56,7 @@ def test_oai_works(load_env):
OPENAI_GPT4oMINI,_ = load_env
execute_completion(OPENAI_GPT4oMINI)

@pytest.mark.skip(reason="until fixed in https://github.com/BerriAI/litellm/issues/7621")
#@pytest.mark.skip(reason="until fixed in https://github.com/BerriAI/litellm/issues/7621")
def test_grok_bug(load_env):
_, LLAMA3_3 = load_env
execute_completion(LLAMA3_3)
14 changes: 8 additions & 6 deletions tests/test_secretary_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
import json
import just_agents.llm_options
from just_agents.router.secretary_agent import SecretaryAgent
from pytest import TempPathFactory, FixtureRequest
from typing import Tuple, Any

@pytest.fixture(scope='module')
def temp_config_path(tmpdir_factory):
def temp_config_path(tmpdir_factory: TempPathFactory) -> str:
# Create a temporary directory for YAML files
dotenv.load_dotenv(override=True)
tmpdir_factory.mktemp('config')
return SecretaryAgent.DEFAULT_CONFIG_PATH

@pytest.fixture
def secretary_autoload_false(temp_config_path):
def secretary_autoload_false(temp_config_path: str) -> Tuple[SecretaryAgent, bool]:
dotenv.load_dotenv(override=True)
params = {
'autoload_from_yaml': False,
Expand All @@ -28,7 +30,7 @@ def secretary_autoload_false(temp_config_path):
return secretary, result

@pytest.fixture
def secretary_autoload_true(temp_config_path, secretary_autoload_false):
def secretary_autoload_true(temp_config_path: str, secretary_autoload_false: Tuple[SecretaryAgent, bool]) -> Tuple[SecretaryAgent, bool]:
# Ensure the YAML file exists from the previous fixture
dotenv.load_dotenv(override=True)
params = {
Expand All @@ -47,22 +49,22 @@ def secretary_autoload_true(temp_config_path, secretary_autoload_false):
secretary.save_to_yaml()
return secretary, result

def test_secretary_autoload_false(secretary_autoload_false):
def test_secretary_autoload_false(secretary_autoload_false: Tuple[SecretaryAgent, bool]) -> None:
dotenv.load_dotenv(override=True)
secretary, result = secretary_autoload_false
assert result is True, "Failed to update profile when autoload_from_yaml is False."
assert secretary.description != secretary.DEFAULT_DESCRIPTION, "Description was not updated."
assert secretary.llm_model_name is not None, "LLM model name is None."

def test_secretary_autoload_true(secretary_autoload_true):
def test_secretary_autoload_true(secretary_autoload_true: Tuple[SecretaryAgent, bool]) -> None:
dotenv.load_dotenv(override=True)
secretary, result = secretary_autoload_true
assert result is True, "Failed to update profile when autoload_from_yaml is True."
assert secretary.description != secretary.DEFAULT_DESCRIPTION, "Description was not updated."
assert secretary.extras.get("personality_traits") is not None, "Personality traits were not set."
assert secretary.llm_model_name is not None, "LLM model name is None."

def test_new_secretary(temp_config_path):
def test_new_secretary(temp_config_path: str) -> None:
# Load the secretary from the YAML file created in previous tests
dotenv.load_dotenv(override=True)
new_secretary = SecretaryAgent.from_yaml(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from just_agents.base_agent import BaseAgent
from just_agents.llm_options import LLMOptions, LLAMA3_3, LLAMA3_2_VISION, OPENAI_GPT4oMINI
from just_agents.just_tool import JustToolsBus


@pytest.fixture(scope="module", autouse=True)
def load_env():
load_dotenv(override=True)
Expand Down
Loading

0 comments on commit 2667583

Please sign in to comment.