Skip to content

Commit 542c135

Browse files
committed
chore: remove coolnames, implement generate_slug() cleanup unused files
1 parent 312161f commit 542c135

5 files changed

Lines changed: 89 additions & 16 deletions

File tree

packages/optimization/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ classifiers = [
2121
]
2222
dependencies = [
2323
"launchdarkly-server-sdk-ai>=0.16.0",
24-
"coolname>=2.0.0",
2524
]
2625

2726
[project.urls]

packages/optimization/src/ldai_optimization/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""Word lists for slug generation.
2+
3+
Adjectives and nouns curated from the coolname package's word files
4+
(Apache-2.0 licensed). Used by generate_slug() to produce
5+
``adjective-noun`` variation keys (e.g. ``blazing-lobster``).
6+
7+
640 × 454 possible combinations from the full coolname corpus would be
8+
overkill; ~100 × ~100 = ~10 000 combinations is sufficient given that
9+
_commit_variation already appends a hex suffix on collisions.
10+
"""
11+
12+
_ADJECTIVES: tuple = (
13+
# appearance / texture
14+
"blazing", "bouncy", "brawny", "chubby", "curvy", "elastic", "ethereal",
15+
"fluffy", "foamy", "furry", "fuzzy", "glaring", "hairy", "hissing",
16+
"icy", "luminous", "lumpy", "misty", "noisy", "quiet", "quirky",
17+
"radiant", "roaring", "ruddy", "shaggy", "shiny", "silent", "silky",
18+
"singing", "skinny", "smooth", "soft", "spicy", "spiked", "sticky",
19+
"tall", "venomous", "warm", "winged", "wooden",
20+
# personality / disposition
21+
"adorable", "amazing", "amiable", "calm", "charming", "cute",
22+
"dainty", "easygoing", "elegant", "famous", "friendly", "funny",
23+
"graceful", "gracious", "happy", "hilarious", "jolly", "jovial",
24+
"kind", "laughing", "lovely", "mellow", "neat", "nifty", "noble",
25+
"popular", "pretty", "refreshing", "spiffy", "stylish", "sweet",
26+
"tactful", "whimsical",
27+
# character / trait
28+
"adventurous", "ambitious", "audacious", "bold", "brave", "cheerful",
29+
"curious", "daring", "determined", "eager", "enthusiastic", "faithful",
30+
"fearless", "fierce", "generous", "gentle", "gleeful", "grateful",
31+
"hopeful", "humble", "intrepid", "lively", "loyal", "merry",
32+
"mysterious", "optimistic", "passionate", "polite", "proud", "rebel",
33+
"relaxed", "reliable", "resolute", "romantic", "sincere", "spirited",
34+
"stalwart", "thankful", "upbeat", "valiant", "vigorous", "vivacious",
35+
"zealous", "zippy",
36+
# quality / impressiveness
37+
"ancient", "awesome", "brilliant", "classic", "dazzling", "fabulous",
38+
"fantastic", "glorious", "legendary", "magnificent", "majestic",
39+
"marvellous", "miraculous", "phenomenal", "remarkable", "splendid",
40+
"wonderful",
41+
# size
42+
"colossal", "enormous", "gigantic", "huge", "massive", "tiny",
43+
"towering",
44+
)
45+
46+
_NOUNS: tuple = (
47+
# common mammals
48+
"badger", "bat", "bear", "beaver", "bison", "bobcat", "buffalo",
49+
"capybara", "cheetah", "chipmunk", "coyote", "dingo", "dormouse",
50+
"elephant", "ermine", "ferret", "fox", "gazelle", "gibbon", "gorilla",
51+
"groundhog", "hamster", "hare", "hedgehog", "hippo", "horse",
52+
"hyena", "jaguar", "kangaroo", "koala", "leopard", "lion", "lynx",
53+
"mammoth", "marmot", "meerkat", "mongoose", "monkey", "moose",
54+
"otter", "panda", "panther", "porcupine", "puma", "rabbit",
55+
"raccoon", "rhinoceros", "seal", "skunk", "sloth", "squirrel",
56+
"tiger", "walrus", "weasel", "whale", "wolf", "wombat",
57+
"wolverine", "zebra",
58+
# birds
59+
"condor", "crane", "crow", "dove", "eagle", "falcon", "flamingo",
60+
"hawk", "heron", "hummingbird", "kingfisher", "macaw", "magpie",
61+
"ostrich", "owl", "parrot", "peacock", "pelican", "penguin",
62+
"phoenix", "puffin", "raven", "robin", "sparrow", "starling",
63+
"stork", "swan", "toucan", "vulture",
64+
# reptiles / amphibians / fish
65+
"cobra", "crocodile", "gecko", "iguana", "jellyfish", "lobster",
66+
"narwhal", "octopus", "orca", "python", "rattlesnake", "salmon",
67+
"seahorse", "shark", "snake", "squid", "tortoise", "turtle",
68+
"viper",
69+
# legendary / breed
70+
"basilisk", "chimera", "chupacabra", "dragon", "griffin",
71+
"kraken", "pegasus", "unicorn", "wyvern",
72+
"beagle", "bulldog", "collie", "corgi", "dalmatian", "husky",
73+
"labrador", "poodle", "rottweiler",
74+
)

packages/optimization/src/ldai_optimizer/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import uuid
2525
from typing import Any, Dict, List, Literal, Optional, Union
2626

27-
from coolname import generate_slug
2827
from ldai import AIAgentConfig, AIJudgeConfig, AIJudgeConfigDefault, LDAIClient
2928
from ldai.models import LDMessage, ModelConfig
3029
from ldclient import Context
@@ -59,6 +58,7 @@
5958
RedactionFilter,
6059
await_if_needed,
6160
extract_json_from_response,
61+
generate_slug,
6262
interpolate_variables,
6363
restore_variable_placeholders,
6464
validate_variation_response,
@@ -1926,7 +1926,7 @@ def _commit_variation(
19261926
**({"base_url": base_url} if base_url else {}),
19271927
)
19281928

1929-
candidate = output_key if output_key else generate_slug(2)
1929+
candidate = output_key if output_key else generate_slug()
19301930

19311931
try:
19321932
ai_config = api_client.get_ai_config(project_key, ai_config_key)

packages/optimization/src/ldai_optimizer/util.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import inspect
44
import json
55
import logging
6+
import random
67
import re
78
from typing import Any, Awaitable, Dict, List, Optional, Tuple, TypeVar, Union
89

10+
from ldai_optimizer._slug_words import _ADJECTIVES, _NOUNS
911
from ldai_optimizer.dataclasses import ToolDefinition
1012

1113
logger = logging.getLogger(__name__)
@@ -38,6 +40,17 @@ def filter(self, record: logging.LogRecord) -> bool:
3840
logger.addFilter(RedactionFilter())
3941

4042

43+
def generate_slug() -> str:
44+
"""Generate a random ``adjective-noun`` slug (e.g. ``blazing-lobster``).
45+
46+
Produces the same format as ``coolname.generate_slug(2)`` using an
47+
internal word list, removing the external dependency.
48+
49+
:return: A hyphen-joined two-word lowercase string.
50+
"""
51+
return f"{random.choice(_ADJECTIVES)}-{random.choice(_NOUNS)}"
52+
53+
4154
def handle_evaluation_tool_call(score: float, rationale: str) -> str:
4255
"""
4356
Process the return_evaluation tool call from the judge LLM.

0 commit comments

Comments
 (0)