You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
731 B

import asyncio
from AgenticInterfaces.KafkaClient import KafkaClient
request_topic = "request_llm_topic"
response_topic = "response_llm_topic"
bootstrap_servers = "kafka:9092"
def modify_text(text):
return text[::-1]
async def process_message(message):
modified_text = modify_text(message["text"])
response_message = {"text": modified_text}
await kafka_client.send_message(response_message)
async def main():
global kafka_client
kafka_client = KafkaClient(topic=request_topic, bootstrap_servers=bootstrap_servers, group_id="my-group")
await kafka_client.start()
try:
await kafka_client.consume_messages(process_message)
finally:
await kafka_client.stop()
asyncio.run(main())