-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (23 loc) · 918 Bytes
/
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
import ai_adapter
import asyncio
import os
from alkemio_virtual_contributor_engine.alkemio_vc_engine import (
AlkemioVirtualContributorEngine,
)
from alkemio_virtual_contributor_engine.events.input import Input
from alkemio_virtual_contributor_engine.events.response import Response
from config import LOG_LEVEL
from logger import setup_logger
logger = setup_logger(__name__)
logger.info(f"log level {os.path.basename(__file__)}: {LOG_LEVEL}")
async def on_request(input: Input) -> Response:
logger.info(f"Expert engine invoked; Input is {input.to_dict()}")
logger.info(
f"AiPersonaServiceID={input.persona_service_id} with VC name `{input.display_name}` invoked."
)
result = await ai_adapter.invoke(input)
logger.info(f"LLM result: {result.to_dict()}")
return result
engine = AlkemioVirtualContributorEngine()
engine.register_handler(on_request)
asyncio.run(engine.start())