Skip to content

Commit 10f8c21

Browse files
committed
Add ruff doctring linting
1 parent 8fe98a8 commit 10f8c21

File tree

7 files changed

+45
-42
lines changed

7 files changed

+45
-42
lines changed

pyproject.toml

+15
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,18 @@ exclude = [
3939

4040
[tool.setuptools]
4141
license-files = []
42+
43+
[tool.ruff.lint]
44+
select = ["E", "F", "I", "D"]
45+
ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D107", "E501"]
46+
47+
# D100: Missing docstring in a public module
48+
# D101: Missing docstring in a public class
49+
# D102: Missing docstring in a public method
50+
# D103: Missing docstring in a public function
51+
# D104: Missing docstring in a public package
52+
# D105: Missing docstring in a magic method
53+
# D107: Missing docstring in an __init__ method
54+
55+
[tool.ruff.lint.pydocstyle]
56+
convention = "google"

weaviate_agents/base.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44

55

66
class _BaseAgent:
7-
"""
8-
Base class for all agents.
9-
"""
7+
"""Base class for all agents."""
108

119
def __init__(
1210
self,
1311
client: WeaviateClient,
1412
agents_host: Union[str, None] = None,
1513
):
16-
"""
17-
Initialize the base agent.
14+
"""Initialize the base agent.
1815
1916
Args:
2017
client: A Weaviate client instance, either sync or async.

weaviate_agents/personalization/personalization_agent.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def create(
5555
reference_collection: The name of the collection to personalize
5656
user_properties: Optional dictionary of user properties and their data types
5757
agents_host: Optional host URL for the agents service
58+
vector_name: Optional name of the vector field to use
5859
timeout: Optional timeout for the request
60+
5961
Returns:
60-
PersonalizationAgent: A new instance of the Personalization Agent
62+
A new instance of the Personalization Agent
6163
"""
6264
agent = cls(
6365
client=client,
@@ -89,9 +91,11 @@ def connect(
8991
client: The Weaviate client
9092
reference_collection: The name of the collection to connect to
9193
agents_host: Optional host URL for the agents service
94+
vector_name: Optional name of the vector field to use
9295
timeout: Optional timeout for the request
96+
9397
Returns:
94-
PersonalizationAgent: An instance of the Personalization Agent
98+
An instance of the Personalization Agent
9599
"""
96100
agent = cls(
97101
client=client,
@@ -116,8 +120,10 @@ def _initialize(
116120
117121
Args:
118122
reference_collection: The name of the collection to personalize
123+
create: Whether to create a new personalization agent
119124
user_properties: Optional dictionary of user properties and their data types
120125
vector_name: Optional name of the vector field to use
126+
timeout: Optional timeout for the request
121127
"""
122128
request_data = {
123129
"collection_name": reference_collection,
@@ -146,7 +152,6 @@ def add_persona(self, persona: Persona) -> None:
146152
persona: The persona to add. The persona must have a persona_id and properties that match the user properties
147153
defined when the Personalization Agent was created.
148154
"""
149-
150155
request_data = {
151156
"persona": persona.model_dump(mode="json"),
152157
"personalization_request": {
@@ -198,7 +203,7 @@ def get_persona(self, persona_id: UUID) -> Persona:
198203
persona_id: The ID of the persona to retrieve
199204
200205
Returns:
201-
Persona: The retrieved persona
206+
The retrieved persona
202207
"""
203208
request_data = {
204209
"collection_name": self._reference_collection,
@@ -249,7 +254,7 @@ def has_persona(self, persona_id: UUID) -> bool:
249254
persona_id: The ID of the persona to check
250255
251256
Returns:
252-
bool: True if the persona exists, False otherwise
257+
True if the persona exists, False otherwise
253258
"""
254259
request_data = {
255260
"collection_name": self._reference_collection,
@@ -325,7 +330,7 @@ def get_interactions(
325330
interaction_type: The type of interaction to filter by (e.g. "positive", "negative")
326331
327332
Returns:
328-
list[PersonaInteractionResponse]: List of matching interactions for the persona
333+
List of matching interactions for the persona
329334
"""
330335
request_data = {
331336
"interaction_request": {
@@ -372,6 +377,12 @@ def get_objects(
372377
persona_id: The ID of the persona to get objects for
373378
limit: The maximum number of objects to return
374379
recent_interactions_count: The number of recent interactions to consider
380+
exclude_interacted_items: Whether to exclude items that have been interacted with
381+
decay_rate: The decay rate for the personalization algorithm
382+
exclude_items: List of items to exclude from the results
383+
use_agent_ranking: Whether to use agent ranking for the results
384+
explain_results: Whether to explain the results
385+
instruction: Optional instruction to guide the personalization process
375386
"""
376387
request_data = {
377388
"objects_request": {
@@ -422,7 +433,7 @@ def exists(
422433
timeout: Optional timeout for the request
423434
424435
Returns:
425-
bool: True if the persona collection exists, False otherwise
436+
True if the persona collection exists, False otherwise
426437
"""
427438
# Initialize base values from client
428439
base_agent = cls(client, reference_collection, agents_host=agents_host)

weaviate_agents/query/classes/response.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class IntegerPropertyFilter(BaseModel):
3030

3131

3232
class TextPropertyFilter(BaseModel):
33-
"""Filter text properties using equality or LIKE operators"""
33+
"""Filter text properties using equality or LIKE operators."""
3434

3535
property_name: str
3636
operator: ComparisonOperator
3737
value: str
3838

3939

4040
class BooleanPropertyFilter(BaseModel):
41-
"""Filter boolean properties using equality operators"""
41+
"""Filter boolean properties using equality operators."""
4242

4343
property_name: str
4444
operator: ComparisonOperator
@@ -80,30 +80,29 @@ class BooleanMetrics(str, Enum):
8080

8181

8282
class IntegerPropertyAggregation(BaseModel):
83-
"""Aggregate numeric properties using statistical functions"""
83+
"""Aggregate numeric properties using statistical functions."""
8484

8585
property_name: str
8686
metrics: NumericMetrics
8787

8888

8989
class TextPropertyAggregation(BaseModel):
90-
"""Aggregate text properties using frequency analysis"""
90+
"""Aggregate text properties using frequency analysis."""
9191

9292
property_name: str
9393
metrics: TextMetrics
9494
top_occurrences_limit: Optional[int] = None
9595

9696

9797
class BooleanPropertyAggregation(BaseModel):
98-
"""Aggregate boolean properties using statistical functions"""
98+
"""Aggregate boolean properties using statistical functions."""
9999

100100
property_name: str
101101
metrics: BooleanMetrics
102102

103103

104104
class AggregationResult(BaseModel):
105-
"""
106-
The aggregations to be performed on a collection in a vector database.
105+
"""The aggregations to be performed on a collection in a vector database.
107106
108107
They should be based on the original user query and can include multiple
109108
aggregations across different properties and metrics.
@@ -160,11 +159,6 @@ class QueryAgentResponse(BaseModel):
160159
sources: list[Source]
161160

162161
def display(self) -> None:
163-
"""
164-
Display a pretty-printed summary of the QueryAgentResponse object.
165-
166-
Returns:
167-
None
168-
"""
162+
"""Display a pretty-printed summary of the QueryAgentResponse object."""
169163
print_query_agent_response(self)
170164
return None

weaviate_agents/query/query_agent.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ def __init__(
2727
):
2828
"""Initialize the QueryAgent.
2929
30-
Warning:
31-
Weaviate Agents - Query Agent is an early stage alpha product. The API is subject to
32-
breaking changes. Please ensure you are using the latest version.
33-
34-
For more information, see the [Weaviate Agents - Query Agent Docs](https://weaviate.io/developers/agents/query)
35-
3630
Args:
3731
client: The Weaviate client connected to a Weaviate Cloud cluster.
3832
collections: The collections to query.
@@ -55,8 +49,7 @@ def run(
5549
view_properties: Optional[List[str]] = None,
5650
context: Optional[QueryAgentResponse] = None,
5751
) -> QueryAgentResponse:
58-
"""
59-
Run the query agent.
52+
"""Run the query agent.
6053
6154
Args:
6255
query: The natural language query string for the agent.

weaviate_agents/transformation/transformation_agent.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ def __init__(
3333
):
3434
"""Initialize the TransformationAgent.
3535
36-
Warning:
37-
Weaviate Agents - Transformation Agent is an early stage alpha product. The API is subject to
38-
breaking changes. Please ensure you are using the latest version of the client.
39-
40-
For more information, see the [Weaviate Agents - Transformation Agent Docs](https://weaviate.io/developers/agents/transformation)
41-
4236
Args:
4337
client: The Weaviate client connected to a Weaviate Cloud cluster.
4438
collection: The collection to perform transformations on.
@@ -61,7 +55,7 @@ def update_all(self) -> TransformationResponse:
6155
"""Triggers all configured transformation operations on the collection.
6256
6357
Returns:
64-
TransformationResponse: response with workflow ID for tracking transformation progress.
58+
Response with workflow ID for tracking transformation progress.
6559
6660
Raises:
6761
httpx.HTTPError: If there is an error communicating with the transformation service.
@@ -130,7 +124,7 @@ def get_status(self, workflow_id: str) -> dict:
130124
workflow_id: The ID of the workflow to check, obtained from TransformationResponse
131125
132126
Returns:
133-
dict: The status response from the transformation service
127+
The status response from the transformation service
134128
135129
Raises:
136130
httpx.HTTPError: If there is an error communicating with the transformation service

weaviate_agents/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
def print_query_agent_response(response: "QueryAgentResponse"):
1515
"""Prints a formatted response from the Query Agent using rich."""
16-
1716
console.print(
1817
Panel(
1918
response.original_query,

0 commit comments

Comments
 (0)