Skip to content

Commit 3fe0ef1

Browse files
authored
fix: resolve a flood of console warnings (#1089)
1 parent 7b209ce commit 3fe0ef1

6 files changed

Lines changed: 27 additions & 27 deletions

File tree

aperag/flow/engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def _bind_node_inputs(self, node: NodeInstance, runner_info: dict) -> tuple:
378378
resolved_inputs = self.resolve_expression(raw_inputs, node.id)
379379
input_model = runner_info["input_model"]
380380
try:
381-
user_input = input_model.parse_obj(resolved_inputs)
381+
user_input = input_model.model_validate(resolved_inputs)
382382
except Exception as e:
383383
raise ValidationError(f"Input validation error for node {node.id}: {e}")
384384
sys_input = SystemInput(**self.context.global_variables)
@@ -400,7 +400,7 @@ async def _execute_node(self, node: NodeInstance) -> None:
400400
node.id,
401401
node.type,
402402
self.execution_id,
403-
{"node_type": node.type, "inputs": user_input.dict()},
403+
{"node_type": node.type, "inputs": user_input.model_dump()},
404404
)
405405
)
406406
outputs = await runner.run(user_input, sys_input)

aperag/index/fulltext_index.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def __init__(self, es_host: str = None):
3737
# Add timeout configuration for sync ES client
3838
self.es = Elasticsearch(
3939
self.es_host,
40-
timeout=settings.es_timeout, # Use timeout from settings
40+
request_timeout=settings.es_timeout, # Use timeout from settings
4141
max_retries=settings.es_max_retries, # Use max retries from settings
4242
retry_on_timeout=True, # Retry on timeout errors
4343
)
4444
# Add timeout configuration for async ES client using settings
4545
self.async_es = AsyncElasticsearch(
4646
self.es_host,
47-
timeout=settings.es_timeout, # Use timeout from settings
47+
request_timeout=settings.es_timeout, # Use timeout from settings
4848
max_retries=settings.es_max_retries, # Use max retries from settings
4949
retry_on_timeout=True, # Retry on timeout errors
5050
)
@@ -266,7 +266,7 @@ def __init__(self, ctx: Dict[str, Any]):
266266
# Add timeout configuration for ES client using settings
267267
self.client = AsyncElasticsearch(
268268
ctx.get("es_host", "http://127.0.0.1:9200"),
269-
timeout=ctx.get("es_timeout", settings.es_timeout), # Use timeout from context or settings
269+
request_timeout=ctx.get("es_timeout", settings.es_timeout), # Use timeout from context or settings
270270
max_retries=ctx.get("es_max_retries", settings.es_max_retries), # Use max retries from context or settings
271271
retry_on_timeout=True, # Retry on timeout errors
272272
)
@@ -291,7 +291,7 @@ async def extract(self, text):
291291
logger.warning("index %s not exists", self.index_name)
292292
return []
293293

294-
resp = await self.client.indices.analyze(index=self.index_name, body={"text": text}, analyzer="ik_smart")
294+
resp = await self.client.indices.analyze(index=self.index_name, body={"text": text, "analyzer": "ik_smart"})
295295
tokens = {}
296296
for item in resp.body["tokens"]:
297297
token = item["token"]
@@ -307,7 +307,7 @@ async def extract(self, text):
307307

308308
es = Elasticsearch(
309309
settings.es_host,
310-
timeout=settings.es_timeout, # Use timeout from settings
310+
request_timeout=settings.es_timeout, # Use timeout from settings
311311
max_retries=settings.es_max_retries, # Use max retries from settings
312312
retry_on_timeout=True, # Retry on timeout errors
313313
)

aperag/schema/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
def parseCollectionConfig(config: str) -> CollectionConfig:
2121
try:
2222
config_dict = json.loads(config)
23-
collection_config = CollectionConfig.parse_obj(config_dict)
23+
collection_config = CollectionConfig.model_validate(config_dict)
2424
return collection_config
2525
except json.JSONDecodeError as e:
2626
raise ValueError(f"Invalid JSON string: {str(e)}")

