style: repo linting pass (#33089)

enable docstring-code-format
This commit is contained in:
Mason Daugherty
2025-09-24 15:25:55 -04:00
committed by GitHub
parent 083bb3cdd7
commit b92b394804
33 changed files with 687 additions and 283 deletions

View File

@@ -326,7 +326,8 @@ class ChatHuggingFace(BaseChatModel):
.. code-block:: python
from huggingface_hub import login
login() # You will be prompted for your HF key, which will then be saved locally
login() # You will be prompted for your HF key, which will then be saved locally
Key init args — completion params:
llm: `HuggingFaceTextGenInference`, `HuggingFaceEndpoint`, `HuggingFaceHub`, or
@@ -447,9 +448,13 @@ class ChatHuggingFace(BaseChatModel):
.. code-block:: python
[{'name': 'GetPopulation',
'args': {'location': 'Los Angeles, CA'},
'id': '0'}]
[
{
"name": "GetPopulation",
"args": {"location": "Los Angeles, CA"},
"id": "0",
}
]
Response metadata
.. code-block:: python
@@ -458,10 +463,13 @@ class ChatHuggingFace(BaseChatModel):
ai_msg.response_metadata
.. code-block:: python
{'token_usage': ChatCompletionOutputUsage(completion_tokens=100,
prompt_tokens=8, total_tokens=108),
'model': '',
'finish_reason': 'length'}
{
"token_usage": ChatCompletionOutputUsage(
completion_tokens=100, prompt_tokens=8, total_tokens=108
),
"model": "",
"finish_reason": "length",
}
""" # noqa: E501

View File

@@ -28,12 +28,12 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings):
from langchain_huggingface import HuggingFaceEmbeddings
model_name = "sentence-transformers/all-mpnet-base-v2"
model_kwargs = {'device': 'cpu'}
encode_kwargs = {'normalize_embeddings': False}
model_kwargs = {"device": "cpu"}
encode_kwargs = {"normalize_embeddings": False}
hf = HuggingFaceEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
encode_kwargs=encode_kwargs,
)
"""

View File

@@ -23,6 +23,7 @@ class HuggingFaceEndpointEmbeddings(BaseModel, Embeddings):
.. code-block:: python
from langchain_huggingface import HuggingFaceEndpointEmbeddings
model = "sentence-transformers/all-mpnet-base-v2"
hf = HuggingFaceEndpointEmbeddings(
model=model,

View File

@@ -45,7 +45,7 @@ class HuggingFaceEndpoint(LLM):
typical_p=0.95,
temperature=0.01,
repetition_penalty=1.03,
huggingfacehub_api_token="my-api-key"
huggingfacehub_api_token="my-api-key",
)
print(llm.invoke("What is Deep Learning?"))
@@ -63,7 +63,7 @@ class HuggingFaceEndpoint(LLM):
repetition_penalty=1.03,
callbacks=callbacks,
streaming=True,
huggingfacehub_api_token="my-api-key"
huggingfacehub_api_token="my-api-key",
)
print(llm.invoke("What is Deep Learning?"))
@@ -73,7 +73,7 @@ class HuggingFaceEndpoint(LLM):
provider="novita",
max_new_tokens=100,
do_sample=False,
huggingfacehub_api_token="my-api-key"
huggingfacehub_api_token="my-api-key",
)
print(llm.invoke("What is Deep Learning?"))

View File

@@ -61,7 +61,10 @@ class HuggingFacePipeline(BaseLLM):
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
pipe = pipeline(
"text-generation", model=model, tokenizer=tokenizer, max_new_tokens=10
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=10,
)
hf = HuggingFacePipeline(pipeline=pipe)