Skip to content

Commit 4a133ae

Browse files
committed
Instruction Enforcement
1 parent 7b16e64 commit 4a133ae

File tree

7 files changed

+166
-28
lines changed

7 files changed

+166
-28
lines changed

.agents/PINECONE-go.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
55
This guide provides Go-specific patterns, examples, and best practices for the Pinecone SDK.
66

7+
## 🚨 MANDATORY RULES - Read First
8+
9+
**⚠️ CRITICAL: These rules MUST be followed. Violations will cause runtime errors or data issues.**
10+
11+
1. **MUST use namespaces** - Every operation MUST use `.WithNamespace()` method
12+
2. **MUST wait 10+ seconds** - After upserting records, MUST wait 10+ seconds before searching
13+
3. **MUST match field_map** - Record field names MUST match the right side of `--field_map` used when creating index
14+
4. **MUST respect batch limits** - Text records: MAX 96 per batch, Vector records: MAX 1000 per batch
15+
5. **MUST use flat metadata** - No nested objects allowed, only flat key-value pairs
16+
6. **MUST use safe type assertions** - Use `ok` check: `val, ok := field.(string)`
17+
7. **MUST pass context** - All operations require `context.Context` parameter
18+
8. **MUST verify before installing** - Check if SDK/CLI already installed before prompting installation
19+
20+
**Before proceeding with any operation, verify these rules are followed. See detailed sections below for implementation.**
21+
722
## Installation & Setup
823

