From a10e4d8edf00599d2e3438c2af51818a32cc46f1 Mon Sep 17 00:00:00 2001 From: leo-gan Date: Mon, 2 Jun 2025 16:47:57 -0700 Subject: [PATCH] fixed misspells --- langfun/core/component.py | 2 +- langfun/core/concurrent.py | 4 ++-- langfun/core/langfunc.py | 2 +- langfun/core/language_model.py | 18 +++++++++--------- langfun/core/language_model_test.py | 2 +- langfun/core/message.py | 10 +++++----- langfun/core/modality.py | 2 +- langfun/core/sampling.py | 4 ++-- langfun/core/subscription.py | 2 +- langfun/core/template.py | 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/langfun/core/component.py b/langfun/core/component.py index 622e7214..c9188901 100644 --- a/langfun/core/component.py +++ b/langfun/core/component.py @@ -81,7 +81,7 @@ def use_settings( Args: cascade: If True, this override will apply to both current scope and nested scope, meaning that this `lf.context` will take precedence over all - nested `lf.context` on the overriden variables. + nested `lf.context` on the overridden variables. **settings: Key/values as override for component attributes. Returns: diff --git a/langfun/core/concurrent.py b/langfun/core/concurrent.py index b4430648..0d67c67a 100644 --- a/langfun/core/concurrent.py +++ b/langfun/core/concurrent.py @@ -203,7 +203,7 @@ def concurrent_execute( list of outputs. Returns: - A list of ouputs. Each is the return value of `func` based on the input + A list of outputs. Each is the return value of `func` based on the input value. Order is preserved. """ jobs = [] @@ -647,7 +647,7 @@ def concurrent_map( exponential_backoff: bool = True, return_jobs: bool = False, ) -> Iterator[Any]: - """Maps inputs to outptus via func concurrently under current context. + """Maps inputs to outputs via func concurrently under current context. Args: func: A user function. diff --git a/langfun/core/langfunc.py b/langfun/core/langfunc.py index 6b932ebe..930c9d80 100644 --- a/langfun/core/langfunc.py +++ b/langfun/core/langfunc.py @@ -95,7 +95,7 @@ class ReAct(lf.LangFunc): {{ tool_examples }} {{ user_input }} ''' - # Default preamble, which could be overriden from subclass + # Default preamble, which could be overridden from subclass # or parsed from the `__init__` argument. preamble = 'Please help me on my task based on the following tools.', diff --git a/langfun/core/language_model.py b/langfun/core/language_model.py index 290889d9..7004d0c3 100644 --- a/langfun/core/language_model.py +++ b/langfun/core/language_model.py @@ -405,7 +405,7 @@ class LMSamplingUsage(pg.Object): float | None, ( 'Estimated cost in US dollars. If None, cost estimating is not ' - 'suppported on the model being queried.' + 'supported on the model being queried.' ), ] = None retry_stats: RetryStats = RetryStats() @@ -604,7 +604,7 @@ class LMScoringResult(pg.Object): ] gradients: Annotated[ Any | None, - '(Optional) gradients from the score method, w.r.t.' + + '(Optional) gradients from the score method, w.r.t.' ' prompt.metadata.weights.', ] = None @@ -677,7 +677,7 @@ class LanguageModel(component.Component): """Interface of a language model. Language models are at the center of LLM-based agents. ``LanguageModel`` - is the interface to interact with different language modles. + is the interface to interact with different language models. In langfun, users can use different language models with the same agents, allowing fast prototype, as well as side-by-side comparisons. @@ -715,7 +715,7 @@ class LanguageModel(component.Component): int, ( 'A number of max attempts to request the LM if fails.' - 'The retry wait time is determined per LM serivice.' + 'The retry wait time is determined per LM service.' ), ] = 5 @@ -724,7 +724,7 @@ class LanguageModel(component.Component): ( 'An integer as a constant wait time in seconds before next retry, ' 'or a tuple of two integers representing the range of wait time, ' - 'based on which the next wait time will be randmly chosen.' + 'based on which the next wait time will be randomly chosen.' ) ] = (5, 60) @@ -839,7 +839,7 @@ def model_id(self) -> str: @final @property def resource_id(self) -> str: - """Resource ID for performing request parallism control.""" + """Resource ID for performing request parallelism control.""" return self.model_info.resource_id @final @@ -1320,7 +1320,7 @@ def estimate_max_concurrency( max_requests_per_minute: int | None, average_tokens_per_request: int = 250 ) -> int | None: - """Estimates max concurrency concurrency based on the rate limits.""" + """Estimates max concurrency based on the rate limits.""" # NOTE(daiyip): max concurrency is estimated based on the rate limit. # We assume each request has approximately 250 tokens, and each request # takes 1 second to complete. This might not be accurate for all models. @@ -1374,7 +1374,7 @@ def get( class UsageSummary(pg.Object, pg.views.HtmlTreeView.Extension): - """Usage sumary.""" + """Usage summary.""" class AggregatedUsage(pg.Object): """Aggregated usage.""" @@ -1589,7 +1589,7 @@ def track_usages( *lm: The language model(s) to track. If None, track all models in scope. Yields: - A dictionary of model ID to usage. If a model does not supports usage + A dictionary of model ID to usage. If a model does not support usage counting, the dict entry will be None. """ if not lm: diff --git a/langfun/core/language_model_test.py b/langfun/core/language_model_test.py index e582c859..32f0227f 100644 --- a/langfun/core/language_model_test.py +++ b/langfun/core/language_model_test.py @@ -9,7 +9,7 @@ # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the infoific language governing permissions and +# See the License for the specific language governing permissions and # limitations under the License. """Tests for language model.""" diff --git a/langfun/core/message.py b/langfun/core/message.py index f6010927..41c58319 100644 --- a/langfun/core/message.py +++ b/langfun/core/message.py @@ -40,7 +40,7 @@ class Message( meta-data. The subclasses of ``Message`` represent messages sent from different roles. - Agents may use the roles to decide the orchastration logic. + Agents may use the roles to decide the orchestration logic. """ # @@ -75,7 +75,7 @@ class Message( # Constant that tags a message that is generated by `LangFunc.render` TAG_RENDERED = 'rendered' - # Constant that tags an transformed message. + # Constant that tags a transformed message. TAG_TRANSFORMED = 'transformed' # @@ -90,7 +90,7 @@ class Message( dict[str, Any], ( 'The metadata associated with the message, ' - 'which chould carry structured data, such as tool function input. ' + 'which should carry structured data, such as tool function input. ' 'It is a `pg.Dict` object whose keys can be accessed by attributes.' ), ] = pg.Dict() @@ -132,7 +132,7 @@ def __init__( sealed: If True, seal the object from future modification (unless under a `pg.seal(False)` context manager). If False, treat the object as unsealed. If None, it's determined by `cls.allow_symbolic_mutation`. - root_path: The symbolic path for current object. By default it's None, + root_path: The symbolic path for current object. By default, it's None, which indicates that newly constructed object does not have a parent. **kwargs: key/value pairs that will be inserted into metadata. """ @@ -382,7 +382,7 @@ def get_modality( var_name: The referred variable name for the modality object. default: default value. from_message_chain: If True, the look up will be performed from the - message chain. Otherwise it will be performed in current message. + message chain. Otherwise, it will be performed in current message. Returns: A modality object if found, otherwise None. diff --git a/langfun/core/modality.py b/langfun/core/modality.py index e8089f72..11b29280 100644 --- a/langfun/core/modality.py +++ b/langfun/core/modality.py @@ -50,7 +50,7 @@ def format(self, *args, **kwargs) -> str: return Modality.text_marker(self.referred_name) def __str_kwargs__(self) -> dict[str, Any]: - # For modality objects, we don't want to use markdown format when they + # For modality objects, we don't want to use Markdown format when they # are rendered as parts of the prompt. kwargs = super().__str_kwargs__() kwargs.pop('markdown', None) diff --git a/langfun/core/sampling.py b/langfun/core/sampling.py index c061a177..482d6ca7 100644 --- a/langfun/core/sampling.py +++ b/langfun/core/sampling.py @@ -46,7 +46,7 @@ def sweep( num_examples: Number of examples to sample. max_workers: Max number of concurrent workers to do sampling. silence_on_errors: Return None for `lm_input` and `lm_output` when errors - in this category happen. Otherwise error will be raised during sampling. + in this category happen. Otherwise, error will be raised during sampling. ignore_examples_with_errors: If True, the examples with erratic lm_input or lm_output will not be included. **kwargs: Keyword arguments as rendering variables. @@ -92,7 +92,7 @@ def random_sample( num_examples: Number of examples to sample. max_workers: Max number of concurrent workers to do sampling. silence_on_errors: Return None for `lm_input` and `lm_output` when errors - in this category happen. Otherwise error will be raised during sampling. + in this category happen. Otherwise, error will be raised during sampling. ignore_examples_with_errors: If True, the examples with erratic lm_input or lm_output will not be included. seed: Random seed. diff --git a/langfun/core/subscription.py b/langfun/core/subscription.py index 78424f47..9632eca7 100644 --- a/langfun/core/subscription.py +++ b/langfun/core/subscription.py @@ -51,7 +51,7 @@ def sender_type(cls) -> Type[Any]: @classmethod def accepts(cls, event: Event[Any]) -> bool: - """Returns True if current event handler class can accepts an event.""" + """Returns True if current event handler class can accept an event.""" return isinstance(event, cls.event_type()) @abc.abstractmethod diff --git a/langfun/core/template.py b/langfun/core/template.py index e1b2f942..0d1b900f 100644 --- a/langfun/core/template.py +++ b/langfun/core/template.py @@ -51,7 +51,7 @@ class Template( ): """Langfun string template. - Langfun uses jinja2 as its template engine. Pleaes check out + Langfun uses jinja2 as its template engine. Please check out https://jinja.palletsprojects.com/en/3.1.x/templates/ for detailed explanation on the template language. """ @@ -85,7 +85,7 @@ class Template( ] def __init_subclass__(cls): - # NOTE(daiyip): class attribute `template_str` may exists in 2 ways: + # NOTE(daiyip): class attribute `template_str` may exist in 2 ways: # A string: specified by the user as the new default value for template_str. # A property: inherited from the base class. In this case, we only update # its default value when template_str can be extracted from the docstr. @@ -366,7 +366,7 @@ def render( assert top is self, (top, self) def additional_metadata(self) -> dict[str, Any]: - """Returns additional metadta to be carried in the rendered message.""" + """Returns additional metadata to be carried in the rendered message.""" metadata = {} # Carry metadata from `lf.context`. for k, v in component.all_contextual_values().items():