WIP: tunning
This commit is contained in:
@@ -12,9 +12,9 @@ r = redis.Redis.from_url(os.environ.get("REDIS_URL", "redis://redis:6379"))
|
|||||||
class MessagePayload(BaseModel):
|
class MessagePayload(BaseModel):
|
||||||
roomId: str
|
roomId: str
|
||||||
userId: str
|
userId: str
|
||||||
content: str
|
|
||||||
eventId: str
|
eventId: str
|
||||||
timestamp: int
|
serverTimestamp: int
|
||||||
|
content: str
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ MATRIX_USER_ID = os.getenv("MATRIX_USER_ID")
|
|||||||
MATRIX_PASSWORD = os.getenv("MATRIX_PASSWORD")
|
MATRIX_PASSWORD = os.getenv("MATRIX_PASSWORD")
|
||||||
MATRIX_LOGIN_TRIES = int(os.getenv("MATRIX_LOGIN_TRIES", 5))
|
MATRIX_LOGIN_TRIES = int(os.getenv("MATRIX_LOGIN_TRIES", 5))
|
||||||
MATRIX_LOGIN_DELAY_INCREMENT = int(os.getenv("MATRIX_LOGIN_DELAY_INCREMENT", 5))
|
MATRIX_LOGIN_DELAY_INCREMENT = int(os.getenv("MATRIX_LOGIN_DELAY_INCREMENT", 5))
|
||||||
|
|
||||||
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
|
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
|
||||||
AI_URL = os.getenv("AI_URL")
|
|
||||||
AI_TOKEN = os.getenv("AI_TOKEN")
|
AI_HANDLER_URL = os.getenv("AI_HANDLER_URL")
|
||||||
|
AI_HANDLER_TOKEN = os.getenv("AI_HANDLER_TOKEN")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -76,15 +78,15 @@ async def main() -> None:
|
|||||||
if isinstance(event, RoomMessageText):
|
if isinstance(event, RoomMessageText):
|
||||||
logger.info(f"Received message in {room.room_id}: {event.body}")
|
logger.info(f"Received message in {room.room_id}: {event.body}")
|
||||||
payload = {
|
payload = {
|
||||||
"roomId": event["room_id"],
|
"roomId": event.room_id,
|
||||||
"userId": event["sender"],
|
"userId": event.sender,
|
||||||
"content": event["content"]["body"],
|
"eventId": event.event_id,
|
||||||
"eventId": event["event_id"],
|
"serverTimestamp": event.server_timestamp,
|
||||||
"timestamp": event["origin_server_ts"]
|
"content": event.body
|
||||||
}
|
}
|
||||||
headers = {"Authorization": f"Bearer {AI_TOKEN}"}
|
headers = {"Authorization": f"Bearer {AI_HANDLER_TOKEN}"}
|
||||||
async with httpx.AsyncClient() as http:
|
async with httpx.AsyncClient() as http:
|
||||||
resp = await http.post(f"{AI_URL}/api/v1/message", json=payload, headers=headers)
|
resp = await http.post(f"{AI_HANDLER_URL}/api/v1/message", json=payload, headers=headers)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
if data.get("reply"):
|
if data.get("reply"):
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
matrix-nio[e2e]>=0.25.0
|
matrix-nio[e2e]>=0.25.0
|
||||||
python-dotenv>=1.0.0
|
python-dotenv>=1.0.0
|
||||||
openai
|
httpx>=0.23.0
|
||||||
|
pydantic>=1.10
|
||||||
Reference in New Issue
Block a user