Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename internal methods #90

Merged
merged 11 commits into from
Oct 11, 2024
16 changes: 8 additions & 8 deletions docetl/operations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def gen_embedding(self, model: str, input: List[str]) -> List[float]:

# TODO: optimize this
@freezeargs
def cached_call_llm(
def _cached_call_llm(
self,
cache_key: str,
model: str,
Expand All @@ -427,7 +427,7 @@ def cached_call_llm(
"""
Cached version of the call_llm function.

This function serves as a cached wrapper around call_llm_with_cache. It uses
This function serves as a cached wrapper around _call_llm_with_cache. It uses
the @freezeargs decorator to ensure immutable arguments and @functools.lru_cache
for caching results.

Expand All @@ -440,12 +440,12 @@ def cached_call_llm(
tools (Optional[str]): The tools to pass to the LLM.
scratchpad (Optional[str]): The scratchpad to use for the operation.
Returns:
str: The result from call_llm_with_cache.
str: The result from _call_llm_with_cache.
"""
with cache as c:
result = c.get(cache_key)
if result is None:
result = self.call_llm_with_cache(
result = self._call_llm_with_cache(
model, op_type, messages, output_schema, tools, scratchpad
)
# Only set the cache if the result tool calls or output is not empty
Expand Down Expand Up @@ -554,7 +554,7 @@ def call_llm(
rate_limited_attempt = 0
while attempt <= max_retries:
try:
return timeout(timeout_seconds)(self.cached_call_llm)(
return timeout(timeout_seconds)(self._cached_call_llm)(
key,
model,
op_type,
Expand Down Expand Up @@ -583,7 +583,7 @@ def call_llm(
return {}
attempt += 1

def call_llm_with_cache(
def _call_llm_with_cache(
self,
model: str,
op_type: str,
Expand Down Expand Up @@ -892,7 +892,7 @@ def parse_llm_response(
This function extracts the tool calls from the LLM response and returns the arguments
"""
try:
return self.parse_llm_response_helper(response, schema, tools)
return self._parse_llm_response_helper(response, schema, tools)
except InvalidOutputError as e:
if manually_fix_errors:
rprint(
Expand All @@ -909,7 +909,7 @@ def parse_llm_response(
else:
raise e

def parse_llm_response_helper(
def _parse_llm_response_helper(
self,
response: Any,
schema: Dict[str, Any] = {},
Expand Down
Loading