Skip to content

Commit

Permalink
Use async runs instead of synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
Flagro committed Dec 10, 2024
1 parent 2921d30 commit 9fc91eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bot/rp_bot/ai_agent/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def engage_is_needed(
toolkit = AIAgentToolkit(
person, context, message, self.models_toolkit, self.prompt_manager
)
return await toolkit.check_engage_needed.run(prompt)
return await toolkit.check_engage_needed.arun(prompt)

async def describe_image(
self,
Expand All @@ -67,7 +67,7 @@ async def describe_image(
if not self.moderation.moderate_image(in_memory_image_stream):
raise ModerationError("Image is not safe")
utility = DescribeImageUtililty(person, context, message, self.models_toolkit)
image_information = await utility.run(in_memory_image_stream)
image_information = await utility.arun(in_memory_image_stream)
image_description = await self.prompt_manager.compose_image_description_prompt(
image_information
)
Expand All @@ -83,7 +83,7 @@ async def transcribe_audio(
if not self.moderation.moderate_audio(in_memory_audio_stream):
raise ModerationError("Audio is not safe")
utility = DescribeAudioUtililty(person, context, message, self.models_toolkit)
audio_information = await utility.run(in_memory_audio_stream)
audio_information = await utility.arun(in_memory_audio_stream)
audio_description = await self.prompt_manager.compose_audio_description_prompt(
audio_information
)
Expand All @@ -98,7 +98,7 @@ async def generate_image(
toolkit = AIAgentToolkit(
person, context, message, self.models_toolkit, self.prompt_manager
)
return await toolkit.image_generator.run(prompt)
return await toolkit.image_generator.arun(prompt)

@staticmethod
def count_tokens(text: str) -> int:
Expand Down

0 comments on commit 9fc91eb

Please sign in to comment.