From e0d906623844d9348e3bf0437025b3a4e07c0d1e Mon Sep 17 00:00:00 2001 From: Aymeric Date: Mon, 6 May 2024 15:09:53 +0200 Subject: [PATCH] Add example for HfEngine --- docs/source/en/main_classes/agent.md | 14 ++++++++++++++ src/transformers/agents/tools.py | 1 + 2 files changed, 15 insertions(+) diff --git a/docs/source/en/main_classes/agent.md b/docs/source/en/main_classes/agent.md index 6c9448814998ce..fe483d6dde9e60 100644 --- a/docs/source/en/main_classes/agent.md +++ b/docs/source/en/main_classes/agent.md @@ -88,6 +88,20 @@ These engines have the following specification: For convenience, we have added a `HfEngine` that implements this and uses an inference endpoint for the execution of the LLM. +```python +>>> from transformers import HfEngine + +>>> messages = [ +... {"role": "user", "content": "Hello, how are you?"}, +... {"role": "assistant", "content": "I'm doing great. How can I help you today?"}, +... {"role": "user", "content": "I'd like to show off how chat templating works!"}, +... ] + +>>> HfEngine()(messages) + +"That sounds like a lot of fun! I'd be happy to help you demonstrate chat templating. Please go ahead and show me how it works." +``` + [[autodoc]] HfEngine diff --git a/src/transformers/agents/tools.py b/src/transformers/agents/tools.py index 5898342d9b002f..4016a20f81e441 100644 --- a/src/transformers/agents/tools.py +++ b/src/transformers/agents/tools.py @@ -401,6 +401,7 @@ def from_langchain(langchain_tool): """ Creates a [`Tool`] from a langchain tool. """ + class LangChainToolWrapper(Tool): def __init__(self, _langchain_tool): super().__init__()