-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (36 loc) · 1.27 KB
/
main.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
#import baml_py
from baml_py import Image
#from pydantic import BaseModel
import time
#from baml_client import client
from baml_client.types import ClassWithImage, FakeImage
from baml_client import BamlClient
runtime = BamlClient.from_directory("baml_src")
async def main():
spongebob_image = Image(
url="https://i.kym-cdn.com/photos/images/original/002/807/304/a0b.jpeg"
)
print("image", spongebob_image)
print("image.url", spongebob_image.url)
orc_image = Image(
url="https://i.kym-cdn.com/entries/icons/original/000/033/100/eht0m1qg8dk21.jpg"
)
full_obj = ClassWithImage(
myImage=spongebob_image,
param2="ocean",
fake_image=FakeImage(
url="https://i.kym-cdn.com/entries/icons/original/000/033/100/eht0m1qg8dk21.jpg"
),
)
#res = await b.call_function(
# "DescribeImage2", args={"classWithImage": full_obj, "img2": orc_image}, ctx={}
#)
#print("res-------\n", res)
res2 = await runtime.DescribeImage2(classWithImage=full_obj, img2=orc_image)
print("res2-------\n", res2)
start_time = time.perf_counter()
asyncio.run(main())
end_time = time.perf_counter()
elapsed_time = end_time - start_time
print(f"Elapsed time: {elapsed_time:.2f} seconds")