Skip to content

Commit

Permalink
Override default max tokens for Anthropic and Groq clients (#143)
Browse files Browse the repository at this point in the history
* Override default max tokens for Anthropic and Groq clients

* Override default max tokens for Anthropic and Groq clients

* Override default max tokens for Anthropic and Groq clients
  • Loading branch information
danielchalef committed Sep 22, 2024
1 parent d8c49c1 commit 14d5ce0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion graphiti_core/llm_client/anthropic_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
logger = logging.getLogger(__name__)

DEFAULT_MODEL = 'claude-3-5-sonnet-20240620'
DEFAULT_MAX_TOKENS = 8192


class AnthropicClient(LLMClient):
def __init__(self, config: LLMConfig | None = None, cache: bool = False):
if config is None:
config = LLMConfig()
config = LLMConfig(max_tokens=DEFAULT_MAX_TOKENS)
elif config.max_tokens is None:
config.max_tokens = DEFAULT_MAX_TOKENS
super().__init__(config, cache)

self.client = AsyncAnthropic(
api_key=config.api_key,
# we'll use tenacity to retry
Expand Down
6 changes: 5 additions & 1 deletion graphiti_core/llm_client/groq_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
logger = logging.getLogger(__name__)

DEFAULT_MODEL = 'llama-3.1-70b-versatile'
DEFAULT_MAX_TOKENS = 2048


class GroqClient(LLMClient):
def __init__(self, config: LLMConfig | None = None, cache: bool = False):
if config is None:
config = LLMConfig()
config = LLMConfig(max_tokens=DEFAULT_MAX_TOKENS)
elif config.max_tokens is None:
config.max_tokens = DEFAULT_MAX_TOKENS
super().__init__(config, cache)

self.client = AsyncGroq(api_key=config.api_key)

def get_embedder(self) -> typing.Any:
Expand Down

0 comments on commit 14d5ce0

Please sign in to comment.