Skip to content

Commit

Permalink
updated versions
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkulaga committed Jan 9, 2025
1 parent fd9164f commit a89f95d
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 52 deletions.
4 changes: 2 additions & 2 deletions coding/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-coding"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Coding Components"
authors = [
"Alex Karmazin <karmazinalex@gmail.com>",
Expand All @@ -19,7 +19,7 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.6"
just-agents-core = ">=0.4.7"
llm-sandbox = ">=0.1.8"

[build-system]
Expand Down
12 changes: 10 additions & 2 deletions core/just_agents/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class BaseAgent(
default=None,
exclude=True,
description="Path to text file with list of api keys, one key per line")

key_list_env: Optional[str] = Field(
default=None,
exclude=True,
description="Environment variable name containing comma-separated API keys")

max_tool_calls: int = Field(
ge=1,
Expand Down Expand Up @@ -121,9 +126,12 @@ def model_post_init(self, __context: Any) -> None:
if not self.llm_options.get("tool_choice", None):
self.llm_options["tool_choice"] = "auto"

# Set up API key rotation if a key list file is provided
# Set up API key rotation based on file or environment variable
if self.key_list_path is not None:
self._key_getter = RotateKeys(self.key_list_path)
self._key_getter = RotateKeys.from_path(self.key_list_path)
elif self.key_list_env is not None:
self._key_getter = RotateKeys.from_env(self.key_list_env)

# Warn if both direct API key and key rotation are configured
if (self._key_getter is not None) and (self.llm_options.get("api_key", None) is not None):
print("Warning api_key will be rewritten by key_getter. Both are present in llm_options.")
Expand Down
39 changes: 37 additions & 2 deletions core/just_agents/rotate_keys.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
import random

class RotateKeys():
"""
RotateKeys is a class that rotates through a list of keys.
"""
keys:list[str]

def __init__(self, file_path:str):
def __init__(self, keys: list[str]):
self.keys = keys

@classmethod
def from_path(cls, file_path: str):
with open(file_path) as f:
text = f.read().strip()
self.keys = text.split("\n")
keys = text.split("\n")
return cls(keys)

@classmethod
def from_list(cls, keys: list[str]):
return cls(keys)

@classmethod
def from_env(cls, env_var: str):
import os
all_keys = []

# Get the base environment variable
keys_str = os.getenv(env_var)
if not keys_str:
raise ValueError(f"Environment variable {env_var} not found")
all_keys.extend([k.strip() for k in keys_str.split(",")])

# Check for additional numbered variables
counter = 1
while True:
numbered_env = f"{env_var}_{counter}"
keys_str = os.getenv(numbered_env)
if not keys_str:
break
all_keys.extend([k.strip() for k in keys_str.split(",")])
counter += 1

return cls(all_keys)

def __call__(self, *args, **kwargs):
return random.choice(self.keys)
Expand Down
2 changes: 1 addition & 1 deletion core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-core"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Base Package"
authors = [
"Alex Karmazin <karmazinalex@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/01_just_agents_colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
],
"source": [
"!pip install just-agents-core==0.4.6"
"!pip install just-agents-core==0.4.7"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/02_sqlite_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (3.7.1)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.27.2)\n",
"Requirement already satisfied: jiter<1,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
"Requirement already satisfied: jiter<1,>=0.4.7 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (4.66.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
Expand Down Expand Up @@ -312,8 +312,8 @@
}
],
"source": [
"!pip install just-agents-core==0.4.6\n",
"!pip install just-agents-examples==0.4.6"
"!pip install just-agents-core==0.4.7\n",
"!pip install just-agents-examples==0.4.7"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/03_coding_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (3.7.1)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.27.2)\n",
"Requirement already satisfied: jiter<1,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.1)\n",
"Requirement already satisfied: jiter<1,>=0.4.7 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (0.7.1)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (1.3.1)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.10/dist-packages (from openai>=1.54.0->litellm>=1.51.0->just-agents) (4.66.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.0.0->litellm>=1.51.0->just-agents) (0.7.0)\n",
Expand Down Expand Up @@ -156,8 +156,8 @@
}
],
"source": [
"!pip install just-agents-core==0.4.6\n",
"!pip install just-agents-examples==0.4.6"
"!pip install just-agents-core==0.4.7\n",
"!pip install just-agents-examples==0.4.7"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-examples"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Examples code"
authors = ["Alex Karmazin <karmazinalex@gmail.com>"]
maintainers = ["Anton Kulaga <antonkulaga@gmail.com>"]
Expand All @@ -12,11 +12,11 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.6"
just-agents-tools = ">=0.4.6"
just-agents-coding = ">=0.4.6"
just-agents-web = ">=0.4.6"
just-agents-router = ">=0.4.6"
just-agents-core = ">=0.4.7"
just-agents-tools = ">=0.4.7"
just-agents-coding = ">=0.4.7"
just-agents-web = ">=0.4.7"
just-agents-router = ">=0.4.7"
docker = ">=7.1.0"

[tool.poetry.group.dev.dependencies]
Expand Down
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - A lightweight, straightforward library for LLM agents that focuses on simplicity over unnecessary abstractions."
authors = [
"Alex Karmazin <karmazinalex@gmail.com>",
Expand All @@ -26,12 +26,12 @@ just-agents-router = { path = "router", develop = true }
just-agents-examples = { path = "examples", develop = true }

[tool.poetry.group.publish.dependencies]
just-agents-core = "0.4.6"
just-agents-tools = "0.4.6"
just-agents-coding = "0.4.6"
just-agents-web = "0.4.6"
just-agents-router = "0.4.6"
just-agents-examples = "0.4.6"
just-agents-core = "0.4.7"
just-agents-tools = "0.4.7"
just-agents-coding = "0.4.7"
just-agents-web = "0.4.7"
just-agents-router = "0.4.7"
just-agents-examples = "0.4.7"

[tool.poetry.group.dev.dependencies]
pytest = ">=8.3.4"
Expand Down
4 changes: 2 additions & 2 deletions router/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-router"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Router Components"
authors = [
"Newton Winter <isoutthere@gmail.com>",
Expand All @@ -18,7 +18,7 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.6"
just-agents-core = ">=0.4.7"

[tool.poetry.group.dev.dependencies]
pytest = ">=8.3.4"
Expand Down
4 changes: 2 additions & 2 deletions tools/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-tools"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Tools Components"
authors = ["Alex Karmazin <karmazinalex@gmail.com>"]
maintainers = ["Anton Kulaga <antonkulaga@gmail.com>"]
Expand All @@ -12,7 +12,7 @@ license = "MIT"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.6"
just-agents-core = ">=0.4.7"
semanticscholar = ">=0.8.4"
typer = ">=0.13.0"

Expand Down
4 changes: 2 additions & 2 deletions web/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "just-agents-web"
version = "0.4.6"
version = "0.4.7"
description = "Just Agents - Web. It allows runing openai API for the agent in the browser."

authors = [
Expand Down Expand Up @@ -31,7 +31,7 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
just-agents-core = ">=0.4.6"
just-agents-core = ">=0.4.7"
pycomfort = ">=0.0.17"
fastapi = ">=0.115.6"
uvicorn = ">=0.34.0"
Expand Down

0 comments on commit a89f95d

Please sign in to comment.