Skip to content

Commit

Permalink
Update package version and include minor bug fixes for batch queries
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSrikanth committed Dec 19, 2024
1 parent ee1df68 commit bac40ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'v0.2.1'
'v0.2.2'
--repo '${{ github.repository }}'
--notes ""
Expand All @@ -102,5 +102,5 @@ jobs:
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'v0.2.1' dist/**
'v0.2.2' dist/**
--repo '${{ github.repository }}'
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ cython_debug/
# Case Studies
case_studies/

# Testing files
test.py
# Local testing files
local

# Lint cache
.ruff_cache
.ruff_cache
44 changes: 20 additions & 24 deletions aifn/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,29 +730,25 @@ def batch_query(
List[NamedTuple]
A list of NamedTuples, each containing the output and metadata of the response.
"""
try:
# Check if an event loop is already running
loop = asyncio.get_running_loop()
if loop.is_running():
nest_asyncio.apply()
task = loop.create_task(
self._batch_query(
fn_name=fn_name,
version=version,
batch_inputs=batch_inputs,
return_reasoning=return_reasoning,
strict=strict,
)

async def run_batch():
return await self._batch_query(
fn_name=fn_name, version=version, batch_inputs=batch_inputs, return_reasoning=return_reasoning, strict=strict
)
return loop.run_until_complete(task)

# Create a new event loop if one doesn't exist
try:
loop = asyncio.get_event_loop()
except RuntimeError:
# If no event loop is running, use asyncio.run
return asyncio.run(
self._batch_query(
fn_name=fn_name,
version=version,
batch_inputs=batch_inputs,
return_reasoning=return_reasoning,
strict=strict,
)
)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

# Apply nest_asyncio if the loop is already running
if loop.is_running():
nest_asyncio.apply()

try:
return loop.run_until_complete(run_batch())
finally:
# Don't close the loop, just let it be cleaned up naturally
pass
2 changes: 1 addition & 1 deletion aifn/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.2.1" # DO NOT EDIT (this is the package version)
__version__ = "0.2.2" # DO NOT EDIT (this is the package version)
MAX_TEXT_LENGTH = 1e6 # 1 million characters
MAX_IMAGE_UPLOADS = 10 # 10 images
MAX_IMAGE_SIZE_MB = 10 # 10 MB
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
]
description = "Documentation for `aifn`, a client facing API for interacting with the WecoAI's AI functions."
readme = "README.md"
version = "0.2.1"
version = "0.2.2"
license = {text = "MIT"}
requires-python = ">=3.8"
dependencies = ["requests", "asyncio", "nest_asyncio", "httpx[http2]", "pillow"]
Expand Down

0 comments on commit bac40ac

Please sign in to comment.