* feat: independent versioning for integrations
- Add per-integration changelog pages at /changelog/integrations/<name>
- Move main changelog to changelog/index.md (URL unchanged)
- Add --integration flag to generate-changelog for LLM-based per-integration changelog generation
- Add scripts/release-integration.sh <name> <version> for cutting integration releases
- Add .github/workflows/release-integration.yml to publish on integrations/** tags
- Remove integrations from main release.sh and release.yml cycle
* fix: add agno and hermes integration docs to version-0.4 for production build
* chore: apply ruff formatting to generate_changelog.py
* feat: add 4-tab code parity across all documentation examples
Every code snippet Tabs block now has Python, Node.js, CLI, and Go variants.
Raw HTTP/curl tabs replaced with proper SDK calls.
New example files:
- Go: retain.go, recall.go, reflect.go, memory-banks.go, directives.go,
mental-models.go, documents.go, main-methods.go
- Shell: memory-banks.sh, directives.sh, mental-models.sh
- Node.js: mental-models.mjs
Extended example files with missing sections:
- recall.mjs/sh: world/experience/observation types, token-budget, all tag modes
- reflect.sh: reflect-with-params, reflect-disposition, reflect-sources, reflect-with-tags
- reflect.mjs: reflect-with-tags, fixed reflect-sources API usage
- retain.mjs/sh: retain-conversation, retain-batch, retain-files-batch
SDK/CLI additions:
- TypeScript: getMentalModelHistory method
- CLI recall: --tags, --tags-match flags
- CLI reflect: --tags, --tags-match, --include-facts flags
- CLI directive update: --is-active flag
- CLI bank set-config: --retain-mission, --retain-extraction-mode,
--observations-mission, --reflect-mission, --disposition-* flags
Build validation:
- scripts/check-code-parity.mjs validates 4-tab parity across all MDX files
- Integrated into npm run build — fails if any Tabs block is missing a variant
* fix: fix doc examples for Go, Node.js, CLI + add mental model with-id examples
- Fix Go Budget constants: BUDGET_HIGH/LOW/MID → HIGH/LOW/MID
- Fix Go documents.go: ListDocuments returns []map[string]interface{}, use map access
- Fix Go retain.go: use correct relative path for sample.pdf
- Fix Node.js createMentalModel: use positional args (name, sourceQuery) not object
- Add CLI 'history' subcommand for mental models (api.rs, main.rs, mental_model.rs)
- Rebuild TypeScript/Python clients to support id param in createMentalModel
- Add create-mental-model-with-id examples across all 4 languages and docs
* fix: move id param to end of create_mental_model signature for backwards compat
155 lines
5.5 KiB
Go
155 lines
5.5 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
hindsight "github.com/vectorize-io/hindsight/hindsight-clients/go"
|
|
)
|
|
|
|
func main() {
|
|
apiURL := os.Getenv("HINDSIGHT_API_URL")
|
|
if apiURL == "" {
|
|
apiURL = "http://localhost:8888"
|
|
}
|
|
|
|
cfg := hindsight.NewConfiguration()
|
|
cfg.Servers = hindsight.ServerConfigurations{{URL: apiURL}}
|
|
client := hindsight.NewAPIClient(cfg)
|
|
ctx := context.Background()
|
|
|
|
// =============================================================================
|
|
// Setup (not shown in docs)
|
|
// =============================================================================
|
|
for _, content := range []string{
|
|
"Alice works at Google as a software engineer",
|
|
"Alice has been working there for 5 years",
|
|
"Alice recently got promoted to senior engineer",
|
|
} {
|
|
client.MemoryAPI.RetainMemories(ctx, "my-bank").
|
|
RetainRequest(hindsight.RetainRequest{
|
|
Items: []hindsight.MemoryItem{{Content: content}},
|
|
}).Execute()
|
|
}
|
|
|
|
// =============================================================================
|
|
// Doc Examples
|
|
// =============================================================================
|
|
|
|
// [docs:reflect-basic]
|
|
client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "What should I know about Alice?",
|
|
}).Execute()
|
|
// [/docs:reflect-basic]
|
|
|
|
// [docs:reflect-with-params]
|
|
budgetMid := hindsight.MID
|
|
client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "We're considering a hybrid work policy. What do you think about remote work?",
|
|
Budget: &budgetMid,
|
|
}).Execute()
|
|
// [/docs:reflect-with-params]
|
|
|
|
// [docs:reflect-with-context]
|
|
// Context is passed to the LLM to help it understand the situation
|
|
ctxText := "We're in a budget review meeting discussing Q4 spending"
|
|
client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "What do you think about the proposal?",
|
|
Context: *hindsight.NewNullableString(&ctxText),
|
|
}).Execute()
|
|
// [/docs:reflect-with-context]
|
|
|
|
// [docs:reflect-disposition]
|
|
// Create a bank with specific disposition
|
|
skepticism := int32(5)
|
|
literalism := int32(4)
|
|
empathy := int32(2)
|
|
mission := "I am a risk-aware financial advisor"
|
|
client.BanksAPI.CreateOrUpdateBank(ctx, "cautious-advisor").
|
|
CreateBankRequest(hindsight.CreateBankRequest{
|
|
Name: *hindsight.NewNullableString(hindsight.PtrString("Cautious Advisor")),
|
|
ReflectMission: *hindsight.NewNullableString(&mission),
|
|
DispositionSkepticism: *hindsight.NewNullableInt32(&skepticism),
|
|
DispositionLiteralism: *hindsight.NewNullableInt32(&literalism),
|
|
DispositionEmpathy: *hindsight.NewNullableInt32(&empathy),
|
|
}).Execute()
|
|
|
|
// Reflect responses will reflect this disposition
|
|
client.MemoryAPI.Reflect(ctx, "cautious-advisor").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "Should I invest in crypto?",
|
|
}).Execute()
|
|
// Response will likely emphasize risks and caution
|
|
// [/docs:reflect-disposition]
|
|
|
|
// [docs:reflect-sources]
|
|
// include.facts enables the based_on field in the response
|
|
sourcesResponse, _, _ := client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "Tell me about Alice",
|
|
Include: &hindsight.ReflectIncludeOptions{
|
|
Facts: map[string]interface{}{}, // empty map enables fact inclusion
|
|
},
|
|
}).Execute()
|
|
|
|
fmt.Println("Response:", sourcesResponse.GetText())
|
|
fmt.Println("\nBased on:")
|
|
if basedOn := sourcesResponse.GetBasedOn(); basedOn.Memories != nil {
|
|
for _, fact := range basedOn.GetMemories() {
|
|
fmt.Printf(" - [%s] %s\n", fact.GetType(), fact.GetText())
|
|
}
|
|
}
|
|
// [/docs:reflect-sources]
|
|
|
|
// [docs:reflect-with-tags]
|
|
// Filter reflection to only consider memories for a specific user
|
|
tagsMatch := "any_strict"
|
|
client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "What does this user think about our product?",
|
|
Tags: []string{"user:alice"},
|
|
TagsMatch: &tagsMatch,
|
|
}).Execute()
|
|
// [/docs:reflect-with-tags]
|
|
|
|
// [docs:reflect-structured-output]
|
|
// Define JSON schema for structured output
|
|
responseSchema := map[string]interface{}{
|
|
"type": "object",
|
|
"properties": map[string]interface{}{
|
|
"recommendation": map[string]interface{}{"type": "string"},
|
|
"confidence": map[string]interface{}{"type": "string", "enum": []string{"low", "medium", "high"}},
|
|
"key_factors": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}},
|
|
"risks": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}},
|
|
},
|
|
"required": []string{"recommendation", "confidence", "key_factors"},
|
|
}
|
|
|
|
structuredResponse, _, _ := client.MemoryAPI.Reflect(ctx, "my-bank").
|
|
ReflectRequest(hindsight.ReflectRequest{
|
|
Query: "Should we hire Alice for the ML team lead position?",
|
|
ResponseSchema: responseSchema,
|
|
}).Execute()
|
|
|
|
// Access structured output
|
|
if out := structuredResponse.GetStructuredOutput(); out != nil {
|
|
fmt.Println("Recommendation:", out["recommendation"])
|
|
fmt.Println("Key factors:", out["key_factors"])
|
|
}
|
|
// [/docs:reflect-structured-output]
|
|
|
|
// =============================================================================
|
|
// Cleanup (not shown in docs)
|
|
// =============================================================================
|
|
for _, bankID := range []string{"my-bank", "cautious-advisor"} {
|
|
req, _ := http.NewRequest("DELETE", fmt.Sprintf("%s/v1/default/banks/%s", apiURL, bankID), nil)
|
|
http.DefaultClient.Do(req)
|
|
}
|
|
|
|
fmt.Println("reflect.go: All examples passed")
|
|
}
|