Skip to content

Commit

Permalink
Override default max tokens for Anthropic and Groq clients
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalef committed Sep 22, 2024
1 parent ecfc45f commit ebd7d4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions graphiti_core/llm_client/anthropic_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@
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)

# Override the default max tokens for Anthropic
if self.max_tokens is None:
self.max_tokens = DEFAULT_MAX_TOKENS

self.client = AsyncAnthropic(
api_key=config.api_key,
# we'll use tenacity to retry
Expand Down
8 changes: 3 additions & 5 deletions graphiti_core/llm_client/groq_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
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)

# Override the default max tokens for Groq
if self.max_tokens is None:
self.max_tokens = DEFAULT_MAX_TOKENS

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

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

0 comments on commit ebd7d4b

Please sign in to comment.