-
-
Save colin-ho/fb3663c2c57cc2f07a2690a52bc82c20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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