mirror of
https://github.com/mruwnik/memory.git
synced 2025-11-13 00:04:05 +01:00
allow discord tools
This commit is contained in:
parent
c42513100b
commit
e95a082147
@ -9,4 +9,5 @@ anthropic==0.69.0
|
||||
openai==2.3.0
|
||||
# Pin the httpx version, as newer versions break the anthropic client
|
||||
httpx==0.27.0
|
||||
celery[redis,sqs]==5.3.6
|
||||
celery[redis,sqs]==5.3.6
|
||||
cryptography==43.0.0
|
||||
@ -1,3 +1,2 @@
|
||||
cryptography==43.0.0
|
||||
boto3
|
||||
awscli==1.42.64
|
||||
@ -290,6 +290,7 @@ class ScheduledLLMCallAdmin(ModelView, model=ScheduledLLMCall):
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
column_sortable_list = ["executed_at", "scheduled_time", "created_at", "updated_at"]
|
||||
|
||||
|
||||
def setup_admin(admin: Admin):
|
||||
|
||||
@ -55,7 +55,7 @@ EXECUTE_SCHEDULED_CALL = f"{SCHEDULED_CALLS_ROOT}.execute_scheduled_call"
|
||||
RUN_SCHEDULED_CALLS = f"{SCHEDULED_CALLS_ROOT}.run_scheduled_calls"
|
||||
|
||||
# Backup tasks
|
||||
BACKUP_TO_S3_DIRECTORY = f"{BACKUP_ROOT}.backup_to_s3_directory"
|
||||
BACKUP_PATH = f"{BACKUP_ROOT}.backup_path"
|
||||
BACKUP_ALL = f"{BACKUP_ROOT}.backup_all"
|
||||
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ from memory.common.celery_app import (
|
||||
TRACK_GIT_CHANGES,
|
||||
SYNC_LESSWRONG,
|
||||
RUN_SCHEDULED_CALLS,
|
||||
BACKUP_TO_S3,
|
||||
BACKUP_ALL,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -49,8 +49,8 @@ app.conf.beat_schedule = {
|
||||
"task": RUN_SCHEDULED_CALLS,
|
||||
"schedule": settings.SCHEDULED_CALL_RUN_INTERVAL,
|
||||
},
|
||||
"backup-to-s3": {
|
||||
"task": BACKUP_TO_S3,
|
||||
"backup-all": {
|
||||
"task": BACKUP_ALL,
|
||||
"schedule": settings.S3_BACKUP_INTERVAL,
|
||||
},
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ import boto3
|
||||
from cryptography.fernet import Fernet
|
||||
|
||||
from memory.common import settings
|
||||
from memory.common.celery_app import app, BACKUP_TO_S3_DIRECTORY, BACKUP_ALL
|
||||
from memory.common.celery_app import app, BACKUP_PATH, BACKUP_ALL
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -120,7 +120,7 @@ def backup_encrypted_directory(path: Path) -> dict:
|
||||
return {"uploaded": False, "directory": path, "error": str(e)}
|
||||
|
||||
|
||||
@app.task(name=BACKUP_TO_S3_DIRECTORY)
|
||||
@app.task(name=BACKUP_PATH)
|
||||
def backup_to_s3(path: Path | str):
|
||||
"""Backup a specific directory to S3."""
|
||||
path = Path(path)
|
||||
|
||||
@ -56,7 +56,7 @@ def call_llm(
|
||||
message: DiscordMessage,
|
||||
model: str,
|
||||
msgs: list[str] = [],
|
||||
allowed_tools: list[str] = [],
|
||||
allowed_tools: list[str] | None = None,
|
||||
) -> str | None:
|
||||
provider = create_provider(model=model)
|
||||
if provider.usage_tracker.is_rate_limited(model):
|
||||
@ -74,7 +74,8 @@ def call_llm(
|
||||
tools = {
|
||||
name: tool
|
||||
for name, tool in tools.items()
|
||||
if message.tool_allowed(name) and name in allowed_tools
|
||||
if message.tool_allowed(name)
|
||||
and (allowed_tools is None or name in allowed_tools)
|
||||
}
|
||||
system_prompt = message.system_prompt or ""
|
||||
system_prompt += comm_channel_prompt(
|
||||
@ -196,6 +197,7 @@ def process_discord_message(message_id: int) -> dict[str, Any]:
|
||||
except Exception:
|
||||
logger.exception("Failed to generate Discord response")
|
||||
|
||||
print("response:", response)
|
||||
if not response:
|
||||
return {
|
||||
"status": "processed",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user