claude-self-reflect 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,7 +17,8 @@ def main():
|
|
|
17
17
|
from .server import mcp
|
|
18
18
|
|
|
19
19
|
# Run the server with the specified transport
|
|
20
|
-
|
|
20
|
+
# Disable FastMCP banner to prevent JSON output interference
|
|
21
|
+
mcp.run(transport=args.transport, show_banner=False)
|
|
21
22
|
|
|
22
23
|
if __name__ == "__main__":
|
|
23
24
|
main()
|
package/mcp-server/src/server.py
CHANGED
|
@@ -12,10 +12,24 @@ from fastmcp import FastMCP, Context
|
|
|
12
12
|
from pydantic import BaseModel, Field
|
|
13
13
|
from qdrant_client import AsyncQdrantClient, models
|
|
14
14
|
from qdrant_client.models import (
|
|
15
|
-
PointStruct, VectorParams, Distance
|
|
16
|
-
FormulaQuery, DecayParamsExpression, SumExpression,
|
|
17
|
-
DatetimeExpression, DatetimeKeyExpression
|
|
15
|
+
PointStruct, VectorParams, Distance
|
|
18
16
|
)
|
|
17
|
+
|
|
18
|
+
# Try to import newer Qdrant API for native decay
|
|
19
|
+
try:
|
|
20
|
+
from qdrant_client.models import (
|
|
21
|
+
Query, Formula, Expression, MultExpression,
|
|
22
|
+
ExpDecayExpression, DecayParamsExpression,
|
|
23
|
+
SearchRequest, NamedQuery
|
|
24
|
+
)
|
|
25
|
+
NATIVE_DECAY_AVAILABLE = True
|
|
26
|
+
except ImportError:
|
|
27
|
+
# Fall back to older API
|
|
28
|
+
from qdrant_client.models import (
|
|
29
|
+
FormulaQuery, DecayParamsExpression, SumExpression,
|
|
30
|
+
DatetimeExpression, DatetimeKeyExpression
|
|
31
|
+
)
|
|
32
|
+
NATIVE_DECAY_AVAILABLE = False
|
|
19
33
|
import voyageai
|
|
20
34
|
from dotenv import load_dotenv
|
|
21
35
|
|
|
@@ -176,11 +190,56 @@ async def reflect_on_past(
|
|
|
176
190
|
# Search each collection
|
|
177
191
|
for collection_name in all_collections:
|
|
178
192
|
try:
|
|
179
|
-
if should_use_decay and USE_NATIVE_DECAY:
|
|
180
|
-
# Use native Qdrant decay
|
|
181
|
-
await ctx.debug(f"Using NATIVE Qdrant decay for {collection_name}")
|
|
193
|
+
if should_use_decay and USE_NATIVE_DECAY and NATIVE_DECAY_AVAILABLE:
|
|
194
|
+
# Use native Qdrant decay with newer API
|
|
195
|
+
await ctx.debug(f"Using NATIVE Qdrant decay (new API) for {collection_name}")
|
|
196
|
+
|
|
197
|
+
# Build the query with native Qdrant decay formula using newer API
|
|
198
|
+
query_obj = Query(
|
|
199
|
+
nearest=query_embedding,
|
|
200
|
+
formula=Formula(
|
|
201
|
+
sum=[
|
|
202
|
+
# Original similarity score
|
|
203
|
+
Expression(variable="score"),
|
|
204
|
+
# Decay boost term
|
|
205
|
+
Expression(
|
|
206
|
+
mult=MultExpression(
|
|
207
|
+
mult=[
|
|
208
|
+
# Decay weight
|
|
209
|
+
Expression(constant=DECAY_WEIGHT),
|
|
210
|
+
# Exponential decay function
|
|
211
|
+
Expression(
|
|
212
|
+
exp_decay=DecayParamsExpression(
|
|
213
|
+
# Use timestamp field for decay
|
|
214
|
+
x=Expression(datetime_key="timestamp"),
|
|
215
|
+
# Decay from current time (server-side)
|
|
216
|
+
target=Expression(datetime="now"),
|
|
217
|
+
# Scale in milliseconds
|
|
218
|
+
scale=DECAY_SCALE_DAYS * 24 * 60 * 60 * 1000,
|
|
219
|
+
# Standard exponential decay midpoint
|
|
220
|
+
midpoint=0.5
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
]
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
]
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# Execute query with native decay (new API)
|
|
231
|
+
results = await qdrant_client.query_points(
|
|
232
|
+
collection_name=collection_name,
|
|
233
|
+
query=query_obj,
|
|
234
|
+
limit=limit,
|
|
235
|
+
score_threshold=min_score,
|
|
236
|
+
with_payload=True
|
|
237
|
+
)
|
|
238
|
+
elif should_use_decay and USE_NATIVE_DECAY and not NATIVE_DECAY_AVAILABLE:
|
|
239
|
+
# Use native Qdrant decay with older API
|
|
240
|
+
await ctx.debug(f"Using NATIVE Qdrant decay (legacy API) for {collection_name}")
|
|
182
241
|
|
|
183
|
-
# Build the query with native Qdrant decay formula
|
|
242
|
+
# Build the query with native Qdrant decay formula using older API
|
|
184
243
|
query_obj = FormulaQuery(
|
|
185
244
|
nearest=query_embedding,
|
|
186
245
|
formula=SumExpression(
|