Skip to content

Instantly share code, notes, and snippets.

@colin-ho
Created April 21, 2025 20:36
Show Gist options
  • Save colin-ho/fb3663c2c57cc2f07a2690a52bc82c20 to your computer and use it in GitHub Desktop.
Save colin-ho/fb3663c2c57cc2f07a2690a52bc82c20 to your computer and use it in GitHub Desktop.
@daft.udf(return_dtype=...)
def analyze_commit_message(commits):
async def analyze_single_commit(commit):
prompt = f"You are an expert at analyzing GitHub contributions ..."
result = await client.chat.completions.create(
model=model,
response_model=CommitQuality,
messages=[{"role": "user", "content": prompt}]
)
return result.model_dump()
semaphore = asyncio.Semaphore(max_concurrent_requests)
async def analyze_with_semaphore(*args):
async with semaphore:
return await analyze_single_commit(*args)
tasks = [
analyze_with_semaphore(commit)
for commit in commits
]
async def run_tasks():
return await asyncio.gather(*tasks)
results = asyncio.run(run_tasks())
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment