Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove positional args from Batch.add #8

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
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
9 changes: 3 additions & 6 deletions oaib/Batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ async def _watch(self):
break

async def _process(self, request, i=None):
endpoint, func, args, kwargs, metadata = request
endpoint, func, kwargs, metadata = request
self.log(f"PROCESSING | {kwargs}", worker=i)

try:
[response] = await wait_for(
gather(func(*args, **kwargs)),
gather(func(**kwargs)),
timeout=self.timeout
)

Expand Down Expand Up @@ -404,7 +404,6 @@ async def add(
self,
endpoint="chat.completions.create",
metadata: dict = {},
*args,
**kwargs
):
"""
Expand All @@ -416,8 +415,6 @@ async def add(
The OpenAI API endpoint to call, e.g., 'chat.completions.create' or 'embeddings.create'.
metadata : dict, default: `None`
A dictionary containing additional data to be added to this observation row in the DataFrame.
*args
Positional arguments to pass to the OpenAI API endpoint function.
**kwargs
Keyword arguments to pass to the OpenAI API endpoint function. Common kwargs include 'model' and input parameters like 'messages' for 'chat.completions.create' or 'input' for 'embeddings.create'.

Expand All @@ -429,7 +426,7 @@ async def add(
func = getattr_dot(self.client.with_raw_response, endpoint)

# Add the request to the queue.
request = (endpoint, func, args, kwargs, metadata)
request = (endpoint, func, kwargs, metadata)
model = kwargs.get("model")
await self.__queue.put(request)

Expand Down