Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langfun/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions langfun/core/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion langfun/core/langfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.',

Expand Down
18 changes: 9 additions & 9 deletions langfun/core/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1374,7 +1374,7 @@ def get(


class UsageSummary(pg.Object, pg.views.HtmlTreeView.Extension):
"""Usage sumary."""
"""Usage summary."""

class AggregatedUsage(pg.Object):
"""Aggregated usage."""
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion langfun/core/language_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
10 changes: 5 additions & 5 deletions langfun/core/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

#
Expand Down Expand Up @@ -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'

#
Expand All @@ -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()
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion langfun/core/modality.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions langfun/core/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion langfun/core/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions langfun/core/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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():
Expand Down