fleet-memory/hindsight-clients/go
Nicolò Boschi 9b96becc5c
feat: entity labels — optional, free_values, multi_value, UI polish (#450)
* feat: entity labels

* feat: entity labels — optional, free_values, multi_value, UI polish

Completes the entity labels system:

**Schema & extraction**
- Dynamic Pydantic Labels model per fact: each group becomes a typed
  field (Literal | None, list[Literal], str | None, or list[str])
- `optional: bool` flag per group — non-optional enum fields appear in
  JSON schema required array so structured-output providers enforce them
- `free_values: bool` flag per group — accepts any LLM-generated string
  instead of a predefined enum; example values shown as hints in prompt
- New `is_label_entity()` helper for labels-only mode filtering that
  handles both enum lookup and free_values key-prefix matching
- Sentinel rejection: "None"/"null"/"n/a" strings dropped in post-processing

**BM25 / dense retrieval**
- `text_signals` column on memory_units: entity names + date tokens for
  enriched BM25 indexing without polluting stored fact text
- Dense embedding includes occurred_end when it differs from occurred_start
- Alembic migration z1u2v3w4x5y6 (merge revision fixing two heads)

**UI (bank-config-view)**
- Shadcn Switch replaces custom Toggle for both entity-labels and observations
- Shadcn Checkbox for multi/optional/free_values per group
- Input heights bumped to h-8 throughout the editor
- "Label Groups" → "Entity Labels", "Free-form entities" → "Entities"
- Free-text groups show "Example hints" banner in values section

**Tests (45 unit + 3 LLM integration)**
- build_labels_model: single, multi, mixed, free_values optional/required/multi
- is_label_entity: enum match, free_values prefix match, no false positives
- Post-processing: null/absent/string-None/free_values/sentinels/multi-value
- Schema: labels in required, structured object, no labels when unconfigured
- LLM integration: single-value enum, multi-value enum, free_values retain

**Docs**
- retain.md: new Entity Labels section covering groups, flags, examples
- configuration.md: retain_free_form_entities env var + entity_labels note

* fix(tests): update hierarchical fields count for entity_labels additions

entity_labels and retain_free_form_entities are hierarchical fields,
bumping the expected count from 11 to 13.

* fix(migration): rename text_signals revision to avoid collision with main

Main branch claimed z1u2v3w4x5y6 for observation_scopes. Rename our
text_signals migration to a2b3c4d5e6f7, chaining after z1u2v3w4x5y6.

* refactor(entity-labels): simplify free_values — always str|None, no multi

- free_values groups always produce str | None (multi_value and optional
  flags are ignored for free text groups — always optional, never multi)
- Prompt section for free_values groups shows only key + description,
  no values list (users put examples in the description instead)
- UI: section title "Entities", toggle "Free Form Entities", replace
  per-group checkboxes with a type dropdown (Enum / Free text); only
  show multi checkbox and values list when type is Enum
- Update tests to reflect new behaviour

* refactor(entity-labels): replace free_values/multi_value booleans with type field

- LabelGroup now uses type: "value" | "multi-values" | "text" instead of
  free_values/multi_value boolean pair
- Backward-compat migration converts legacy dicts automatically
- Rename retain_free_form_entities → entities_allow_free_form throughout
- Update UI dropdown to show Single value / Multi-values / Free text
- Remove separate multi checkbox (captured by type selection)
- Update docs examples and configuration.md
- Update all tests to use new field names

* fix(migration): backfill observation_scopes column for DBs with swapped z1u2v3w4x5y6

Local DBs that had z1u2v3w4x5y6 applied when it referred to the old
text_signals migration (before it was renamed to a2b3c4d5e6f7) won't have
observation_scopes in their memory_units table. This migration adds the
column with IF NOT EXISTS so it's a no-op on clean installs.

* feat(entity-labels): add tag field to auto-populate memory unit tags from labels

When a LabelGroup has tag=True, extracted key:value entities for that group
are automatically written to the memory unit's tags array. This lets entity
labels double as tags, enabling immediate filtering via the existing
tags/tags_match API params with no extra infrastructure.

- Add tag: bool = False to LabelGroup
- _inject_label_tags() helper called in both sync and batch extraction paths
- UI: add Tag checkbox per label group row
- Docs: document the new tag field
- Tests: 4 new unit tests covering all tag injection paths

* style: ruff format migration file

* fix(migration): fix multiple alembic heads after rebase — point text_signals after nullable_event_date

* fix(clients): update timestamp field to use Timestamp wrapper type after timestamp=unset feature

* style: ruff format agent.py

* fix(docs): update Go quickstart example to use NullableTimestamp for timestamp field
2026-03-02 13:05:25 +01:00
..
api feat: support timestamp="unset" to retain content without a date (#465) 2026-03-02 12:03:23 +01:00
test fix(go-client): use monorepo-compatible module path (#392) 2026-02-18 10:35:13 +01:00
.gitignore feat: use official go generator for Go client (#377) 2026-02-16 14:04:12 +01:00
api_banks.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_directives.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_documents.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_entities.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_files.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_memory.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_mental_models.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_monitoring.go Release v0.4.14 2026-02-26 18:03:14 +01:00
api_operations.go Release v0.4.14 2026-02-26 18:03:14 +01:00
client.go Release v0.4.14 2026-02-26 18:03:14 +01:00
configuration.go Release v0.4.14 2026-02-26 18:03:14 +01:00
go.mod fix(go-client): use monorepo-compatible module path (#392) 2026-02-18 10:35:13 +01:00
go.sum feat: use official go generator for Go client (#377) 2026-02-16 14:04:12 +01:00
hindsight_client.go fix: clients don't respect timeout setting (#400) 2026-02-19 10:47:47 +01:00
integration_test.go feat: entity labels — optional, free_values, multi_value, UI polish (#450) 2026-03-02 13:05:25 +01:00
model_add_background_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_async_operation_submit_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_background_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_config_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_config_update.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_list_item.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_list_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_profile_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_bank_stats_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_budget.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_cancel_operation_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_child_operation_status.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_chunk_data.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_chunk_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_chunk_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_clear_memory_observations_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_consolidation_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_create_bank_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_create_directive_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_create_mental_model_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_create_mental_model_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_delete_document_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_delete_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_directive_list_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_directive_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_disposition_traits.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_document_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_detail_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_input.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_list_item.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_list_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_observation_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_entity_state_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_features_info.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_file_retain_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_graph_data_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_http_validation_error.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_list_documents_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_list_memory_units_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_list_tags_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_memory_item.go feat: support timestamp="unset" to retain content without a date (#465) 2026-03-02 12:03:23 +01:00
model_mental_model_list_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_mental_model_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_mental_model_trigger.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_observation_scopes.go feat: observation_scopes field to drive observations granularity (#447) 2026-02-28 10:46:21 +01:00
model_operation_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_operation_status_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_operations_list_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_recall_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_recall_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_recall_result.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_based_on.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_directive.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_fact.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_llm_call.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_mental_model.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_tool_call.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_reflect_trace.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_retain_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_retain_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_source_facts_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_tag_item.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_timestamp.go feat: support timestamp="unset" to retain content without a date (#465) 2026-03-02 12:03:23 +01:00
model_token_usage.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_tool_calls_include_options.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_update_directive_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_update_disposition_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_update_mental_model_request.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_validation_error.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_validation_error_loc_inner.go Release v0.4.14 2026-02-26 18:03:14 +01:00
model_version_response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
null_test.go feat: use official go generator for Go client (#377) 2026-02-16 14:04:12 +01:00
openapi-generator-cli.jar feat: use official go generator for Go client (#377) 2026-02-16 14:04:12 +01:00
openapi-generator-config.yaml fix(go-client): use monorepo-compatible module path (#392) 2026-02-18 10:35:13 +01:00
README.md fix(go-client): use monorepo-compatible module path (#392) 2026-02-18 10:35:13 +01:00
response.go Release v0.4.14 2026-02-26 18:03:14 +01:00
trace_test.go feat: use official go generator for Go client (#377) 2026-02-16 14:04:12 +01:00
utils.go Release v0.4.14 2026-02-26 18:03:14 +01:00

Go API client for hindsight

HTTP API for Hindsight

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.4.11
  • Package version: 1.0.0
  • Generator version: 7.10.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import hindsight "github.com/vectorize-io/hindsight/hindsight-clients/go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value hindsight.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), hindsight.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value hindsight.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), hindsight.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using hindsight.ContextOperationServerIndices and hindsight.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), hindsight.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), hindsight.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
BanksAPI AddBankBackground Post /v1/default/banks/{bank_id}/background Add/merge memory bank background (deprecated)
BanksAPI ClearObservations Delete /v1/default/banks/{bank_id}/observations Clear all observations
BanksAPI CreateOrUpdateBank Put /v1/default/banks/{bank_id} Create or update memory bank
BanksAPI DeleteBank Delete /v1/default/banks/{bank_id} Delete memory bank
BanksAPI GetAgentStats Get /v1/default/banks/{bank_id}/stats Get statistics for memory bank
BanksAPI GetBankConfig Get /v1/default/banks/{bank_id}/config Get bank configuration
BanksAPI GetBankProfile Get /v1/default/banks/{bank_id}/profile Get memory bank profile
BanksAPI ListBanks Get /v1/default/banks List all memory banks
BanksAPI ResetBankConfig Delete /v1/default/banks/{bank_id}/config Reset bank configuration
BanksAPI TriggerConsolidation Post /v1/default/banks/{bank_id}/consolidate Trigger consolidation
BanksAPI UpdateBank Patch /v1/default/banks/{bank_id} Partial update memory bank
BanksAPI UpdateBankConfig Patch /v1/default/banks/{bank_id}/config Update bank configuration
BanksAPI UpdateBankDisposition Put /v1/default/banks/{bank_id}/profile Update memory bank disposition
DirectivesAPI CreateDirective Post /v1/default/banks/{bank_id}/directives Create directive
DirectivesAPI DeleteDirective Delete /v1/default/banks/{bank_id}/directives/{directive_id} Delete directive
DirectivesAPI GetDirective Get /v1/default/banks/{bank_id}/directives/{directive_id} Get directive
DirectivesAPI ListDirectives Get /v1/default/banks/{bank_id}/directives List directives
DirectivesAPI UpdateDirective Patch /v1/default/banks/{bank_id}/directives/{directive_id} Update directive
DocumentsAPI DeleteDocument Delete /v1/default/banks/{bank_id}/documents/{document_id} Delete a document
DocumentsAPI GetChunk Get /v1/default/chunks/{chunk_id} Get chunk details
DocumentsAPI GetDocument Get /v1/default/banks/{bank_id}/documents/{document_id} Get document details
DocumentsAPI ListDocuments Get /v1/default/banks/{bank_id}/documents List documents
EntitiesAPI GetEntity Get /v1/default/banks/{bank_id}/entities/{entity_id} Get entity details
EntitiesAPI ListEntities Get /v1/default/banks/{bank_id}/entities List entities
EntitiesAPI RegenerateEntityObservations Post /v1/default/banks/{bank_id}/entities/{entity_id}/regenerate Regenerate entity observations (deprecated)
MemoryAPI ClearBankMemories Delete /v1/default/banks/{bank_id}/memories Clear memory bank memories
MemoryAPI GetGraph Get /v1/default/banks/{bank_id}/graph Get memory graph data
MemoryAPI GetMemory Get /v1/default/banks/{bank_id}/memories/{memory_id} Get memory unit
MemoryAPI ListMemories Get /v1/default/banks/{bank_id}/memories/list List memory units
MemoryAPI ListTags Get /v1/default/banks/{bank_id}/tags List tags
MemoryAPI RecallMemories Post /v1/default/banks/{bank_id}/memories/recall Recall memory
MemoryAPI Reflect Post /v1/default/banks/{bank_id}/reflect Reflect and generate answer
MemoryAPI RetainMemories Post /v1/default/banks/{bank_id}/memories Retain memories
MentalModelsAPI CreateMentalModel Post /v1/default/banks/{bank_id}/mental-models Create mental model
MentalModelsAPI DeleteMentalModel Delete /v1/default/banks/{bank_id}/mental-models/{mental_model_id} Delete mental model
MentalModelsAPI GetMentalModel Get /v1/default/banks/{bank_id}/mental-models/{mental_model_id} Get mental model
MentalModelsAPI ListMentalModels Get /v1/default/banks/{bank_id}/mental-models List mental models
MentalModelsAPI RefreshMentalModel Post /v1/default/banks/{bank_id}/mental-models/{mental_model_id}/refresh Refresh mental model
MentalModelsAPI UpdateMentalModel Patch /v1/default/banks/{bank_id}/mental-models/{mental_model_id} Update mental model
MonitoringAPI GetVersion Get /version Get API version and feature flags
MonitoringAPI HealthEndpointHealthGet Get /health Health check endpoint
MonitoringAPI MetricsEndpointMetricsGet Get /metrics Prometheus metrics endpoint
OperationsAPI CancelOperation Delete /v1/default/banks/{bank_id}/operations/{operation_id} Cancel a pending async operation
OperationsAPI GetOperationStatus Get /v1/default/banks/{bank_id}/operations/{operation_id} Get operation status
OperationsAPI ListOperations Get /v1/default/banks/{bank_id}/operations List async operations

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author