Skip to content

Commit

Permalink
Increase default max tokens for Claude and add environment variable t…
Browse files Browse the repository at this point in the history
…o configure this
  • Loading branch information
mikejar committed Jan 12, 2025
1 parent 512ddce commit 6d40dfa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assistants/ai/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from assistants.ai.memory import MemoryMixin
from assistants.ai.types import MessageData
from assistants.cli.constants import CLAUDE_CLI_MAX_TOKENS
from assistants.config import environment
from assistants.lib.exceptions import ConfigError

Expand All @@ -34,7 +35,7 @@ class Claude(MemoryMixin):
def __init__(
self,
model: str,
max_tokens: int = 1024,
max_tokens: int = CLAUDE_CLI_MAX_TOKENS,
max_memory: int = 50,
api_key: Optional[str] = environment.ANTHROPIC_API_KEY,
) -> None:
Expand Down
2 changes: 2 additions & 0 deletions assistants/cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
Anything else you type will be sent to the assistant for processing.\
"""

CLAUDE_CLI_MAX_TOKENS = 2048
4 changes: 4 additions & 0 deletions assistants/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from enum import Enum
from dataclasses import dataclass

from assistants.cli.constants import CLAUDE_CLI_MAX_TOKENS


class CustomKeyNames(str, Enum):
ASSISTANTS_API_KEY_NAME: str = "ASSISTANTS_API_KEY_NAME"
Expand Down Expand Up @@ -35,6 +37,7 @@ class Config:
ASSISTANT_INSTRUCTIONS: str
ASSISTANT_NAME: str
TELEGRAM_BOT_TOKEN: str
CLAUDE_MAX_TOKENS: str


def get_config() -> Config:
Expand All @@ -50,6 +53,7 @@ def get_config() -> Config:
),
ASSISTANT_NAME=os.environ.get("ASSISTANT_NAME", "DefaultAssistant"),
TELEGRAM_BOT_TOKEN=os.environ.get("TG_BOT_TOKEN", None),
CLAUDE_MAX_TOKENS=os.environ.get("CLAUDE_MAX_TOKENS", CLAUDE_CLI_MAX_TOKENS),
)


Expand Down

0 comments on commit 6d40dfa

Please sign in to comment.