Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
72cae1c
Implemetation of v1.1.0
alexvbrdn Sep 28, 2025
a8dd099
update readme + add tests + caching
alexvbrdn Sep 29, 2025
41a01b3
readme wip
alexvbrdn Oct 8, 2025
96626c6
Add dotenv
alexvbrdn Oct 13, 2025
8cb340e
Env variables should be read in initialize
alexvbrdn Oct 13, 2025
da3bdf7
Update readme
alexvbrdn Oct 13, 2025
360cbd4
Update readme
alexvbrdn Oct 13, 2025
6ad21e7
update readme
alexvbrdn Oct 13, 2025
0a7b773
update readme
alexvbrdn Oct 13, 2025
63ff2b6
update readme
alexvbrdn Oct 13, 2025
58a8146
update readme
alexvbrdn Oct 13, 2025
8415d28
update readme
alexvbrdn Oct 13, 2025
b4e4514
update readme
alexvbrdn Oct 13, 2025
bee9113
Update README.md
alexvbrdn Oct 14, 2025
b8fa994
Update README.md
alexvbrdn Oct 14, 2025
585c8bd
Update project
alexvbrdn Oct 14, 2025
5a5ef35
Add missing repeat
alexvbrdn Oct 17, 2025
03a5bca
Improve testing
alexvbrdn Oct 19, 2025
a150a82
Update README.md
alexvbrdn Oct 21, 2025
85f3604
Remove get_details
alexvbrdn Oct 26, 2025
5db1321
WIP: new client architecture
alexvbrdn Mar 11, 2026
22b2d4f
Update the library structure
alexvbrdn Mar 15, 2026
bea97db
Update error handling
alexvbrdn Mar 15, 2026
6e55a66
Update workflow
alexvbrdn Mar 15, 2026
06b3814
Update README.md
alexvbrdn Mar 16, 2026
c59c88e
Add logging
alexvbrdn Mar 16, 2026
b5ef629
Update generate strings
alexvbrdn Mar 18, 2026
a894e41
Update generate_strings
alexvbrdn Mar 18, 2026
75ac4a2
Update test name
alexvbrdn Mar 18, 2026
0d75cac
Update generate_strings
alexvbrdn Mar 21, 2026
008eb09
Update generate_strings
alexvbrdn Mar 21, 2026
c0c38f2
Update wrapper
alexvbrdn Mar 22, 2026
8c3441a
Update README.md
alexvbrdn Mar 22, 2026
df78f88
Update README.md
alexvbrdn Mar 22, 2026
76b6cce
small refactoring
alexvbrdn Mar 24, 2026
ed506e2
Update library
alexvbrdn Mar 29, 2026
f3d68ca
Update README.md
alexvbrdn Mar 29, 2026
5e1a38d
Remove GEMINI.md
alexvbrdn Mar 29, 2026
cc1ce06
Update library
alexvbrdn Apr 6, 2026
dd30901
Update README
alexvbrdn Apr 12, 2026
7b28894
Update possible errors
alexvbrdn Apr 13, 2026
af7f0e2
Update endpoints
alexvbrdn Jun 14, 2026
6ec42eb
Add new error
alexvbrdn Jun 15, 2026
c32f8e3
Fix some issues
alexvbrdn Jul 25, 2026
4af4ce3
Align repo with the Java and JS SDKs, and make the lint gate pass
alexvbrdn Jul 25, 2026
d5622a6
Update library
alexvbrdn Aug 4, 2026
06299eb
Drop support for python 3.9
alexvbrdn Aug 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update generate strings
  • Loading branch information
alexvbrdn committed Mar 18, 2026
commit b5ef629f658e6c2a01ee6a3a60e939652bc88398
19 changes: 12 additions & 7 deletions regexsolver/clients/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,24 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):

# --- HELPER ---
async def _execute_with_retry(self, api_method, **kwargs):
max_retries = 5
retries = 0
retried = False
while True:
await self._rate_limiter.wait()
try:
return await api_method(**kwargs)
except ApiException as e:
if e.status == 429:
retries += 1
if retries > max_retries:
if retried:
logger.error("Max retries exceeded for 429 Too Many Requests.")
raise TooManyRequestsError(
"Max retries exceeded for 429 Too Many Requests.",
status_code=429,
)
retried = True
headers = e.headers or {}
retry_after = float(headers.get("Retry-After", 1))
logger.debug(
f"429 Too Many Requests hit (Attempt {retries}/{max_retries}). "
"429 Too Many Requests hit. "
f"Triggering rate limiter for {retry_after} seconds."
)
await self._rate_limiter.trigger(retry_after)
Expand Down Expand Up @@ -580,13 +579,18 @@ async def repeat(

# --- GENERATE ---
async def generate_strings(
self, term: Term, count: int, execution_timeout: Optional[int] = None
self,
term: Term,
count: int,
offset: int,
execution_timeout: Optional[int] = None,
) -> List[str]:
"""Generates up to `count` unique strings matched by the term.
"""Generates up to `count` distinct strings matched by 'term', skipping the first 'offset' strings.

Args:
term: The term to sample generated strings from.
count: The maximum number of unique strings to return.
offset: Number of matched strings to skip before starting to collect the results. Used for pagination.
execution_timeout: Timeout in milliseconds for the operation.

Returns:
Expand All @@ -595,6 +599,7 @@ async def generate_strings(
request = GenerateStringsRequest(
term=term._api_model,
count=count,
offset=offset,
options=self._build_options(execution_timeout),
)
response = await self._execute_with_retry(
Expand Down
11 changes: 8 additions & 3 deletions regexsolver/clients/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,23 @@ def repeat(

# --- GENERATE ---
def generate_strings(
self, term: Term, count: int, execution_timeout: Optional[int] = None
self,
term: Term,
count: int,
offset: int,
execution_timeout: Optional[int] = None,
) -> List[str]:
"""Generates up to `count` unique strings matched by the term.
"""Generates up to `count` distinct strings matched by 'term', skipping the first 'offset' strings.

Args:
term: The term to sample generated strings from.
count: The maximum number of unique strings to return.
offset: Number of matched strings to skip before starting to collect the results. Used for pagination.
execution_timeout: Timeout in milliseconds for the operation.

Returns:
List[str]: A list of strings that match the term.
"""
return self._run_sync(
self._aio.generate_strings(term, count, execution_timeout)
self._aio.generate_strings(term, count, offset, execution_timeout)
)
8 changes: 5 additions & 3 deletions regexsolver/generated/models/generate_strings_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

class GenerateStringsRequest(BaseModel):
"""
Request to generate up to 'count' distinct strings matched by 'term'.
Request to generate up to 'count' distinct strings matched by 'term', skipping the first 'offset' strings.
""" # noqa: E501
term: Term = Field(description="Source term to sample from.")
term: Term = Field(description="Source term to generate strings from.")
count: StrictInt = Field(description="Maximum number of unique strings to return.")
offset: StrictInt = Field(description="Number of matched strings to skip before starting to collect the results. Used for pagination.")
options: Optional[RequestOptions] = None
__properties: ClassVar[List[str]] = ["term", "count", "options"]
__properties: ClassVar[List[str]] = ["term", "count", "offset", "options"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -92,6 +93,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
_obj = cls.model_validate({
"term": Term.from_dict(obj["term"]) if obj.get("term") is not None else None,
"count": obj.get("count"),
"offset": obj.get("offset"),
"options": RequestOptions.from_dict(obj["options"]) if obj.get("options") is not None else None
})
return _obj
Expand Down