aperag/service/collection_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ async def create_search(
254254
user=user,
255255
collection_id=collection_id,
256256
query=data.query,
257-
vector_search=data.vector_search.dict() if data.vector_search else None,
258-
fulltext_search=data.fulltext_search.dict() if data.fulltext_search else None,
259-
graph_search=data.graph_search.dict() if data.graph_search else None,
260-
items=[item.dict() for item in items],
257+
vector_search=data.vector_search.model_dump() if data.vector_search else None,
258+
fulltext_search=data.fulltext_search.model_dump() if data.fulltext_search else None,
259+
graph_search=data.graph_search.model_dump() if data.graph_search else None,
260+
items=[item.model_dump() for item in items],
261261
)
262262
return SearchResult(
263263
id=record.id,

aperag/utils/audit_decorator.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ def _extract_response_data(response: Any) -> Optional[Dict[str, Any]]:
3131
if isinstance(response, dict):
3232
return response
3333

34-
# If response has a dict() method (Pydantic models)
35-
elif hasattr(response, "dict"):
36-
return response.dict()
37-
3834
# If response has a model_dump() method (Pydantic v2)
3935
elif hasattr(response, "model_dump"):
4036
return response.model_dump()
4137

38+
# If response has a dict() method (Pydantic models)
39+
elif hasattr(response, "dict"):
40+
return response.dict()
41+
4242
# If response is a list of dicts or models
4343
elif isinstance(response, list):
4444
result = []
4545
for item in response:
4646
if isinstance(item, dict):
4747
result.append(item)
48-
elif hasattr(item, "dict"):
49-
result.append(item.dict())
5048
elif hasattr(item, "model_dump"):
5149
result.append(item.model_dump())
50+
elif hasattr(item, "dict"):
51+
result.append(item.dict())
5252
else:
5353
result.append(str(item))
5454
return {"items": result}
@@ -119,15 +119,15 @@ def _extract_request_data_from_args(request: Request, kwargs: dict) -> Optional[
119119

120120
# Try to serialize the value
121121
try:
122-
if hasattr(value, "dict"): # Pydantic model
123-
serialized = value.dict()
124-
# Clean up the serialized data - remove null values and filter sensitive data
122+
if hasattr(value, "model_dump"): # Pydantic v2
123+
serialized = value.model_dump()
124+
# Clean up the serialized data
125125
cleaned_data = _clean_data_for_audit(serialized)
126126
if cleaned_data: # Only add if there's actual data
127127
parsed_data[key] = cleaned_data
128-
elif hasattr(value, "model_dump"): # Pydantic v2
129-
serialized = value.model_dump()
130-
# Clean up the serialized data
128+
elif hasattr(value, "dict"): # Pydantic model
129+
serialized = value.dict()
130+
# Clean up the serialized data - remove null values and filter sensitive data
131131
cleaned_data = _clean_data_for_audit(serialized)
132132
if cleaned_data: # Only add if there's actual data
133133
parsed_data[key] = cleaned_data

aperag/vectorstore/qdrant_connector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ def search(self, query: QueryWithEmbedding, **kwargs):
5353
search_params = kwargs.get("search_params")
5454
score_threshold = kwargs.get("score_threshold", 0.1)
5555

56-
hits = self.client.search(
56+
hits = self.client.query_points(
5757
collection_name=self.collection_name,
58-
query_vector=query.embedding,
58+
query=query.embedding,
5959
with_vectors=True,
6060
limit=query.top_k,
6161
consistency=consistency,
6262
search_params=search_params,
6363
score_threshold=score_threshold,
6464
)
6565

66-
results = [self._convert_scored_point_to_document_with_score(point) for point in hits]
66+
results = [self._convert_scored_point_to_document_with_score(point) for point in hits.points]
6767
results = [result for result in results if result is not None]
6868

6969
return QueryResult(

0 commit comments

Comments
 (0)