924
> **⚠️ IMPORTANT**: See [PINECONE.md](./PINECONE.md#-mandatory-always-use-latest-version) for the mandatory requirement to always use the latest version when creating projects.
@@ -467,9 +482,11 @@ if err != nil {
467482

468483
### Semantic Search with Reranking (Best Practice)
469484

485+
**Note**: Reranking is a best practice for production quality results. Quickstarts include reranking to demonstrate usage.
486+
470487
```go
471488
func searchWithRerank(indexConn *pinecone.IndexConnection, namespace string, queryText string, topK int) (*pinecone.SearchRecordsResponse, error) {
472-
// Standard search pattern - always rerank for production
489+
// Best practice: Use reranking for production quality results. This pattern is shown in quickstarts.
473490
ctx := context.Background()
474491
results, err := indexConn.WithNamespace(namespace).SearchRecords(ctx, &pinecone.SearchRecordsRequest{
475492
Query: &pinecone.SearchRecordsRequestQuery{

.agents/PINECONE-java.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
55
This guide provides Java-specific patterns, examples, and best practices for the Pinecone SDK.
66

7+
## 🚨 MANDATORY RULES - Read First
8+
9+
**⚠️ CRITICAL: These rules MUST be followed. Violations will cause runtime errors or data issues.**
10+
11+
1. **MUST use namespaces** - Every upsert, search, fetch, delete operation MUST specify a namespace parameter
12+
2. **MUST wait 10+ seconds** - After upserting records, MUST wait 10+ seconds before searching
13+
3. **MUST match field_map** - Record field names MUST match the right side of `--field_map` used when creating index
14+
4. **MUST respect batch limits** - Text records: MAX 96 per batch, Vector records: MAX 1000 per batch
15+
5. **MUST use flat metadata** - No nested objects allowed, only flat key-value pairs
16+
6. **MUST handle exceptions** - All operations can throw exceptions, MUST use try-catch
17+
7. **MUST verify before installing** - Check if SDK/CLI already installed before prompting installation
18+
19+
**Before proceeding with any operation, verify these rules are followed. See detailed sections below for implementation.**
20+
721
## Installation & Setup
822

923
> **⚠️ IMPORTANT**: See [PINECONE.md](./PINECONE.md#-mandatory-always-use-latest-version) for the mandatory requirement to always use the latest version when creating projects.
@@ -363,14 +377,16 @@ List<String> docsOnly = listAllIds("user_123", "doc_");
363377

364378
### Semantic Search with Reranking (Best Practice)
365379

380+
**Note**: Reranking is a best practice for production quality results. Quickstarts include reranking to demonstrate usage.
381+
366382
```java
367383
import io.pinecone.clients.Index;
368384
import org.openapitools.db_data.client.model.SearchRecordsRequestRerank;
369385
import org.openapitools.db_data.client.model.SearchRecordsResponse;
370386
import java.util.*;
371387

372388
public SearchRecordsResponse searchWithRerank(String namespace, String queryText, int topK) {
373-
// Standard search pattern - always rerank for production
389+
// Best practice: Use reranking for production quality results. This pattern is shown in quickstarts.
374390

375391
// Configure reranking
376392
SearchRecordsRequestRerank rerank = new SearchRecordsRequestRerank()
@@ -985,7 +1001,7 @@ SearchRecordsResponse basicResults = index.searchRecordsByText(
9851001
queryText, namespace, Arrays.asList("content"), 5, null, null
9861002
);
9871003

988-
// ✅ BETTER - always rerank in production
1004+
// ✅ BETTER - use reranking for best results (best practice)
9891005
SearchRecordsRequestRerank rerank = new SearchRecordsRequestRerank()
9901006
.model("bge-reranker-v2-m3")
9911007
.topN(5)

.agents/PINECONE-python.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
55
This guide provides Python-specific patterns, examples, and best practices for the Pinecone SDK.
66

7+
## 🚨 MANDATORY RULES - Read First
8+
9+
**⚠️ CRITICAL: These rules MUST be followed. Violations will cause runtime errors or data issues.**
10+
11+
1. **MUST use namespaces** - Every upsert, search, fetch, delete operation MUST specify a namespace
12+
2. **MUST wait 10+ seconds** - After upserting records, MUST wait 10+ seconds before searching
13+
3. **MUST match field_map** - Record field names MUST match the right side of `--field_map` used when creating index
14+
4. **MUST respect batch limits** - Text records: MAX 96 per batch, Vector records: MAX 1000 per batch
15+
5. **MUST use flat metadata** - No nested objects allowed, only flat key-value pairs
16+
6. **MUST use `pinecone` package** - NOT `pinecone-client` (deprecated, causes errors)
17+
7. **MUST verify before installing** - Check if SDK/CLI already installed before prompting installation
18+
19+
**Before proceeding with any operation, verify these rules are followed. See detailed sections below for implementation.**
20+
721
## Installation & Setup
822

923
> **⚠️ IMPORTANT**: See [PINECONE.md](./PINECONE.md#-mandatory-always-use-latest-version) for the mandatory requirement to always use the latest version when creating projects.
@@ -269,6 +283,13 @@ for hit in reranked_results.result.hits:
269283

270284
### Upserting Records
271285

286+
**⚠️ Before upserting, verify:**
287+
288+
1. Namespace is specified (MANDATORY)
289+
2. Field names match `--field_map` used when creating index (MANDATORY)
290+
3. Batch size ≤ 96 records for text, ≤ 1000 for vectors (MANDATORY)
291+
4. Metadata is flat (no nested objects) (MANDATORY)
292+
272293
```python
273294
# Indexes with integrated embeddings
274295
records = [
@@ -370,9 +391,17 @@ docs_only = list_all_ids(index, "user_123", prefix="doc_")
370391

371392
### Semantic Search with Reranking (Best Practice)
372393

394+
**⚠️ Before searching, verify:**
395+
396+
1. Namespace is specified (MANDATORY)
397+
2. Wait 10+ seconds after upserting before searching (MANDATORY)
398+
3. Field name in query matches `--field_map` (MANDATORY)
399+
400+
**Note**: Reranking is a best practice for production quality results. Quickstarts include reranking to demonstrate usage.
401+
373402
```python
374403
def search_with_rerank(index, namespace, query_text, top_k=5):
375-
"""Standard search pattern - always rerank for production"""
404+
"""Best practice: Use reranking for production quality results. This pattern is shown in quickstarts."""
376405
results = index.search(
377406
namespace=namespace,
378407
query={

.agents/PINECONE-quickstart.md

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,66 @@ The following sample data should be used for the Quick Test across all languages
226226

227227
```json
228228
[
229-
{ "_id": "rec1", "content": "The Eiffel Tower was completed in 1889 and stands in Paris, France.", "category": "history" },
230-
{ "_id": "rec2", "content": "Photosynthesis allows plants to convert sunlight into energy.", "category": "science" },
231-
{ "_id": "rec5", "content": "Shakespeare wrote many famous plays, including Hamlet and Macbeth.", "category": "literature" },
232-
{ "_id": "rec7", "content": "The Great Wall of China was built to protect against invasions.", "category": "history" },
233-
{ "_id": "rec15", "content": "Leonardo da Vinci painted the Mona Lisa.", "category": "art" },
234-
{ "_id": "rec17", "content": "The Pyramids of Giza are among the Seven Wonders of the Ancient World.", "category": "history" },
235-
{ "_id": "rec21", "content": "The Statue of Liberty was a gift from France to the United States.", "category": "history" },
236-
{ "_id": "rec26", "content": "Rome was once the center of a vast empire.", "category": "history" },
237-
{ "_id": "rec33", "content": "The violin is a string instrument commonly used in orchestras.", "category": "music" },
238-
{ "_id": "rec38", "content": "The Taj Mahal is a mausoleum built by Emperor Shah Jahan.", "category": "history" },
239-
{ "_id": "rec48", "content": "Vincent van Gogh painted Starry Night.", "category": "art" },
240-
{ "_id": "rec50", "content": "Renewable energy sources include wind, solar, and hydroelectric power.", "category": "energy" }
229+
{
230+
"_id": "rec1",
231+
"content": "The Eiffel Tower was completed in 1889 and stands in Paris, France.",
232+
"category": "history"
233+
},
234+
{
235+
"_id": "rec2",
236+
"content": "Photosynthesis allows plants to convert sunlight into energy.",
237+
"category": "science"
238+
},
239+
{
240+
"_id": "rec5",
241+
"content": "Shakespeare wrote many famous plays, including Hamlet and Macbeth.",
242+
"category": "literature"
243+
},
244+
{
245+
"_id": "rec7",
246+
"content": "The Great Wall of China was built to protect against invasions.",
247+
"category": "history"
248+
},
249+
{
250+
"_id": "rec15",
251+
"content": "Leonardo da Vinci painted the Mona Lisa.",
252+
"category": "art"
253+
},
254+
{
255+
"_id": "rec17",
256+
"content": "The Pyramids of Giza are among the Seven Wonders of the Ancient World.",
257+
"category": "history"
258+
},
259+
{
260+
"_id": "rec21",
261+
"content": "The Statue of Liberty was a gift from France to the United States.",
262+
"category": "history"
263+
},
264+
{
265+
"_id": "rec26",
266+
"content": "Rome was once the center of a vast empire.",
267+
"category": "history"
268+
},
269+
{
270+
"_id": "rec33",
271+
"content": "The violin is a string instrument commonly used in orchestras.",
272+
"category": "music"
273+
},
274+
{
275+
"_id": "rec38",
276+
"content": "The Taj Mahal is a mausoleum built by Emperor Shah Jahan.",
277+
"category": "history"
278+
},
279+
{
280+
"_id": "rec48",
281+
"content": "Vincent van Gogh painted Starry Night.",
282+
"category": "art"
283+
},
284+
{
285+
"_id": "rec50",
286+
"content": "Renewable energy sources include wind, solar, and hydroelectric power.",
287+
"category": "energy"
288+
}
241289
]
242290
```
243291

@@ -284,7 +332,7 @@ pc index create -n agentic-quickstart-search -m cosine -c aws -r us-east-1 --mod
284332
### Production Patterns
285333

286334
- Always use shielded namespaces
287-
- Always rerank results
335+
- Use reranking for best results (included in quickstart examples)
288336
- Implement exponential backoff retry
289337
- Handle edge cases gracefully
290338

@@ -438,4 +486,4 @@ For comprehensive troubleshooting guidance, see [PINECONE-troubleshooting.md](./
438486

439487
---
440488

441-
**Remember**: Always use namespaces, always rerank, always handle errors with retry logic.
489+
**Remember**: Always use namespaces, use reranking for best results (shown in examples), always handle errors with retry logic.

.agents/PINECONE-troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,4 @@ If you're still experiencing issues:
259259

260260
---
261261

262-
**Remember**: Always use namespaces, always rerank, always handle errors with retry logic, and account for eventual consistency delays.
262+
**Remember**: Always use namespaces, use reranking for best results (shown in quickstarts), always handle errors with retry logic, and account for eventual consistency delays.

.agents/PINECONE-typescript.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
55
This guide provides TypeScript/Node.js-specific patterns, examples, and best practices for the Pinecone SDK.
66

7+
## 🚨 MANDATORY RULES - Read First
8+
9+
**⚠️ CRITICAL: These rules MUST be followed. Violations will cause runtime errors or data issues.**
10+
11+
1. **MUST use namespaces** - Every upsert, search, fetch, delete operation MUST use `.namespace()` method
12+
2. **MUST wait 10+ seconds** - After upserting records, MUST wait 10+ seconds before searching
13+
3. **MUST match field_map** - Record field names MUST match the right side of `--field_map` used when creating index
14+
4. **MUST respect batch limits** - Text records: MAX 96 per batch, Vector records: MAX 1000 per batch
15+
5. **MUST use flat metadata** - No nested objects allowed, only flat key-value pairs
16+
6. **MUST cast `hit.fields`** - TypeScript requires explicit casting: `hit.fields as Record<string, any>`
17+
7. **MUST use `await`** - All SDK operations are async, MUST use `await` keyword
18+
8. **MUST verify before installing** - Check if SDK/CLI already installed before prompting installation
19+
20+
**Before proceeding with any operation, verify these rules are followed. See detailed sections below for implementation.**
21+
722
## Installation & Setup
823

924
> **⚠️ IMPORTANT**: See [PINECONE.md](./PINECONE.md#-mandatory-always-use-latest-version) for the mandatory requirement to always use the latest version when creating projects.
@@ -373,14 +388,16 @@ const docsOnly = await listAllIds(index, "user_123", "doc_");
373388

374389
### Semantic Search with Reranking (Best Practice)
375390

391+
**Note**: Reranking is a best practice for production quality results. Quickstarts include reranking to demonstrate usage.
392+
376393
```typescript
377394
async function searchWithRerank(
378395
index: any,
379396
namespace: string,
380397
queryText: string,
381398
topK: number = 5
382399
) {
383-
// Standard search pattern - always rerank for production
400+
// Best practice: Use reranking for production quality results. This pattern is shown in quickstarts.
384401
const results = await index.namespace(namespace).searchRecords({
385402
query: {
386403
topK: topK * 2, // more candidates for reranking
@@ -908,7 +925,7 @@ const results = await index.namespace("ns").searchRecords({
908925
query: { topK: 5, inputs: { text: "query" } },
909926
});
910927

911-
// ✅ BETTER - always rerank in production
928+
// ✅ BETTER - use reranking for best results (best practice)
912929
const rerankedResults = await index.namespace("ns").searchRecords({
913930
query: {
914931
topK: 10,

.agents/PINECONE.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,21 @@ For detailed CLI installation, authentication, and command reference, see [PINEC
146146

147147
### Upserting records (text with integrated embeddings)
148148

149-
**Always use namespaces for data isolation:**
149+
**⚠️ MANDATORY: Always use namespaces for data isolation. Every upsert operation MUST specify a namespace.**
150+
151+
**Namespace patterns:**
150152

151153
- Multi-user apps: `user_123`
152154
- Session-based: `session_456`
153155
- Content-based: `knowledge_base`, `chat_history`
154156

157+
**Before upserting, verify:**
158+
159+
1. Namespace is specified (MANDATORY)
160+
2. Field names match `--field_map` from index creation (MANDATORY)
161+
3. Batch size limits respected (MANDATORY)
162+
4. Metadata is flat structure (MANDATORY)
163+
155164
### Updating records
156165

157166
Use the same upsert operation with existing IDs. Only changed fields need to be included for partial updates.
@@ -168,11 +177,13 @@ Use paginated listing with optional prefix filters for efficient ID retrieval.
168177

169178
### Semantic search with reranking (best practice)
170179

171-
**Always rerank for production quality:**
180+
**Best practice**: Reranking improves search quality. Quickstarts include reranking to demonstrate usage.
181+
182+
**Recommended pattern:**
172183

173-
- Get 2x candidates initially
184+
- Get 2x candidates initially (e.g., if you want 5 results, request 10)
174185
- Rerank with `bge-reranker-v2-m3` model
175-
- Return final count
186+
- Return final count (reranked results)
176187

177188
### Lexical search (keyword-based)
178189

@@ -211,8 +222,8 @@ Use for exact keyword matching with optional required terms and reranking.
211222

212223
### 4. **Skipping Reranking** (reduces search quality)
213224

214-
- ⚠️ OK but not optimal
215-
-Always rerank in production
225+
- ⚠️ **OK but not optimal** - Search works without reranking
226+
-**Best practice** - Use reranking in production with `bge-reranker-v2-m3` for better results
216227

217228
### 5. **Hardcoded API Keys**
218229

@@ -281,4 +292,4 @@ For advanced features not covered in this quick reference:
281292
- **Error handling**: [https://docs.pinecone.io/guides/production/error-handling](https://docs.pinecone.io/guides/production/error-handling)
282293
- **Database limits**: [https://docs.pinecone.io/reference/api/database-limits](https://docs.pinecone.io/reference/api/database-limits)
283294

284-
**Remember**: Always use namespaces, always rerank, always handle errors with retry logic.
295+
**Remember**: Always use namespaces, use reranking for best results (shown in quickstarts), always handle errors with retry logic.

0 commit comments

Comments
 (0)