Skip to content

Commit

Permalink
Simplify DescribeImageUtililty run and arun logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Flagro committed Dec 8, 2024
1 parent c0fae6e commit 88abced
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions bot/rp_bot/ai_agent/ai_utils/describe_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@ def __str__(self):
)


async def describe_image(in_memory_image_stream: io.BytesIO) -> ImageInformation:
# Encode in base64:
image_base64 = base64.b64encode(in_memory_image_stream.getvalue()).decode()
parser = JsonOutputParser(pydantic_object=ImageInformation)

# TODO: implement image chain runnable
# TODO: pass the image model here

return ImageInformation(
image_description="an image", image_type="picture", main_objects=["image"]
)


class DescribeImageUtililty(BaseUtility):
def run(self, in_memory_image_stream: io.BytesIO) -> ImageInformation:
return describe_image(in_memory_image_stream)
# Encode in base64:
image_base64 = base64.b64encode(in_memory_image_stream.getvalue()).decode()
parser = JsonOutputParser(pydantic_object=ImageInformation)

# TODO: implement image chain runnable
# TODO: pass the image model here

return ImageInformation(
image_description="an image", image_type="picture", main_objects=["image"]
)

async def arun(self, in_memory_image_stream: io.BytesIO) -> ImageInformation:
return await describe_image(in_memory_image_stream)
# TODO: make it non-blocking
return self.run(in_memory_image_stream)

0 comments on commit 88abced

Please sign in to comment.