Spaces:
Running
Running
File size: 580 Bytes
b247dc4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import asyncio
import time
from manifest import Manifest
def main():
manifest = Manifest(
client_name="openaichat",
)
print("Running in serial")
prompts = [f"Tell me something interesting about {i}" for i in range(50)]
st = time.time()
for pmt in prompts:
_ = manifest.run(pmt)
print(f"For loop: {time.time() - st :.2f}")
print("Running with async")
st = time.time()
_ = asyncio.run(manifest.arun_batch(prompts, max_tokens=30))
print(f"Async loop: {time.time() - st :.2f}")
if __name__ == "__main__":
main()
|