Compare commits

..
2 Commits
229 changed files with 771 additions and 42988 deletions
-6
View File
@@ -41,12 +41,6 @@ HINDSIGHT_API_LOG_LEVEL=info
# HINDSIGHT_API_DATABASE_URL=postgresql://user:pass@host:5432/db
# HINDSIGHT_API_DATABASE_SCHEMA=public # PostgreSQL schema name (default: public)
# Vector Extension (Optional - uses pgvector by default)
# Options: "pgvector" (default), "vchord", "pgvectorscale" (DiskANN)
# HINDSIGHT_API_VECTOR_EXTENSION=pgvector
# For Azure PostgreSQL with DiskANN:
# HINDSIGHT_API_VECTOR_EXTENSION=pgvectorscale # Auto-detects pg_diskann on Azure
# Embeddings Configuration (Optional - uses local by default)
# Provider: "local" (default) or "tei" (HuggingFace Text Embeddings Inference)
# HINDSIGHT_API_EMBEDDINGS_PROVIDER=local
+21 -76
View File
@@ -648,80 +648,6 @@ jobs:
echo "=== API Server Logs ==="
cat /tmp/api-server.log || echo "No API server log found"
test-go-client:
runs-on: ubuntu-latest
env:
HINDSIGHT_API_LLM_PROVIDER: groq
HINDSIGHT_API_LLM_API_KEY: ${{ secrets.GROQ_API_KEY }}
HINDSIGHT_API_LLM_MODEL: openai/gpt-oss-20b
HINDSIGHT_API_URL: http://localhost:8888
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Prefer CPU-only PyTorch in CI (but keep PyPI for everything else)
UV_INDEX: pytorch=https://download.pytorch.org/whl/cpu
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
prune-cache: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: hindsight-clients/go/go.sum
- name: Build API
working-directory: ./hindsight-api
run: uv build
- name: Install API dependencies
working-directory: ./hindsight-api
run: uv sync --frozen --no-install-project --index-strategy unsafe-best-match
- name: Create .env file
run: |
cat > .env << EOF
HINDSIGHT_API_LLM_PROVIDER=${{ env.HINDSIGHT_API_LLM_PROVIDER }}
HINDSIGHT_API_LLM_API_KEY=${{ env.HINDSIGHT_API_LLM_API_KEY }}
HINDSIGHT_API_LLM_MODEL=${{ env.HINDSIGHT_API_LLM_MODEL }}
EOF
- name: Start API server
run: |
./scripts/dev/start-api.sh > /tmp/api-server.log 2>&1 &
echo "Waiting for API server to be ready..."
for i in {1..60}; do
if curl -sf http://localhost:8888/health > /dev/null 2>&1; then
echo "API server is ready after ${i}s"
break
fi
if [ $i -eq 60 ]; then
echo "API server failed to start after 60s"
cat /tmp/api-server.log
exit 1
fi
sleep 1
done
- name: Run Go client tests
working-directory: ./hindsight-clients/go
run: go test -v -tags=integration
- name: Show API server logs
if: always()
run: |
echo "=== API Server Logs ==="
cat /tmp/api-server.log || echo "No API server log found"
test-integration:
runs-on: ubuntu-latest
env:
@@ -1015,11 +941,30 @@ jobs:
sleep 1
done
- name: Run Python doc examples
working-directory: ./hindsight-clients/python
run: |
for f in ../../hindsight-docs/examples/api/*.py; do
echo "Running $f..."
uv run python "$f"
done
- name: Run Node.js doc examples
run: |
for f in hindsight-docs/examples/api/*.mjs; do
echo "Running $f..."
node "$f"
done
- name: Configure CLI
run: hindsight configure --api-url http://localhost:8888
- name: Run all doc examples
run: ./scripts/test-doc-examples.sh
- name: Run CLI doc examples
run: |
for f in hindsight-docs/examples/api/*.sh; do
echo "Running $f..."
bash "$f"
done
- name: Show API server logs
if: always()
-1
View File
@@ -46,7 +46,6 @@ hindsight-docs/static/llms-full.txt
hindsight-dev/benchmarks/locomo/results/
hindsight-dev/benchmarks/longmemeval/results/
hindsight-dev/benchmarks/consolidation/results/
hindsight-dev/benchmarks/perf/results/
benchmarks/results/
hindsight-cli/target
hindsight-clients/rust/target
-7
View File
@@ -57,15 +57,8 @@ cd hindsight-control-plane && npm run dev
### Benchmarks
```bash
# Accuracy benchmarks
./scripts/benchmarks/run-longmemeval.sh
./scripts/benchmarks/run-locomo.sh
# Performance benchmarks
./scripts/benchmarks/run-consolidation.sh
./scripts/benchmarks/run-retain-perf.sh --document <path> # Requires API server running
# Results viewer
./scripts/benchmarks/start-visualizer.sh # View results at localhost:8001
```
@@ -1,83 +0,0 @@
# Docker Compose file for Hindsight with S3 file storage (SeaweedFS)
#
# SeaweedFS (Apache 2.0) provides an S3-compatible object storage backend
# for storing uploaded files instead of PostgreSQL BYTEA storage.
#
# Make sure to set the required environment variables before running:
# - HINDSIGHT_DB_PASSWORD: Password for the PostgreSQL user
# - Configure LLM provider variables as needed (see below in the hindsight service)
#
# Usage:
# docker compose up -d
#
# Optional environment variables with defaults:
# - HINDSIGHT_VERSION: Hindsight application version (default: latest)
# - HINDSIGHT_DB_USER: PostgreSQL user (default: hindsight_user)
# - HINDSIGHT_DB_NAME: PostgreSQL database name (default: hindsight_db)
# - HINDSIGHT_DB_VERSION: PostgreSQL version (default: 18)
# - SEAWEEDFS_S3_ACCESS_KEY: S3 access key (default: hindsight_s3_key)
# - SEAWEEDFS_S3_SECRET_KEY: S3 secret key (default: hindsight_s3_secret)
services:
db:
image: pgvector/pgvector:pg${HINDSIGHT_DB_VERSION:-18}
container_name: hindsight-db
restart: always
environment:
POSTGRES_USER: ${HINDSIGHT_DB_USER:-hindsight_user}
POSTGRES_PASSWORD: ${HINDSIGHT_DB_PASSWORD:?Please set the HINDSIGHT_DB_PASSWORD env variable}
POSTGRES_DB: ${HINDSIGHT_DB_NAME:-hindsight_db}
volumes:
- pg_data:/var/lib/postgresql/${HINDSIGHT_DB_VERSION:-18}/docker
networks:
- hindsight-net
seaweedfs:
image: chrislusf/seaweedfs:latest
container_name: hindsight-seaweedfs
restart: always
# Single-node mode: master + volume + filer + S3 gateway all in one process
command: >
server
-s3
-s3.port=8333
-s3.config=/etc/seaweedfs/s3.json
-ip.bind=0.0.0.0
volumes:
- seaweedfs_data:/data
- ./s3.json:/etc/seaweedfs/s3.json:ro
# Expose S3 API port (uncomment to access from host)
# ports:
# - "8333:8333"
networks:
- hindsight-net
hindsight:
image: ghcr.io/vectorize-io/hindsight:${HINDSIGHT_VERSION:-latest}
container_name: hindsight-app
ports:
- "8888:8888"
- "9999:9999"
environment:
- HINDSIGHT_API_LLM_API_KEY=${OPENAI_API_KEY?Please set the OPENAI_API_KEY env variable}
- HINDSIGHT_API_DATABASE_URL=postgresql://${HINDSIGHT_DB_USER:-hindsight_user}:${HINDSIGHT_DB_PASSWORD:?Please set the HINDSIGHT_DB_PASSWORD env variable}@db:5432/${HINDSIGHT_DB_NAME:-hindsight_db}
# S3 file storage configuration (SeaweedFS)
- HINDSIGHT_API_FILE_STORAGE_TYPE=s3
- HINDSIGHT_API_FILE_STORAGE_S3_BUCKET=hindsight
- HINDSIGHT_API_FILE_STORAGE_S3_ENDPOINT=http://seaweedfs:8333
- HINDSIGHT_API_FILE_STORAGE_S3_REGION=us-east-1
- HINDSIGHT_API_FILE_STORAGE_S3_ACCESS_KEY_ID=${SEAWEEDFS_S3_ACCESS_KEY:-hindsight_s3_key}
- HINDSIGHT_API_FILE_STORAGE_S3_SECRET_ACCESS_KEY=${SEAWEEDFS_S3_SECRET_KEY:-hindsight_s3_secret}
depends_on:
- db
- seaweedfs
networks:
- hindsight-net
networks:
hindsight-net:
driver: bridge
volumes:
pg_data:
seaweedfs_data:
@@ -1,19 +0,0 @@
{
"identities": [
{
"name": "hindsight",
"credentials": [
{
"accessKey": "hindsight_s3_key",
"secretKey": "hindsight_s3_secret"
}
],
"actions": [
"Admin",
"Read",
"Write",
"List"
]
}
]
}
@@ -32,26 +32,18 @@ def _detect_vector_extension() -> str:
# Validate configured extension is installed
if vector_extension == "pgvectorscale":
# pgvectorscale/DiskANN requires pgvector
# pgvectorscale requires pgvector
pgvector_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vector'")).scalar()
if not pgvector_check:
raise RuntimeError(
"DiskANN requires pgvector. Install with: CREATE EXTENSION vector; then vectorscale or pg_diskann CASCADE;"
"pgvectorscale requires pgvector. Install with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
# Check for either vectorscale (open source) or pg_diskann (Azure)
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
pg_diskann_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'pg_diskann'")).scalar()
if vectorscale_check:
return "pgvectorscale"
elif pg_diskann_check:
return "pg_diskann"
else:
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. Install either:\n"
" - pgvectorscale: CREATE EXTENSION vectorscale CASCADE;\n"
" - pg_diskann (Azure): CREATE EXTENSION pg_diskann CASCADE;"
"Configured vector extension 'pgvectorscale' not found. Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
return "pgvectorscale"
elif vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
@@ -319,13 +311,6 @@ def upgrade() -> None:
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "pg_diskann":
# Use DiskANN index for pg_diskann (Azure)
op.execute("""
CREATE INDEX idx_memory_units_embedding ON memory_units
USING diskann (embedding vector_cosine_ops)
WITH (max_neighbors = 50)
""")
elif vector_ext == "vchord":
# Use vchordrq index for vchord (supports high-dimensional embeddings)
op.execute("""
@@ -1,70 +0,0 @@
"""Add file_storage table for BYTEA-based file storage
Revision ID: a1b2c3d4e5f6
Revises: y0t1u2v3w4x5
Create Date: 2026-02-16
Creates a dedicated table for storing uploaded files using BYTEA.
This provides zero-config file storage that "just works" for development
and small deployments. For production/scale, use S3-compatible storage.
Files are stored in a separate table to avoid bloating the documents table.
"""
from collections.abc import Sequence
from alembic import context, op
revision: str = "a1b2c3d4e5f6"
down_revision: str | Sequence[str] | None = "y0t1u2v3w4x5"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def _get_schema_prefix() -> str:
"""Get schema prefix for table names (required for multi-tenant support)."""
schema = context.config.get_main_option("target_schema")
return f'"{schema}".' if schema else ""
def upgrade() -> None:
"""Create file_storage table for BYTEA storage."""
schema = _get_schema_prefix()
# Create file_storage table (minimal: just key + data)
op.execute(
f"""
CREATE TABLE {schema}file_storage (
storage_key TEXT PRIMARY KEY,
data BYTEA NOT NULL
)
"""
)
# Add file tracking columns to documents table
op.execute(
f"""
ALTER TABLE {schema}documents
ADD COLUMN IF NOT EXISTS file_storage_key TEXT,
ADD COLUMN IF NOT EXISTS file_original_name TEXT,
ADD COLUMN IF NOT EXISTS file_content_type TEXT
"""
)
def downgrade() -> None:
"""Remove file_storage table and related columns."""
schema = _get_schema_prefix()
# Drop columns from documents table
op.execute(
f"""
ALTER TABLE {schema}documents
DROP COLUMN IF EXISTS file_storage_key,
DROP COLUMN IF EXISTS file_original_name,
DROP COLUMN IF EXISTS file_content_type
"""
)
# Drop file_storage table
op.execute(f"DROP TABLE IF EXISTS {schema}file_storage")
@@ -39,26 +39,18 @@ def _detect_vector_extension() -> str:
# Validate configured extension is installed
if vector_extension == "pgvectorscale":
# pgvectorscale/DiskANN requires pgvector
# pgvectorscale requires pgvector
pgvector_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vector'")).scalar()
if not pgvector_check:
raise RuntimeError(
"DiskANN requires pgvector. Install with: CREATE EXTENSION vector; then vectorscale or pg_diskann CASCADE;"
"pgvectorscale requires pgvector. Install with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
# Check for either vectorscale (open source) or pg_diskann (Azure)
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
pg_diskann_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'pg_diskann'")).scalar()
if vectorscale_check:
return "pgvectorscale"
elif pg_diskann_check:
return "pg_diskann"
else:
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. Install either:\n"
" - pgvectorscale: CREATE EXTENSION vectorscale CASCADE;\n"
" - pg_diskann (Azure): CREATE EXTENSION pg_diskann CASCADE;"
"Configured vector extension 'pgvectorscale' not found. Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
return "pgvectorscale"
elif vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
@@ -163,12 +155,6 @@ def upgrade() -> None:
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "pg_diskann":
op.execute(f"""
CREATE INDEX idx_learnings_embedding ON {schema}learnings
USING diskann (embedding vector_cosine_ops)
WITH (max_neighbors = 50)
""")
elif vector_ext == "vchord":
op.execute(f"""
CREATE INDEX idx_learnings_embedding ON {schema}learnings
@@ -242,12 +228,6 @@ def upgrade() -> None:
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "pg_diskann":
op.execute(f"""
CREATE INDEX idx_pinned_reflections_embedding ON {schema}pinned_reflections
USING diskann (embedding vector_cosine_ops)
WITH (max_neighbors = 50)
""")
elif vector_ext == "vchord":
op.execute(f"""
CREATE INDEX idx_pinned_reflections_embedding ON {schema}pinned_reflections
@@ -1,49 +0,0 @@
"""Add GIN index on async_operations.result_metadata for parent_operation_id queries
Revision ID: y0t1u2v3w4x5
Revises: x9s0t1u2v3w4
Create Date: 2026-02-13
This migration adds a GIN index on the result_metadata JSONB column in the
async_operations table to support efficient queries for child operations by
parent_operation_id.
The index enables fast lookups when querying for child operations:
SELECT * FROM async_operations
WHERE result_metadata::jsonb @> '{"parent_operation_id": "uuid"}'::jsonb
"""
from collections.abc import Sequence
from alembic import context, op
revision: str = "y0t1u2v3w4x5"
down_revision: str | Sequence[str] | None = "x9s0t1u2v3w4"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def _get_schema_prefix() -> str:
"""Get schema prefix for table names (required for multi-tenant support)."""
schema = context.config.get_main_option("target_schema")
return f'"{schema}".' if schema else ""
def upgrade() -> None:
"""Add GIN index on result_metadata for efficient parent_operation_id queries."""
schema = _get_schema_prefix()
# Add GIN index for JSONB containment queries (@> operator)
op.execute(f"""
CREATE INDEX idx_async_operations_result_metadata
ON {schema}async_operations
USING gin(result_metadata)
""")
def downgrade() -> None:
"""Remove GIN index on result_metadata."""
schema = _get_schema_prefix()
# Drop index
op.execute(f"DROP INDEX IF EXISTS {schema}idx_async_operations_result_metadata")
+2 -228
View File
@@ -13,7 +13,7 @@ from contextlib import asynccontextmanager
from datetime import datetime
from typing import Any, Literal
from fastapi import Depends, FastAPI, File, Form, Header, HTTPException, Query, UploadFile
from fastapi import Depends, FastAPI, Header, HTTPException, Query
from hindsight_api.extensions import AuthenticationError
@@ -430,36 +430,6 @@ class RetainRequest(BaseModel):
)
class FileRetainMetadata(BaseModel):
"""Metadata for a single file in file retain request."""
document_id: str | None = Field(default=None, description="Document ID (auto-generated if not provided)")
context: str | None = Field(default=None, description="Context for the file")
metadata: dict[str, Any] | None = Field(default=None, description="Additional metadata")
tags: list[str] | None = Field(default=None, description="Tags for this file")
timestamp: str | None = Field(default=None, description="ISO timestamp")
class FileRetainRequest(BaseModel):
"""Request model for file retain endpoint."""
model_config = ConfigDict(
json_schema_extra={
"example": {
"files_metadata": [
{"document_id": "report_2024", "tags": ["quarterly"]},
{"context": "meeting notes"},
],
}
}
)
files_metadata: list[FileRetainMetadata] | None = Field(
default=None,
description="Metadata for each file (optional, must match number of files if provided)",
)
class RetainResponse(BaseModel):
"""Response model for retain endpoint."""
@@ -484,7 +454,7 @@ class RetainResponse(BaseModel):
)
operation_id: str | None = Field(
default=None,
description="Operation ID for tracking async operations. Use GET /v1/default/banks/{bank_id}/operations to list operations. Only present when async=true.",
description="Operation ID for tracking async operations. Use GET /v1/default/banks/{bank_id}/operations to list operations and find this ID. Only present when async=true.",
)
usage: TokenUsage | None = Field(
default=None,
@@ -492,26 +462,6 @@ class RetainResponse(BaseModel):
)
class FileRetainResponse(BaseModel):
"""Response model for file upload endpoint."""
model_config = ConfigDict(
json_schema_extra={
"example": {
"operation_ids": [
"550e8400-e29b-41d4-a716-446655440000",
"550e8400-e29b-41d4-a716-446655440001",
"550e8400-e29b-41d4-a716-446655440002",
],
}
},
)
operation_ids: list[str] = Field(
description="Operation IDs for tracking file conversion operations. Use GET /v1/default/banks/{bank_id}/operations to list operations."
)
class FactsIncludeOptions(BaseModel):
"""Options for including facts (based_on) in reflect results."""
@@ -1407,16 +1357,6 @@ class CancelOperationResponse(BaseModel):
operation_id: str
class ChildOperationStatus(BaseModel):
"""Status of a child operation (for batch operations)."""
operation_id: str
status: str
sub_batch_index: int | None = None
items_count: int | None = None
error_message: str | None = None
class OperationStatusResponse(BaseModel):
"""Response model for getting a single operation status."""
@@ -1441,13 +1381,6 @@ class OperationStatusResponse(BaseModel):
updated_at: str | None = None
completed_at: str | None = None
error_message: str | None = None
result_metadata: dict[str, Any] | None = Field(
default=None,
description="Internal metadata for debugging. Structure may change without notice. Not for production use.",
)
child_operations: list[ChildOperationStatus] | None = Field(
default=None, description="Child operations for batch operations (if applicable)"
)
class AsyncOperationSubmitResponse(BaseModel):
@@ -1473,7 +1406,6 @@ class FeaturesInfo(BaseModel):
mcp: bool = Field(description="Whether MCP (Model Context Protocol) server is enabled")
worker: bool = Field(description="Whether the background worker is enabled")
bank_config_api: bool = Field(description="Whether per-bank configuration API is enabled")
file_upload_api: bool = Field(description="Whether file upload/conversion API is enabled")
class VersionResponse(BaseModel):
@@ -1488,7 +1420,6 @@ class VersionResponse(BaseModel):
"mcp": True,
"worker": True,
"bank_config_api": False,
"file_upload_api": True,
},
}
}
@@ -1783,7 +1714,6 @@ def _register_routes(app: FastAPI):
mcp=config.mcp_enabled,
worker=config.worker_enabled,
bank_config_api=config.enable_bank_config_api,
file_upload_api=config.enable_file_upload_api,
),
)
@@ -3633,21 +3563,6 @@ def _register_routes(app: FastAPI):
}
)
else:
# Check if batch API is enabled - if so, require async mode
from hindsight_api.config import get_config
config = get_config()
if config.retain_batch_enabled:
raise HTTPException(
status_code=400,
detail=(
"Batch API is enabled (HINDSIGHT_API_RETAIN_BATCH_ENABLED=true) but async=false. "
"Batch operations can take several minutes to hours and will timeout in synchronous mode. "
"Please set async=true in your request to use background processing, or disable batch API "
"by setting HINDSIGHT_API_RETAIN_BATCH_ENABLED=false in your environment."
),
)
# Synchronous processing: wait for completion (record metrics)
with metrics.record_operation("retain", bank_id=bank_id, source="api"):
result, usage = await app.state.memory.retain_batch_async(
@@ -3685,147 +3600,6 @@ def _register_routes(app: FastAPI):
logger.error(f"Error in /v1/default/banks/{bank_id}/memories (retain): {error_detail}")
raise HTTPException(status_code=500, detail=str(e))
@app.post(
"/v1/default/banks/{bank_id}/files/retain",
response_model=FileRetainResponse,
summary="Convert files to memories",
description="Upload files (PDF, DOCX, etc.), convert them to markdown, and retain as memories.\n\n"
"This endpoint handles file upload, conversion, and memory creation in a single operation.\n\n"
"**Features:**\n"
"- Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription)\n"
"- Automatic file-to-markdown conversion using pluggable parsers\n"
"- Files stored in object storage (PostgreSQL by default, S3 for production)\n"
"- Each file becomes a separate document with optional metadata/tags\n"
"- Always processes asynchronously — returns operation IDs immediately\n\n"
"**The system automatically:**\n"
"1. Stores uploaded files in object storage\n"
"2. Converts files to markdown\n"
"3. Creates document records with file metadata\n"
"4. Extracts facts and creates memory units (same as regular retain)\n\n"
"Use the operations endpoint to monitor progress.\n\n"
"**Request format:** multipart/form-data with:\n"
"- `files`: One or more files to upload\n"
"- `request`: JSON string with FileRetainRequest model (files_metadata)\n\n"
"**Note:** File parser is configured server-side via `HINDSIGHT_API_FILE_PARSER` (default: markitdown).",
operation_id="file_retain",
tags=["Files"],
)
async def api_file_retain(
bank_id: str,
files: list[UploadFile] = File(..., description="Files to upload and convert"),
request: str = Form(..., description="JSON string with FileRetainRequest model"),
request_context: RequestContext = Depends(get_request_context),
):
"""Upload and convert files to memories."""
from hindsight_api.config import get_config
config = get_config()
# Check if file upload API is enabled
if not config.enable_file_upload_api:
raise HTTPException(
status_code=404,
detail="File upload API is disabled. Set HINDSIGHT_API_ENABLE_FILE_UPLOAD_API=true to enable.",
)
try:
# Parse request JSON
try:
request_data = FileRetainRequest.model_validate_json(request)
except Exception as e:
raise HTTPException(
status_code=400,
detail=f"Invalid request JSON: {str(e)}",
)
# Validate file count
if len(files) > config.file_conversion_max_batch_size:
raise HTTPException(
status_code=400,
detail=f"Too many files. Maximum {config.file_conversion_max_batch_size} files per request.",
)
# Validate files_metadata count matches files count if provided
if request_data.files_metadata and len(request_data.files_metadata) != len(files):
raise HTTPException(
status_code=400,
detail=f"files_metadata count ({len(request_data.files_metadata)}) must match files count ({len(files)})",
)
# Prepare file items and calculate total batch size
file_items = []
total_batch_size = 0
for i, file in enumerate(files):
# Read file content to check size
file_content = await file.read()
size = len(file_content)
total_batch_size += size
# Create a temporary file-like object from the bytes
import io
file_obj = io.BytesIO(file_content)
# Create a mock UploadFile with the necessary attributes
class FileWrapper:
def __init__(self, content, filename, content_type):
self._content = content
self.filename = filename
self.content_type = content_type
self._buffer = io.BytesIO(content)
async def read(self):
return self._content
wrapped_file = FileWrapper(file_content, file.filename, file.content_type)
# Get per-file metadata
file_meta = request_data.files_metadata[i] if request_data.files_metadata else FileRetainMetadata()
doc_id = file_meta.document_id or f"file_{uuid.uuid4()}"
item = {
"file": wrapped_file,
"document_id": doc_id,
"context": file_meta.context,
"metadata": file_meta.metadata or {},
"tags": file_meta.tags or [],
"timestamp": file_meta.timestamp,
}
file_items.append(item)
# Check total batch size after processing all files
if total_batch_size > config.file_conversion_max_batch_size_bytes:
total_mb = total_batch_size / (1024 * 1024)
raise HTTPException(
status_code=400,
detail=f"Total batch size ({total_mb:.1f}MB) exceeds maximum of {config.file_conversion_max_batch_size_mb}MB",
)
result = await app.state.memory.submit_async_file_retain(
bank_id=bank_id,
file_items=file_items,
parser=config.file_parser,
document_tags=None,
request_context=request_context,
)
return FileRetainResponse.model_validate(
{
"operation_ids": result["operation_ids"],
}
)
except OperationValidationError as e:
raise HTTPException(status_code=e.status_code, detail=e.reason)
except (AuthenticationError, HTTPException):
raise
except Exception as e:
import traceback
error_detail = f"{str(e)}\n\nTraceback:\n{traceback.format_exc()}"
logger.error(f"Error in /v1/default/banks/{bank_id}/files/retain: {error_detail}")
raise HTTPException(status_code=500, detail=str(e))
@app.delete(
"/v1/default/banks/{bank_id}/memories",
response_model=DeleteResponse,
-111
View File
@@ -129,11 +129,6 @@ ENV_LLM_INITIAL_BACKOFF = "HINDSIGHT_API_LLM_INITIAL_BACKOFF"
ENV_LLM_MAX_BACKOFF = "HINDSIGHT_API_LLM_MAX_BACKOFF"
ENV_LLM_TIMEOUT = "HINDSIGHT_API_LLM_TIMEOUT"
ENV_LLM_GROQ_SERVICE_TIER = "HINDSIGHT_API_LLM_GROQ_SERVICE_TIER"
ENV_LLM_OPENAI_SERVICE_TIER = "HINDSIGHT_API_LLM_OPENAI_SERVICE_TIER"
# Defaults for service tiers
DEFAULT_LLM_GROQ_SERVICE_TIER = "auto" # "on_demand", "flex", or "auto"
DEFAULT_LLM_OPENAI_SERVICE_TIER = None # None (default) or "flex" (50% cheaper)
# Per-operation LLM configuration (optional, falls back to global LLM config)
ENV_RETAIN_LLM_PROVIDER = "HINDSIGHT_API_RETAIN_LLM_PROVIDER"
@@ -255,29 +250,6 @@ ENV_RETAIN_CHUNK_SIZE = "HINDSIGHT_API_RETAIN_CHUNK_SIZE"
ENV_RETAIN_EXTRACT_CAUSAL_LINKS = "HINDSIGHT_API_RETAIN_EXTRACT_CAUSAL_LINKS"
ENV_RETAIN_EXTRACTION_MODE = "HINDSIGHT_API_RETAIN_EXTRACTION_MODE"
ENV_RETAIN_CUSTOM_INSTRUCTIONS = "HINDSIGHT_API_RETAIN_CUSTOM_INSTRUCTIONS"
ENV_RETAIN_BATCH_TOKENS = "HINDSIGHT_API_RETAIN_BATCH_TOKENS"
ENV_RETAIN_BATCH_ENABLED = "HINDSIGHT_API_RETAIN_BATCH_ENABLED"
ENV_RETAIN_BATCH_POLL_INTERVAL_SECONDS = "HINDSIGHT_API_RETAIN_BATCH_POLL_INTERVAL_SECONDS"
# File storage configuration
ENV_FILE_STORAGE_TYPE = "HINDSIGHT_API_FILE_STORAGE_TYPE"
ENV_FILE_STORAGE_S3_BUCKET = "HINDSIGHT_API_FILE_STORAGE_S3_BUCKET"
ENV_FILE_STORAGE_S3_REGION = "HINDSIGHT_API_FILE_STORAGE_S3_REGION"
ENV_FILE_STORAGE_S3_ENDPOINT = "HINDSIGHT_API_FILE_STORAGE_S3_ENDPOINT"
ENV_FILE_STORAGE_S3_ACCESS_KEY_ID = "HINDSIGHT_API_FILE_STORAGE_S3_ACCESS_KEY_ID"
ENV_FILE_STORAGE_S3_SECRET_ACCESS_KEY = "HINDSIGHT_API_FILE_STORAGE_S3_SECRET_ACCESS_KEY"
ENV_FILE_STORAGE_GCS_BUCKET = "HINDSIGHT_API_FILE_STORAGE_GCS_BUCKET"
ENV_FILE_STORAGE_GCS_SERVICE_ACCOUNT_KEY = "HINDSIGHT_API_FILE_STORAGE_GCS_SERVICE_ACCOUNT_KEY"
ENV_FILE_STORAGE_AZURE_CONTAINER = "HINDSIGHT_API_FILE_STORAGE_AZURE_CONTAINER"
ENV_FILE_STORAGE_AZURE_ACCOUNT_NAME = "HINDSIGHT_API_FILE_STORAGE_AZURE_ACCOUNT_NAME"
ENV_FILE_STORAGE_AZURE_ACCOUNT_KEY = "HINDSIGHT_API_FILE_STORAGE_AZURE_ACCOUNT_KEY"
ENV_FILE_PARSER = "HINDSIGHT_API_FILE_PARSER"
ENV_FILE_PARSER_IRIS_TOKEN = "HINDSIGHT_API_FILE_PARSER_IRIS_TOKEN"
ENV_FILE_PARSER_IRIS_ORG_ID = "HINDSIGHT_API_FILE_PARSER_IRIS_ORG_ID"
ENV_FILE_CONVERSION_MAX_BATCH_SIZE_MB = "HINDSIGHT_API_FILE_CONVERSION_MAX_BATCH_SIZE_MB"
ENV_FILE_CONVERSION_MAX_BATCH_SIZE = "HINDSIGHT_API_FILE_CONVERSION_MAX_BATCH_SIZE"
ENV_ENABLE_FILE_UPLOAD_API = "HINDSIGHT_API_ENABLE_FILE_UPLOAD_API"
ENV_FILE_DELETE_AFTER_RETAIN = "HINDSIGHT_API_FILE_DELETE_AFTER_RETAIN"
# Observations settings (consolidated knowledge from facts)
ENV_ENABLE_OBSERVATIONS = "HINDSIGHT_API_ENABLE_OBSERVATIONS"
@@ -399,17 +371,6 @@ DEFAULT_RETAIN_EXTRACT_CAUSAL_LINKS = True # Extract causal links between facts
DEFAULT_RETAIN_EXTRACTION_MODE = "concise" # Extraction mode: "concise", "verbose", or "custom"
RETAIN_EXTRACTION_MODES = ("concise", "verbose", "custom") # Allowed extraction modes
DEFAULT_RETAIN_CUSTOM_INSTRUCTIONS = None # Custom extraction guidelines (only used when mode="custom")
DEFAULT_RETAIN_BATCH_TOKENS = 10_000 # ~40KB of text # Max chars per sub-batch for async retain auto-splitting
DEFAULT_RETAIN_BATCH_ENABLED = False # Use LLM Batch API for fact extraction (only when async=True)
DEFAULT_RETAIN_BATCH_POLL_INTERVAL_SECONDS = 60 # Batch API polling interval in seconds
# File storage defaults
DEFAULT_FILE_STORAGE_TYPE = "native" # PostgreSQL BYTEA storage
DEFAULT_FILE_PARSER = "markitdown" # File parser to use (markitdown is the only supported parser)
DEFAULT_FILE_CONVERSION_MAX_BATCH_SIZE_MB = 100 # Max total batch size in MB (all files combined)
DEFAULT_FILE_CONVERSION_MAX_BATCH_SIZE = 10 # Max files per batch upload
DEFAULT_ENABLE_FILE_UPLOAD_API = True # Enable file upload endpoint
DEFAULT_FILE_DELETE_AFTER_RETAIN = True # Delete file bytes after retain (saves storage)
# Observations defaults (consolidated knowledge from facts)
DEFAULT_ENABLE_OBSERVATIONS = True # Observations enabled by default
@@ -533,8 +494,6 @@ class HindsightConfig:
llm_initial_backoff: float
llm_max_backoff: float
llm_timeout: float
llm_groq_service_tier: str # Groq: "on_demand", "flex", or "auto"
llm_openai_service_tier: str | None # OpenAI: None (default) or "flex" (50% cheaper)
# Vertex AI configuration
llm_vertexai_project_id: str | None
@@ -631,29 +590,6 @@ class HindsightConfig:
retain_extract_causal_links: bool
retain_extraction_mode: str
retain_custom_instructions: str | None
retain_batch_tokens: int
retain_batch_enabled: bool
retain_batch_poll_interval_seconds: int
# File storage (static - server-level only)
file_storage_type: str # "native" (PostgreSQL) or "s3" (S3-compatible)
file_storage_s3_bucket: str | None # S3 bucket name (required for s3 storage)
file_storage_s3_region: str | None # S3 region (optional, uses SDK default)
file_storage_s3_endpoint: str | None # S3 endpoint URL (for MinIO, R2, etc.)
file_storage_s3_access_key_id: str | None # S3 access key (optional, uses env/IAM)
file_storage_s3_secret_access_key: str | None # S3 secret key (optional, uses env/IAM)
file_storage_gcs_bucket: str | None # GCS bucket name (required for gcs storage)
file_storage_gcs_service_account_key: str | None # GCS service account key JSON (optional, uses ADC)
file_storage_azure_container: str | None # Azure container name (required for azure storage)
file_storage_azure_account_name: str | None # Azure storage account name
file_storage_azure_account_key: str | None # Azure storage account key
file_parser: str # File parser to use (e.g., "markitdown", "iris")
file_parser_iris_token: str | None # Vectorize API token for iris parser (VECTORIZE_TOKEN)
file_parser_iris_org_id: str | None # Vectorize org ID for iris parser (VECTORIZE_ORG_ID)
file_conversion_max_batch_size_mb: int # Max total batch size in MB (all files combined)
file_conversion_max_batch_size: int # Max files per request
enable_file_upload_api: bool
file_delete_after_retain: bool
# Observations settings (consolidated knowledge from facts)
enable_observations: bool
@@ -711,13 +647,6 @@ class HindsightConfig:
"reranker_cohere_base_url",
# Service Account Keys
"llm_vertexai_service_account_key",
# File storage credentials
"file_storage_s3_access_key_id",
"file_storage_s3_secret_access_key",
"file_storage_gcs_service_account_key",
"file_storage_azure_account_key",
# File parser credentials
"file_parser_iris_token",
}
# CONFIGURABLE_FIELDS: Safe behavioral settings that can be customized per-tenant/bank
@@ -732,11 +661,6 @@ class HindsightConfig:
"enable_observations",
}
@property
def file_conversion_max_batch_size_bytes(self) -> int:
"""Get maximum total batch size in bytes."""
return self.file_conversion_max_batch_size_mb * 1024 * 1024
@classmethod
def get_configurable_fields(cls) -> set[str]:
"""
@@ -843,8 +767,6 @@ class HindsightConfig:
llm_initial_backoff=float(os.getenv(ENV_LLM_INITIAL_BACKOFF, str(DEFAULT_LLM_INITIAL_BACKOFF))),
llm_max_backoff=float(os.getenv(ENV_LLM_MAX_BACKOFF, str(DEFAULT_LLM_MAX_BACKOFF))),
llm_timeout=float(os.getenv(ENV_LLM_TIMEOUT, str(DEFAULT_LLM_TIMEOUT))),
llm_groq_service_tier=os.getenv(ENV_LLM_GROQ_SERVICE_TIER, DEFAULT_LLM_GROQ_SERVICE_TIER),
llm_openai_service_tier=os.getenv(ENV_LLM_OPENAI_SERVICE_TIER, DEFAULT_LLM_OPENAI_SERVICE_TIER),
# Vertex AI
llm_vertexai_project_id=os.getenv(ENV_LLM_VERTEXAI_PROJECT_ID) or DEFAULT_LLM_VERTEXAI_PROJECT_ID,
llm_vertexai_region=os.getenv(ENV_LLM_VERTEXAI_REGION, DEFAULT_LLM_VERTEXAI_REGION),
@@ -1017,39 +939,6 @@ class HindsightConfig:
os.getenv(ENV_RETAIN_EXTRACTION_MODE, DEFAULT_RETAIN_EXTRACTION_MODE)
),
retain_custom_instructions=os.getenv(ENV_RETAIN_CUSTOM_INSTRUCTIONS) or DEFAULT_RETAIN_CUSTOM_INSTRUCTIONS,
retain_batch_tokens=int(os.getenv(ENV_RETAIN_BATCH_TOKENS, str(DEFAULT_RETAIN_BATCH_TOKENS))),
retain_batch_enabled=os.getenv(ENV_RETAIN_BATCH_ENABLED, str(DEFAULT_RETAIN_BATCH_ENABLED)).lower()
== "true",
retain_batch_poll_interval_seconds=int(
os.getenv(ENV_RETAIN_BATCH_POLL_INTERVAL_SECONDS, str(DEFAULT_RETAIN_BATCH_POLL_INTERVAL_SECONDS))
),
# File storage
file_storage_type=os.getenv(ENV_FILE_STORAGE_TYPE, DEFAULT_FILE_STORAGE_TYPE),
file_storage_s3_bucket=os.getenv(ENV_FILE_STORAGE_S3_BUCKET) or None,
file_storage_s3_region=os.getenv(ENV_FILE_STORAGE_S3_REGION) or None,
file_storage_s3_endpoint=os.getenv(ENV_FILE_STORAGE_S3_ENDPOINT) or None,
file_storage_s3_access_key_id=os.getenv(ENV_FILE_STORAGE_S3_ACCESS_KEY_ID) or None,
file_storage_s3_secret_access_key=os.getenv(ENV_FILE_STORAGE_S3_SECRET_ACCESS_KEY) or None,
file_storage_gcs_bucket=os.getenv(ENV_FILE_STORAGE_GCS_BUCKET) or None,
file_storage_gcs_service_account_key=os.getenv(ENV_FILE_STORAGE_GCS_SERVICE_ACCOUNT_KEY) or None,
file_storage_azure_container=os.getenv(ENV_FILE_STORAGE_AZURE_CONTAINER) or None,
file_storage_azure_account_name=os.getenv(ENV_FILE_STORAGE_AZURE_ACCOUNT_NAME) or None,
file_storage_azure_account_key=os.getenv(ENV_FILE_STORAGE_AZURE_ACCOUNT_KEY) or None,
file_parser=os.getenv(ENV_FILE_PARSER, DEFAULT_FILE_PARSER),
file_parser_iris_token=os.getenv(ENV_FILE_PARSER_IRIS_TOKEN) or None,
file_parser_iris_org_id=os.getenv(ENV_FILE_PARSER_IRIS_ORG_ID) or None,
file_conversion_max_batch_size_mb=int(
os.getenv(ENV_FILE_CONVERSION_MAX_BATCH_SIZE_MB, str(DEFAULT_FILE_CONVERSION_MAX_BATCH_SIZE_MB))
),
file_conversion_max_batch_size=int(
os.getenv(ENV_FILE_CONVERSION_MAX_BATCH_SIZE, str(DEFAULT_FILE_CONVERSION_MAX_BATCH_SIZE))
),
enable_file_upload_api=os.getenv(ENV_ENABLE_FILE_UPLOAD_API, str(DEFAULT_ENABLE_FILE_UPLOAD_API)).lower()
== "true",
file_delete_after_retain=os.getenv(
ENV_FILE_DELETE_AFTER_RETAIN, str(DEFAULT_FILE_DELETE_AFTER_RETAIN)
).lower()
== "true",
# Observations settings (consolidated knowledge from facts)
enable_observations=os.getenv(ENV_ENABLE_OBSERVATIONS, str(DEFAULT_ENABLE_OBSERVATIONS)).lower() == "true",
consolidation_batch_size=int(
@@ -128,67 +128,6 @@ class LLMInterface(ABC):
"""
pass
async def supports_batch_api(self) -> bool:
"""
Check if this provider supports batch API operations.
Returns:
True if provider supports submit_batch/get_batch_status/retrieve_batch_results
"""
return False
async def submit_batch(
self,
requests: list[dict[str, Any]],
endpoint: str = "/v1/chat/completions",
completion_window: str = "24h",
) -> dict[str, Any]:
"""
Submit a batch of requests to the provider's batch API.
Args:
requests: List of request dicts in JSONL format (custom_id, method, url, body)
endpoint: API endpoint for the batch (e.g., "/v1/chat/completions")
completion_window: Completion window (e.g., "24h")
Returns:
Dict with batch metadata: {"batch_id": str, "status": str, ...}
Raises:
NotImplementedError: If provider doesn't support batch API
"""
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
async def get_batch_status(self, batch_id: str) -> dict[str, Any]:
"""
Get the status of a batch job.
Args:
batch_id: Batch identifier returned from submit_batch
Returns:
Dict with status info: {"batch_id": str, "status": str, "completed_at": str, ...}
Raises:
NotImplementedError: If provider doesn't support batch API
"""
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
async def retrieve_batch_results(self, batch_id: str) -> list[dict[str, Any]]:
"""
Retrieve completed batch results.
Args:
batch_id: Batch identifier returned from submit_batch
Returns:
List of result dicts (one per request, matched by custom_id)
Raises:
NotImplementedError: If provider doesn't support batch API
"""
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
@abstractmethod
async def cleanup(self) -> None:
"""Clean up resources (close connections, etc.)."""
@@ -67,7 +67,6 @@ def create_llm_provider(
model: str,
reasoning_effort: str,
groq_service_tier: str | None = None,
openai_service_tier: str | None = None,
vertexai_project_id: str | None = None,
vertexai_region: str | None = None,
vertexai_credentials: Any = None,
@@ -81,8 +80,7 @@ def create_llm_provider(
base_url: Base URL for the API.
model: Model name.
reasoning_effort: Reasoning effort level for supported providers.
groq_service_tier: Groq service tier (for Groq provider) - "on_demand", "flex", or "auto".
openai_service_tier: OpenAI service tier (for OpenAI provider) - None (default) or "flex" (50% cheaper).
groq_service_tier: Groq service tier (for Groq provider).
vertexai_project_id: Vertex AI project ID (for VertexAI provider).
vertexai_region: Vertex AI region (for VertexAI provider).
vertexai_credentials: Vertex AI credentials object (for VertexAI provider).
@@ -158,7 +156,6 @@ def create_llm_provider(
model=model,
reasoning_effort=reasoning_effort,
groq_service_tier=groq_service_tier,
openai_service_tier=openai_service_tier,
)
else:
@@ -180,7 +177,6 @@ class LLMProvider:
model: str,
reasoning_effort: str = "low",
groq_service_tier: str | None = None,
openai_service_tier: str | None = None,
):
"""
Initialize LLM provider.
@@ -191,17 +187,15 @@ class LLMProvider:
base_url: Base URL for the API.
model: Model name.
reasoning_effort: Reasoning effort level for supported providers.
groq_service_tier: Groq service tier ("on_demand", "flex", "auto") - from config.
openai_service_tier: OpenAI service tier (None or "flex") - from config.
groq_service_tier: Groq service tier ("on_demand", "flex", "auto"). Default: None (uses Groq's default).
"""
self.provider = provider.lower()
self.api_key = api_key
self.base_url = base_url
self.model = model
self.reasoning_effort = reasoning_effort
# Service tiers from hierarchical config (not env vars)
self.groq_service_tier = groq_service_tier
self.openai_service_tier = openai_service_tier
# Default to 'auto' for best performance, users can override to 'on_demand' for free tier
self.groq_service_tier = groq_service_tier or os.getenv(ENV_LLM_GROQ_SERVICE_TIER, "auto")
# Validate provider
valid_providers = [
@@ -278,7 +272,6 @@ class LLMProvider:
model=self.model,
reasoning_effort=self.reasoning_effort,
groq_service_tier=self.groq_service_tier,
openai_service_tier=self.openai_service_tier,
vertexai_project_id=vertexai_project_id,
vertexai_region=vertexai_region,
vertexai_credentials=vertexai_credentials,
File diff suppressed because it is too large Load Diff
@@ -1,69 +0,0 @@
"""
Typed metadata models for async operations.
These dataclasses define the structure of result_metadata for different operation types.
The metadata is exposed in the API for debugging purposes and may change without notice.
"""
from dataclasses import asdict, dataclass
from typing import Any
@dataclass
class BatchRetainParentMetadata:
"""Metadata for parent batch_retain operations (when split into sub-batches)."""
items_count: int
total_tokens: int
num_sub_batches: int
is_parent: bool = True
def to_dict(self) -> dict[str, Any]:
"""Convert to dict for JSON serialization."""
return asdict(self)
@dataclass
class BatchRetainChildMetadata:
"""Metadata for child batch_retain operations (individual sub-batches)."""
items_count: int
parent_operation_id: str
sub_batch_index: int
total_sub_batches: int
def to_dict(self) -> dict[str, Any]:
"""Convert to dict for JSON serialization."""
return asdict(self)
@dataclass
class RetainMetadata:
"""Metadata for regular retain operations (non-batched, deprecated async path)."""
items_count: int
def to_dict(self) -> dict[str, Any]:
"""Convert to dict for JSON serialization."""
return asdict(self)
@dataclass
class ConsolidationMetadata:
"""Metadata for consolidation operations."""
# Currently empty, but structure for future fields
def to_dict(self) -> dict[str, Any]:
"""Convert to dict for JSON serialization."""
return asdict(self)
@dataclass
class RefreshMentalModelMetadata:
"""Metadata for mental model refresh operations."""
mental_model_id: str
def to_dict(self) -> dict[str, Any]:
"""Convert to dict for JSON serialization."""
return asdict(self)
@@ -1,62 +0,0 @@
"""File parser implementations."""
from .base import FileParser, UnsupportedFileTypeError
from .iris import IrisParser
from .markitdown import MarkitdownParser
__all__ = ["FileParser", "UnsupportedFileTypeError", "IrisParser", "MarkitdownParser", "FileParserRegistry"]
class FileParserRegistry:
"""Registry for file parsers with auto-detection."""
def __init__(self):
"""Initialize empty parser registry."""
self._parsers: dict[str, FileParser] = {}
def register(self, parser: FileParser):
"""
Register a parser.
Args:
parser: FileParser instance
"""
self._parsers[parser.name()] = parser
def get_parser(
self,
name: str | None,
filename: str,
content_type: str | None = None,
) -> FileParser:
"""
Get parser by name or auto-detect.
Args:
name: Parser name (e.g., "markitdown") or None for auto-detect
filename: File name for auto-detection
content_type: MIME type (optional)
Returns:
FileParser instance
Raises:
ValueError: If no suitable parser found
"""
if name:
# Explicit parser requested — return it directly, let the parser
# raise UnsupportedFileTypeError from convert() if needed
if name not in self._parsers:
raise ValueError(f"Parser '{name}' not found. Available: {list(self._parsers.keys())}")
return self._parsers[name]
# Auto-detect parser
for parser in self._parsers.values():
if parser.supports(filename, content_type):
return parser
raise ValueError(f"No parser found for {filename}. Available parsers: {list(self._parsers.keys())}")
def list_parsers(self) -> list[str]:
"""Get list of registered parser names."""
return list(self._parsers.keys())
@@ -1,58 +0,0 @@
"""Abstract base class for file parsers."""
from abc import ABC, abstractmethod
class UnsupportedFileTypeError(Exception):
"""Raised by a parser when it does not support the given file type."""
pass
class FileParser(ABC):
"""Abstract base for file to markdown parsers."""
@abstractmethod
async def convert(self, file_data: bytes, filename: str) -> str:
"""
Parse file to markdown.
Args:
file_data: Raw file bytes
filename: Original filename (used for format detection)
Returns:
Markdown content as string
Raises:
UnsupportedFileTypeError: If the file type is not supported by this parser
RuntimeError: If parsing fails for another reason
"""
pass
def supports(self, filename: str, content_type: str | None = None) -> bool:
"""
Check if parser supports this file type.
Override this for local/static extension-based filtering.
Parsers that delegate to a remote service should leave this as True
and raise UnsupportedFileTypeError from convert() instead.
Args:
filename: File name (used for extension check)
content_type: MIME type (optional)
Returns:
True if this parser can handle the file (default: True)
"""
return True
@abstractmethod
def name(self) -> str:
"""
Get parser name.
Returns:
Parser name (e.g., "markitdown")
"""
pass
@@ -1,137 +0,0 @@
"""Iris parser implementation using the Vectorize Iris HTTP API."""
import asyncio
import logging
import mimetypes
import time
import httpx
from .base import FileParser, UnsupportedFileTypeError
logger = logging.getLogger(__name__)
_IRIS_BASE_URL = "https://api.vectorize.io/v1"
_DEFAULT_POLL_INTERVAL = 2.0 # seconds
_DEFAULT_TIMEOUT = 300.0 # seconds
class IrisParser(FileParser):
"""
Iris file parser using the Vectorize Iris cloud extraction service.
Uploads files to the Vectorize Iris API, starts an extraction job,
and polls until the text is ready. The API determines which file types
are supported — UnsupportedFileTypeError is raised if the file is rejected.
Authentication:
Requires HINDSIGHT_API_FILE_PARSER_IRIS_TOKEN and
HINDSIGHT_API_FILE_PARSER_IRIS_ORG_ID environment variables,
or pass them explicitly via the constructor.
"""
def __init__(
self,
token: str,
org_id: str,
poll_interval: float = _DEFAULT_POLL_INTERVAL,
timeout: float = _DEFAULT_TIMEOUT,
):
"""
Initialize iris parser.
Args:
token: Vectorize API token
org_id: Vectorize organization ID
poll_interval: Seconds between status poll requests (default: 2)
timeout: Maximum seconds to wait for extraction (default: 300)
"""
self._token = token
self._org_id = org_id
self._poll_interval = poll_interval
self._timeout = timeout
self._auth_headers = {"Authorization": f"Bearer {token}"}
async def convert(self, file_data: bytes, filename: str) -> str:
"""
Parse file to text using the Vectorize Iris API.
Raises:
UnsupportedFileTypeError: If the Iris API rejects the file type (4xx)
RuntimeError: If extraction fails for another reason
"""
content_type = mimetypes.guess_type(filename)[0] or "application/octet-stream"
async with httpx.AsyncClient() as client:
# Step 1: Request a presigned upload URL
init_resp = await client.post(
f"{_IRIS_BASE_URL}/org/{self._org_id}/files",
headers=self._auth_headers,
json={"name": filename, "contentType": content_type},
)
_raise_for_status(init_resp, filename, "file upload init")
init_data = init_resp.json()
file_id: str = init_data["fileId"]
upload_url: str = init_data["uploadUrl"]
# Step 2: Upload the file bytes to the presigned URL (no auth header)
upload_resp = await client.put(
upload_url,
content=file_data,
headers={"Content-Type": content_type},
)
_raise_for_status(upload_resp, filename, "file upload")
# Step 3: Start extraction
extract_resp = await client.post(
f"{_IRIS_BASE_URL}/org/{self._org_id}/extraction",
headers=self._auth_headers,
json={"fileId": file_id},
)
_raise_for_status(extract_resp, filename, "start extraction")
extraction_id: str = extract_resp.json()["extractionId"]
# Step 4: Poll until ready or timeout
deadline = time.monotonic() + self._timeout
while True:
status_resp = await client.get(
f"{_IRIS_BASE_URL}/org/{self._org_id}/extraction/{extraction_id}",
headers=self._auth_headers,
)
_raise_for_status(status_resp, filename, "poll extraction status")
status_data = status_resp.json()
if status_data.get("ready"):
data = status_data.get("data", {})
if not data.get("success"):
error = data.get("error", "unknown error")
raise RuntimeError(f"Iris extraction failed for '{filename}': {error}")
text = data.get("text")
if not text:
raise RuntimeError(f"No content extracted from '{filename}'")
return text
if time.monotonic() >= deadline:
raise RuntimeError(f"Iris extraction timed out after {self._timeout}s for '{filename}'")
await asyncio.sleep(self._poll_interval)
def name(self) -> str:
"""Get parser name."""
return "iris"
def _raise_for_status(response: httpx.Response, filename: str, step: str) -> None:
"""
Raise an appropriate error including the response body on HTTP errors.
Raises UnsupportedFileTypeError for 4xx responses (file rejected by the API),
RuntimeError for other HTTP errors.
"""
if not response.is_error:
return
body = response.text or "<empty>"
msg = f"Iris API error during {step} for '{filename}': {response.status_code} {response.reason_phrase}{body}"
if response.is_client_error:
raise UnsupportedFileTypeError(msg)
raise RuntimeError(msg)
@@ -1,109 +0,0 @@
"""Markitdown parser implementation."""
import asyncio
import logging
import tempfile
from pathlib import Path
from .base import FileParser
logger = logging.getLogger(__name__)
class MarkitdownParser(FileParser):
"""
Markitdown file parser.
Uses Microsoft's markitdown library to convert various file formats
to markdown including PDF, Office docs, images (via OCR), audio, HTML.
Supported formats:
- PDF (.pdf)
- Word (.docx, .doc)
- PowerPoint (.pptx, .ppt)
- Excel (.xlsx, .xls)
- Images (.jpg, .jpeg, .png) - with OCR
- HTML (.html, .htm)
- Text (.txt, .md)
- Audio (.mp3, .wav) - with transcription
"""
def __init__(self):
"""Initialize markitdown parser."""
# Lazy import to avoid requiring markitdown for all users
try:
from markitdown import MarkItDown
self._markitdown = MarkItDown()
except ImportError as e:
raise ImportError(
"markitdown package is required for file parsing. Install with: pip install markitdown"
) from e
async def convert(self, file_data: bytes, filename: str) -> str:
"""Parse file to markdown using markitdown."""
# markitdown is synchronous, so we run it in executor to avoid blocking
loop = asyncio.get_event_loop()
return await loop.run_in_executor(None, self._convert_sync, file_data, filename)
def _convert_sync(self, file_data: bytes, filename: str) -> str:
"""Synchronous parsing (runs in thread pool)."""
# Write to temp file (markitdown requires file path)
with tempfile.NamedTemporaryFile(suffix=Path(filename).suffix, delete=False) as tmp:
tmp.write(file_data)
tmp_path = tmp.name
try:
# Parse using markitdown
result = self._markitdown.convert(tmp_path)
if not result or not result.text_content:
raise RuntimeError(f"No content extracted from '{filename}'")
return result.text_content
except Exception as e:
logger.error(f"Markitdown parsing failed for {filename}: {e}")
raise RuntimeError(f"Failed to parse '{filename}': {e}") from e
finally:
# Clean up temp file
try:
Path(tmp_path).unlink()
except Exception:
pass
def supports(self, filename: str, content_type: str | None = None) -> bool:
"""Check if markitdown supports this file type."""
# Supported extensions (from markitdown docs)
supported_extensions = {
# Documents
".pdf",
".docx",
".doc",
".pptx",
".ppt",
".xlsx",
".xls",
# Images (with OCR)
".jpg",
".jpeg",
".png",
# Web
".html",
".htm",
# Text
".txt",
".md",
".csv",
# Audio (with transcription)
".mp3",
".wav",
}
ext = Path(filename).suffix.lower()
return ext in supported_extensions
def name(self) -> str:
"""Get parser name."""
return "markitdown"
@@ -16,7 +16,6 @@ Features:
"""
import asyncio
import io
import json
import logging
import os
@@ -97,9 +96,8 @@ class OpenAICompatibleLLM(LLMInterface):
if self.provider in ("openai", "groq") and not self.api_key:
raise ValueError(f"API key is required for {self.provider}")
# Service tier configuration (from config, not env vars)
self.groq_service_tier = groq_service_tier
self.openai_service_tier = kwargs.get("openai_service_tier")
# Groq service tier configuration
self.groq_service_tier = groq_service_tier or os.getenv("HINDSIGHT_API_LLM_GROQ_SERVICE_TIER", "auto")
# Get timeout config
self.timeout = timeout or float(os.getenv(ENV_LLM_TIMEOUT, str(DEFAULT_LLM_TIMEOUT)))
@@ -784,140 +782,6 @@ class OpenAICompatibleLLM(LLMInterface):
raise last_exception
raise RuntimeError("Ollama call failed after all retries")
async def supports_batch_api(self) -> bool:
"""Check if this provider supports batch API operations."""
# Only OpenAI and Groq support batch API
return self.provider in ("openai", "groq")
async def submit_batch(
self,
requests: list[dict[str, Any]],
endpoint: str = "/v1/chat/completions",
completion_window: str = "24h",
) -> dict[str, Any]:
"""
Submit a batch of requests to OpenAI/Groq Batch API.
Args:
requests: List of request dicts with custom_id, method, url, body
endpoint: API endpoint (e.g., "/v1/chat/completions")
completion_window: Completion window (e.g., "24h")
Returns:
Dict with batch metadata including batch_id
Raises:
NotImplementedError: If provider doesn't support batch API
"""
if not await self.supports_batch_api():
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
logger.info(f"Submitting batch with {len(requests)} requests to {self.provider}")
# Format requests as JSONL
jsonl_content = "\n".join(json.dumps(req) for req in requests)
# Upload file to provider (wrap in BytesIO with filename)
file_bytes = io.BytesIO(jsonl_content.encode("utf-8"))
file_bytes.name = "batch_input.jsonl" # OpenAI SDK needs a filename
file_response = await self._client.files.create(
file=file_bytes,
purpose="batch",
)
logger.debug(f"Uploaded batch file: {file_response.id}")
# Create batch
batch_response = await self._client.batches.create(
input_file_id=file_response.id,
endpoint=endpoint,
completion_window=completion_window,
)
logger.info(f"Batch submitted: {batch_response.id}, status={batch_response.status}")
return {
"batch_id": batch_response.id,
"status": batch_response.status,
"input_file_id": file_response.id,
"created_at": batch_response.created_at,
"request_count": len(requests),
}
async def get_batch_status(self, batch_id: str) -> dict[str, Any]:
"""
Get the status of a batch job.
Args:
batch_id: Batch identifier
Returns:
Dict with status info (batch_id, status, completed_at, etc.)
"""
if not await self.supports_batch_api():
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
batch = await self._client.batches.retrieve(batch_id)
result = {
"batch_id": batch.id,
"status": batch.status,
"created_at": batch.created_at,
"request_counts": {
"total": batch.request_counts.total if batch.request_counts else 0,
"completed": batch.request_counts.completed if batch.request_counts else 0,
"failed": batch.request_counts.failed if batch.request_counts else 0,
},
}
if batch.completed_at:
result["completed_at"] = batch.completed_at
if batch.output_file_id:
result["output_file_id"] = batch.output_file_id
if batch.error_file_id:
result["error_file_id"] = batch.error_file_id
if batch.errors:
result["errors"] = batch.errors
return result
async def retrieve_batch_results(self, batch_id: str) -> list[dict[str, Any]]:
"""
Retrieve completed batch results.
Args:
batch_id: Batch identifier
Returns:
List of result dicts (one per request, matched by custom_id)
"""
if not await self.supports_batch_api():
raise NotImplementedError(f"Batch API not supported for provider: {self.provider}")
# Get batch status
batch = await self._client.batches.retrieve(batch_id)
if batch.status != "completed":
raise ValueError(f"Batch {batch_id} is not completed yet (status: {batch.status})")
if not batch.output_file_id:
raise ValueError(f"Batch {batch_id} has no output file")
# Download results file
logger.debug(f"Downloading results for batch {batch_id} from file {batch.output_file_id}")
file_content = await self._client.files.content(batch.output_file_id)
# Parse JSONL results
results = []
for line in file_content.text.strip().split("\n"):
if line:
results.append(json.loads(line))
logger.info(f"Retrieved {len(results)} results for batch {batch_id}")
return results
async def cleanup(self) -> None:
"""Clean up resources (close OpenAI client connections)."""
if hasattr(self, "_client") and self._client:
@@ -695,91 +695,6 @@ Example: "Lost job → couldn't pay rent → moved apartment"
- Fact 2: Moved apartment, causal_relations: [{target_index: 1, relation_type: "caused_by"}]"""
def _build_extraction_prompt_and_schema(config) -> tuple[str, type]:
"""
Build extraction prompt and response schema based on config.
Returns:
Tuple of (prompt, response_schema)
"""
fact_types_instruction = "Extract ONLY 'world' and 'assistant' type facts."
extraction_mode = config.retain_extraction_mode
extract_causal_links = config.retain_extract_causal_links
# Select base prompt based on extraction mode
if extraction_mode == "custom":
if not config.retain_custom_instructions:
base_prompt = CONCISE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
else:
base_prompt = CUSTOM_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(
fact_types_instruction=fact_types_instruction,
custom_instructions=config.retain_custom_instructions,
)
elif extraction_mode == "verbose":
base_prompt = VERBOSE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
else:
base_prompt = CONCISE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
# Add causal relationships section if enabled
if extract_causal_links:
prompt = prompt + CAUSAL_RELATIONSHIPS_SECTION
response_schema = FactExtractionResponseVerbose if extraction_mode == "verbose" else FactExtractionResponse
else:
response_schema = FactExtractionResponseNoCausal
return prompt, response_schema
def _build_user_message(chunk: str, chunk_index: int, total_chunks: int, event_date: datetime, context: str) -> str:
"""Build user message for fact extraction."""
from .orchestrator import parse_datetime_flexible
sanitized_chunk = _sanitize_text(chunk)
sanitized_context = _sanitize_text(context) if context else "none"
event_date = parse_datetime_flexible(event_date)
event_date_formatted = event_date.strftime("%A, %B %d, %Y")
return f"""Extract facts from the following text chunk.
Chunk: {chunk_index + 1}/{total_chunks}
Event Date: {event_date_formatted} ({event_date.isoformat()})
Context: {sanitized_context}
Text:
{sanitized_chunk}"""
def _build_request_body(llm_config, config, prompt: str, user_message: str, response_schema: type) -> dict:
"""Build request body for LLM API call."""
request_body = {
"model": llm_config.model,
"messages": [{"role": "system", "content": prompt}, {"role": "user", "content": user_message}],
"temperature": 0.1,
}
# Add max_completion_tokens if configured
if config.retain_max_completion_tokens:
request_body["max_completion_tokens"] = config.retain_max_completion_tokens
# Add service_tier for OpenAI Flex Processing
if llm_config.provider == "openai" and llm_config._provider_impl.openai_service_tier:
request_body["service_tier"] = llm_config._provider_impl.openai_service_tier
# Add response_format (JSON schema)
if hasattr(response_schema, "model_json_schema"):
schema = response_schema.model_json_schema()
request_body["response_format"] = {
"type": "json_schema",
"json_schema": {"name": "facts", "schema": schema},
}
return request_body
async def _extract_facts_from_chunk(
chunk: str,
chunk_index: int,
@@ -802,20 +717,72 @@ async def _extract_facts_from_chunk(
logger = logging.getLogger(__name__)
# Build prompt and schema using helper function
prompt, response_schema = _build_extraction_prompt_and_schema(config)
# Determine which fact types to extract
# Note: We use "assistant" in the prompt but convert to "bank" for storage
fact_types_instruction = "Extract ONLY 'world' and 'assistant' type facts."
# Check config for extraction mode and causal link extraction
extraction_mode = config.retain_extraction_mode
extract_causal_links = config.retain_extract_causal_links
# Build user message using helper function
user_message = _build_user_message(chunk, chunk_index, total_chunks, event_date, context)
# Select base prompt based on extraction mode
if extraction_mode == "custom":
# Custom mode: inject user-provided guidelines
if not config.retain_custom_instructions:
logger.warning(
"extraction_mode='custom' but HINDSIGHT_API_RETAIN_CUSTOM_INSTRUCTIONS not set. "
"Falling back to 'concise' mode."
)
base_prompt = CONCISE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
else:
base_prompt = CUSTOM_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(
fact_types_instruction=fact_types_instruction,
custom_instructions=config.retain_custom_instructions,
)
elif extraction_mode == "verbose":
base_prompt = VERBOSE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
else:
base_prompt = CONCISE_FACT_EXTRACTION_PROMPT
prompt = base_prompt.format(fact_types_instruction=fact_types_instruction)
# Build the full prompt with or without causal relationships section
# Select appropriate response schema based on extraction mode and causal links
if extract_causal_links:
prompt = prompt + CAUSAL_RELATIONSHIPS_SECTION
if extraction_mode == "verbose":
response_schema = FactExtractionResponseVerbose
else:
response_schema = FactExtractionResponse
else:
response_schema = FactExtractionResponseNoCausal
# Retry logic for JSON validation errors
max_retries = 2
last_error = None
# Sanitize input text to prevent Unicode encoding errors (e.g., unpaired surrogates)
sanitized_chunk = _sanitize_text(chunk)
sanitized_context = _sanitize_text(context) if context else "none"
# Build user message with metadata and chunk content in a clear format
# Format event_date with day of week for better temporal reasoning
# Handle both datetime objects and ISO string formats (from deserialized async tasks)
from .orchestrator import parse_datetime_flexible
event_date = parse_datetime_flexible(event_date)
event_date_formatted = event_date.strftime("%A, %B %d, %Y") # e.g., "Monday, June 10, 2024"
user_message = f"""Extract facts from the following text chunk.
Chunk: {chunk_index + 1}/{total_chunks}
Event Date: {event_date_formatted} ({event_date.isoformat()})
Context: {sanitized_context}
Text:
{sanitized_chunk}"""
usage = TokenUsage() # Track cumulative usage across retries
for attempt in range(max_retries):
try:
@@ -1278,420 +1245,8 @@ logger = logging.getLogger(__name__)
SECONDS_PER_FACT = 10
async def extract_facts_from_contents_batch_api(
contents: list[RetainContent],
llm_config,
agent_name: str,
config,
pool=None,
operation_id: str | None = None,
schema: str | None = None,
) -> tuple[list[ExtractedFactType], list[ChunkMetadata], TokenUsage]:
"""
Extract facts using LLM Batch API (OpenAI/Groq).
Submits all chunks as a single batch, polls until complete, then processes results.
Only called when config.retain_batch_enabled=True.
Args:
contents: List of RetainContent objects to process
llm_config: LLM configuration with batch API support
agent_name: Name of the agent
config: Resolved HindsightConfig for this bank
pool: Database connection pool (for storing batch state)
operation_id: Async operation ID (for crash recovery)
schema: Database schema (for multi-tenant support)
Returns:
Tuple of (extracted_facts, chunks_metadata, usage)
"""
if not contents:
return [], [], TokenUsage()
logger.info(f"Using Batch API for fact extraction ({len(contents)} contents)")
# Check config for extraction mode and causal link extraction (used throughout)
extraction_mode = config.retain_extraction_mode
extract_causal_links = config.retain_extract_causal_links
# Check if provider supports batch API
if not await llm_config._provider_impl.supports_batch_api():
logger.warning(f"Batch API not supported for provider {llm_config.provider}, falling back to sync mode")
return await extract_facts_from_contents(contents, llm_config, agent_name, config, pool, operation_id, schema)
# Check if we're resuming an existing batch (crash recovery)
batch_id = None
if operation_id and pool:
from ..task_backend import fq_table
table = fq_table("async_operations", schema)
row = await pool.fetchrow(
f"SELECT result_metadata FROM {table} WHERE operation_id = $1",
operation_id,
)
if row and row["result_metadata"]:
metadata = row["result_metadata"]
if isinstance(metadata, str):
metadata = json.loads(metadata)
batch_id = metadata.get("batch_id")
if batch_id:
logger.info(f"Resuming existing batch: batch_id={batch_id} (crash recovery)")
# Step 1: Chunk all contents and build batch requests (skip if resuming)
all_chunks_info = [] # List of (chunk_text, content_index, chunk_index_in_content, event_date, context)
batch_requests = []
# Build prompt and schema once (same for all chunks)
prompt, response_schema = _build_extraction_prompt_and_schema(config)
for content_index, item in enumerate(contents):
chunks = chunk_text(item.content, max_chars=config.retain_chunk_size)
for chunk_index_in_content, chunk in enumerate(chunks):
all_chunks_info.append((chunk, content_index, chunk_index_in_content, item.event_date, item.context))
# Build batch request for this chunk
custom_id = f"chunk_{len(all_chunks_info) - 1}" # Global chunk index
# Build user message using helper function
user_message = _build_user_message(
chunk, chunk_index_in_content, len(chunks), item.event_date, item.context
)
# Build request body using helper function
request_body = _build_request_body(llm_config, config, prompt, user_message, response_schema)
batch_requests.append(
{"custom_id": custom_id, "method": "POST", "url": "/v1/chat/completions", "body": request_body}
)
if not batch_requests and not batch_id: # No requests and not resuming
return [], [], TokenUsage()
# Step 2: Submit batch (skip if resuming)
if not batch_id:
logger.info(f"Submitting batch with {len(batch_requests)} chunk requests")
batch_metadata = await llm_config._provider_impl.submit_batch(batch_requests)
batch_id = batch_metadata["batch_id"]
logger.info(f"Batch submitted: {batch_id}, polling every {config.retain_batch_poll_interval_seconds}s")
# CRITICAL: Store minimal batch state in operation metadata for crash recovery
# This allows resuming polling if worker restarts
if operation_id and pool:
batch_state = {
"batch_id": batch_id,
"batch_provider": llm_config.provider,
"chunk_count": len(batch_requests),
}
# Update operation result_metadata
from ..task_backend import fq_table
table = fq_table("async_operations", schema)
await pool.execute(
f"""
UPDATE {table}
SET result_metadata = result_metadata || $1::jsonb, updated_at = now()
WHERE operation_id = $2
""",
json.dumps(batch_state),
operation_id,
)
logger.info(f"Stored batch state for operation {operation_id} (crash recovery enabled)")
else:
logger.info(f"Resuming polling for existing batch: {batch_id}")
# Step 3: Poll until complete
import time
start_time = time.time()
while True:
status_info = await llm_config._provider_impl.get_batch_status(batch_id)
status = status_info["status"]
elapsed = time.time() - start_time
logger.info(
f"Batch {batch_id}: status={status}, "
f"completed={status_info['request_counts']['completed']}/{status_info['request_counts']['total']}, "
f"elapsed={elapsed:.0f}s"
)
if status == "completed":
break
elif status in ("failed", "expired", "cancelled"):
error_msg = status_info.get("errors", "Unknown error")
raise RuntimeError(f"Batch {batch_id} failed with status {status}: {error_msg}")
# Wait before polling again
await asyncio.sleep(config.retain_batch_poll_interval_seconds)
logger.info(f"Batch {batch_id} completed in {elapsed:.0f}s, retrieving results")
# Step 4: Retrieve results
batch_results = await llm_config._provider_impl.retrieve_batch_results(batch_id)
# Map results by custom_id
results_by_id = {result["custom_id"]: result for result in batch_results}
# Step 5: Parse results into facts (same as sync mode)
all_facts_from_llm = []
chunks_metadata = []
total_usage = TokenUsage()
for chunk_idx, (chunk_content, content_index, chunk_index_in_content, event_date, context) in enumerate(
all_chunks_info
):
custom_id = f"chunk_{chunk_idx}"
result = results_by_id.get(custom_id)
if not result:
logger.warning(f"Missing result for {custom_id}, skipping")
chunks_metadata.append(
ChunkMetadata(
chunk_text=chunk_content, fact_count=0, content_index=content_index, chunk_index=chunk_idx
)
)
continue
# Check for errors
if result.get("error"):
logger.error(f"Error in {custom_id}: {result['error']}")
chunks_metadata.append(
ChunkMetadata(
chunk_text=chunk_content, fact_count=0, content_index=content_index, chunk_index=chunk_idx
)
)
continue
# Extract response
response_body = result.get("response", {}).get("body", {})
choices = response_body.get("choices", [])
if not choices:
logger.warning(f"No choices in response for {custom_id}")
chunks_metadata.append(
ChunkMetadata(
chunk_text=chunk_content, fact_count=0, content_index=content_index, chunk_index=chunk_idx
)
)
continue
# Parse JSON content
message = choices[0].get("message", {})
content_str = message.get("content", "{}")
try:
extraction_response_json = json.loads(content_str)
except json.JSONDecodeError as e:
logger.error(f"Failed to parse JSON for {custom_id}: {e}")
chunks_metadata.append(
ChunkMetadata(
chunk_text=chunk_content, fact_count=0, content_index=content_index, chunk_index=chunk_idx
)
)
continue
# Parse facts (reuse existing logic from _extract_facts_from_chunk)
raw_facts = extraction_response_json.get("facts", [])
chunk_facts = []
for i, llm_fact in enumerate(raw_facts):
if not isinstance(llm_fact, dict):
continue
def get_value(field_name):
value = llm_fact.get(field_name)
if value and value != "" and value != [] and value != {} and str(value).upper() != "N/A":
return value
return None
what = get_value("what")
if not what:
what = get_value("factual_core")
if not what:
continue
when = get_value("when")
who = get_value("who")
why = get_value("why")
# Critical field: fact_type
original_fact_type = llm_fact.get("fact_type")
fact_type = original_fact_type
# Convert "assistant" → "experience"
if fact_type == "assistant":
fact_type = "experience"
# Validate fact_type
if fact_type not in ["world", "experience", "opinion"]:
fact_kind = llm_fact.get("fact_kind")
if fact_kind == "assistant":
fact_type = "experience"
elif fact_kind in ["world", "experience", "opinion"]:
fact_type = fact_kind
else:
fact_type = "world"
# Build combined fact text
combined_parts = [what]
if when:
combined_parts.append(f"When: {when}")
if who:
combined_parts.append(f"Involving: {who}")
if why:
combined_parts.append(why)
combined_text = " | ".join(combined_parts)
# Temporal fields
fact_data = {}
fact_kind = llm_fact.get("fact_kind", "conversation")
if fact_kind not in ["conversation", "event", "other"]:
fact_kind = "conversation"
if fact_kind == "event":
occurred_start = get_value("occurred_start")
occurred_end = get_value("occurred_end")
if not occurred_start:
fact_data["occurred_start"] = _infer_temporal_date(combined_text, event_date)
else:
fact_data["occurred_start"] = occurred_start
if occurred_end:
fact_data["occurred_end"] = occurred_end
elif fact_data.get("occurred_start"):
fact_data["occurred_end"] = fact_data["occurred_start"]
# Entities
entities = get_value("entities")
if entities:
validated_entities = []
for ent in entities:
if isinstance(ent, str):
validated_entities.append(Entity(text=ent))
elif isinstance(ent, dict) and "text" in ent:
try:
validated_entities.append(Entity.model_validate(ent))
except Exception:
pass
if validated_entities:
fact_data["entities"] = validated_entities
# Causal relations
if extract_causal_links:
validated_relations = []
causal_relations_raw = get_value("causal_relations")
if causal_relations_raw:
for rel in causal_relations_raw:
if not isinstance(rel, dict):
continue
target_idx = rel.get("target_index")
relation_type = rel.get("relation_type")
strength = rel.get("strength", 1.0)
if target_idx is None or relation_type is None:
continue
if target_idx < 0 or target_idx >= i:
continue
try:
validated_relations.append(
CausalRelation(
target_fact_index=target_idx, relation_type=relation_type, strength=strength
)
)
except Exception:
pass
if validated_relations:
fact_data["causal_relations"] = validated_relations
# Always set mentioned_at
fact_data["mentioned_at"] = event_date.isoformat()
try:
fact = Fact(fact=combined_text, fact_type=fact_type, **fact_data)
chunk_facts.append(fact)
except Exception as e:
logger.error(f"Failed to create Fact model for fact {i}: {e}")
continue
all_facts_from_llm.extend(chunk_facts)
chunks_metadata.append(
ChunkMetadata(
chunk_text=chunk_content,
fact_count=len(chunk_facts),
content_index=content_index,
chunk_index=chunk_idx,
)
)
# Track token usage
usage_data = response_body.get("usage", {})
if usage_data:
total_usage = total_usage + TokenUsage(
input_tokens=usage_data.get("prompt_tokens", 0),
output_tokens=usage_data.get("completion_tokens", 0),
total_tokens=usage_data.get("total_tokens", 0),
)
# Step 6: Convert to ExtractedFact objects with proper chunk mapping
# Group facts by chunk
facts_by_chunk = [] # List of (chunk_metadata, [facts])
fact_start_idx = 0
for chunk_meta in chunks_metadata:
chunk_facts = all_facts_from_llm[fact_start_idx : fact_start_idx + chunk_meta.fact_count]
facts_by_chunk.append((chunk_meta, chunk_facts))
fact_start_idx += chunk_meta.fact_count
# Now convert to ExtractedFactType
extracted_facts = []
global_fact_idx = 0
for chunk_meta, chunk_facts in facts_by_chunk:
content = contents[chunk_meta.content_index]
for fact_from_llm in chunk_facts:
extracted_fact = ExtractedFactType(
fact_text=fact_from_llm.fact,
fact_type=fact_from_llm.fact_type,
entities=[e.text for e in (fact_from_llm.entities or [])],
occurred_start=_parse_datetime(fact_from_llm.occurred_start) if fact_from_llm.occurred_start else None,
occurred_end=_parse_datetime(fact_from_llm.occurred_end) if fact_from_llm.occurred_end else None,
causal_relations=_convert_causal_relations(fact_from_llm.causal_relations or [], global_fact_idx),
content_index=chunk_meta.content_index,
chunk_index=chunk_meta.chunk_index,
context=content.context,
mentioned_at=content.event_date,
metadata=content.metadata,
tags=content.tags,
)
extracted_facts.append(extracted_fact)
global_fact_idx += 1
# Step 7: Add temporal offsets
_add_temporal_offsets(extracted_facts, contents)
logger.info(f"Batch API extracted {len(extracted_facts)} facts from {len(all_chunks_info)} chunks")
return extracted_facts, chunks_metadata, total_usage
async def extract_facts_from_contents(
contents: list[RetainContent],
llm_config,
agent_name: str,
config,
pool=None,
operation_id: str | None = None,
schema: str | None = None,
contents: list[RetainContent], llm_config, agent_name: str, config
) -> tuple[list[ExtractedFactType], list[ChunkMetadata], TokenUsage]:
"""
Extract facts from multiple content items in parallel.
@@ -1702,16 +1257,11 @@ async def extract_facts_from_contents(
3. Adds time offsets to preserve fact ordering within each content
4. Returns typed ExtractedFact and ChunkMetadata objects
Routes to batch API mode if config.retain_batch_enabled=True.
Args:
contents: List of RetainContent objects to process
llm_config: LLM configuration for fact extraction
agent_name: Name of the agent (for agent-related fact detection)
config: Resolved HindsightConfig for this bank
pool: Database connection pool (passed to batch API for state storage)
operation_id: Async operation ID (passed to batch API for crash recovery)
schema: Database schema (passed to batch API for multi-tenant support)
Returns:
Tuple of (extracted_facts, chunks_metadata, usage)
@@ -1719,12 +1269,6 @@ async def extract_facts_from_contents(
if not contents:
return [], [], TokenUsage()
# Route to batch API if enabled
if config.retain_batch_enabled:
return await extract_facts_from_contents_batch_api(
contents, llm_config, agent_name, config, pool, operation_id, schema
)
# Step 1: Create parallel fact extraction tasks
fact_extraction_tasks = []
for item in contents:
@@ -82,8 +82,6 @@ async def retain_batch(
fact_type_override: str | None = None,
confidence_score: float | None = None,
document_tags: list[str] | None = None,
operation_id: str | None = None,
schema: str | None = None,
) -> tuple[list[list[str]], TokenUsage]:
"""
Process a batch of content through the retain pipeline.
@@ -149,7 +147,7 @@ async def retain_batch(
step_start = time.time()
extracted_facts, chunks, usage = await fact_extraction.extract_facts_from_contents(
contents, llm_config, agent_name, config, pool, operation_id, schema
contents, llm_config, agent_name, config
)
log_buffer.append(
f"[1] Extract facts: {len(extracted_facts)} facts, {len(chunks)} chunks from {len(contents)} contents in {time.time() - step_start:.3f}s"
@@ -1,77 +0,0 @@
"""File storage backends for uploaded files."""
from collections.abc import Callable
from .base import FileStorage
from .postgresql import PostgreSQLFileStorage
__all__ = ["FileStorage", "PostgreSQLFileStorage", "create_file_storage"]
def create_file_storage(
storage_type: str,
pool_getter: Callable | None = None,
schema: str | None = None,
**kwargs,
) -> FileStorage:
"""
Create file storage backend based on configuration.
Args:
storage_type: "native" (PostgreSQL BYTEA) or "s3" (S3-compatible object storage)
pool_getter: Database pool getter (required for native)
schema: Database schema (for native multi-tenant)
**kwargs: Additional args passed to storage backend
Returns:
FileStorage instance
Raises:
ValueError: If storage_type is unknown or required args are missing
"""
if storage_type == "native":
if not pool_getter:
raise ValueError("pool_getter required for native (PostgreSQL) storage")
return PostgreSQLFileStorage(pool_getter=pool_getter, schema=schema)
elif storage_type == "s3":
from ...config import get_config
from .s3 import S3FileStorage
config = get_config()
bucket = config.file_storage_s3_bucket
if not bucket:
raise ValueError("HINDSIGHT_API_FILE_STORAGE_S3_BUCKET is required for S3 storage")
return S3FileStorage(
bucket=bucket,
region=config.file_storage_s3_region,
endpoint=config.file_storage_s3_endpoint,
access_key_id=config.file_storage_s3_access_key_id,
secret_access_key=config.file_storage_s3_secret_access_key,
)
elif storage_type == "gcs":
from ...config import get_config
from .gcs import GCSFileStorage
config = get_config()
bucket = config.file_storage_gcs_bucket
if not bucket:
raise ValueError("HINDSIGHT_API_FILE_STORAGE_GCS_BUCKET is required for GCS storage")
return GCSFileStorage(
bucket=bucket,
service_account_key=config.file_storage_gcs_service_account_key,
)
elif storage_type == "azure":
from ...config import get_config
from .azure import AzureFileStorage
config = get_config()
container = config.file_storage_azure_container
if not container:
raise ValueError("HINDSIGHT_API_FILE_STORAGE_AZURE_CONTAINER is required for Azure storage")
return AzureFileStorage(
container_name=container,
account_name=config.file_storage_azure_account_name,
account_key=config.file_storage_azure_account_key,
)
else:
raise ValueError(f"Unknown storage type: {storage_type}. Supported: 'native', 's3', 'gcs', 'azure'.")
@@ -1,62 +0,0 @@
"""Azure Blob Storage backend using obstore."""
import logging
from datetime import timedelta
import obstore as obs
from obstore.store import AzureStore
from .base import FileStorage
logger = logging.getLogger(__name__)
class AzureFileStorage(FileStorage):
"""
Azure Blob Storage backend.
Uses obstore (Rust-backed) for high-throughput async access to Azure Blob Storage.
Supports account key, SAS token, and default Azure credentials.
"""
def __init__(
self,
container_name: str,
account_name: str | None = None,
account_key: str | None = None,
):
kwargs: dict = {}
if account_name:
kwargs["account_name"] = account_name
if account_key:
kwargs["account_key"] = account_key
self._store = AzureStore(container_name, **kwargs)
logger.info(f"Initialized Azure file storage: container={container_name}, account={account_name}")
async def store(self, file_data: bytes, key: str, metadata: dict[str, str] | None = None) -> str:
await obs.put_async(self._store, key, file_data)
logger.debug(f"Stored file {key} ({len(file_data)} bytes) in Azure")
return key
async def retrieve(self, key: str) -> bytes:
try:
response = await obs.get_async(self._store, key)
return await response.bytes_async()
except Exception as e:
if "not found" in str(e).lower() or "BlobNotFound" in str(e):
raise FileNotFoundError(f"File not found: {key}") from e
raise
async def delete(self, key: str) -> None:
await obs.delete_async(self._store, key)
async def exists(self, key: str) -> bool:
try:
await obs.head_async(self._store, key)
return True
except Exception:
return False
async def get_download_url(self, key: str, expires_in: int = 3600) -> str:
return await obs.sign_async(self._store, "GET", key, timedelta(seconds=expires_in))
@@ -1,83 +0,0 @@
"""Abstract base class for file storage backends."""
from abc import ABC, abstractmethod
class FileStorage(ABC):
"""Abstract base for file storage backends."""
@abstractmethod
async def store(
self,
file_data: bytes,
key: str,
metadata: dict[str, str] | None = None,
) -> str:
"""
Store file and return storage key.
Args:
file_data: Raw file bytes
key: Storage key (e.g., "banks/{bank_id}/files/{file_id}.pdf")
metadata: Optional metadata to store with file
Returns:
Storage key that can be used to retrieve the file
"""
pass
@abstractmethod
async def retrieve(self, key: str) -> bytes:
"""
Retrieve file by storage key.
Args:
key: Storage key
Returns:
File data as bytes
Raises:
FileNotFoundError: If file does not exist
"""
pass
@abstractmethod
async def delete(self, key: str) -> None:
"""
Delete file by storage key.
Args:
key: Storage key
"""
pass
@abstractmethod
async def exists(self, key: str) -> bool:
"""
Check if file exists.
Args:
key: Storage key
Returns:
True if file exists, False otherwise
"""
pass
@abstractmethod
async def get_download_url(self, key: str, expires_in: int = 3600) -> str:
"""
Get a URL for downloading the file.
For PostgreSQL storage, this might be a relative API path.
For S3, this would be a pre-signed URL.
Args:
key: Storage key
expires_in: Expiration time in seconds (may be ignored for some backends)
Returns:
Download URL or path
"""
pass
@@ -1,59 +0,0 @@
"""Google Cloud Storage backend using obstore."""
import logging
from datetime import timedelta
import obstore as obs
from obstore.store import GCSStore
from .base import FileStorage
logger = logging.getLogger(__name__)
class GCSFileStorage(FileStorage):
"""
Google Cloud Storage backend.
Uses obstore (Rust-backed) for high-throughput async access to GCS.
Supports Application Default Credentials, service account keys, and explicit credentials.
"""
def __init__(
self,
bucket: str,
service_account_key: str | None = None,
):
kwargs: dict = {}
if service_account_key:
kwargs["service_account_key"] = service_account_key
self._store = GCSStore(bucket, **kwargs)
logger.info(f"Initialized GCS file storage: bucket={bucket}")
async def store(self, file_data: bytes, key: str, metadata: dict[str, str] | None = None) -> str:
await obs.put_async(self._store, key, file_data)
logger.debug(f"Stored file {key} ({len(file_data)} bytes) in GCS")
return key
async def retrieve(self, key: str) -> bytes:
try:
response = await obs.get_async(self._store, key)
return await response.bytes_async()
except Exception as e:
if "not found" in str(e).lower():
raise FileNotFoundError(f"File not found: {key}") from e
raise
async def delete(self, key: str) -> None:
await obs.delete_async(self._store, key)
async def exists(self, key: str) -> bool:
try:
await obs.head_async(self._store, key)
return True
except Exception:
return False
async def get_download_url(self, key: str, expires_in: int = 3600) -> str:
return await obs.sign_async(self._store, "GET", key, timedelta(seconds=expires_in))
@@ -1,139 +0,0 @@
"""PostgreSQL BYTEA-based file storage (default, zero-config)."""
import logging
from collections.abc import Callable
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import asyncpg
from .base import FileStorage
logger = logging.getLogger(__name__)
def fq_table(table: str, schema: str | None = None) -> str:
"""Get fully-qualified table name with optional schema prefix."""
if schema:
return f'"{schema}".{table}'
return table
class PostgreSQLFileStorage(FileStorage):
"""
PostgreSQL BYTEA-based file storage.
Stores files directly in PostgreSQL using BYTEA columns.
This is the default storage backend - zero configuration required!
Pros:
- Works out of the box (no external dependencies)
- Transactional consistency with database
- Simple backups (included in pg_dump)
- Good performance for <10MB files
Cons:
- Database bloat for large/many files
- Not ideal for distributed deployments
- Higher cost than object storage at scale
For production/scale, consider S3FileStorage instead.
"""
def __init__(self, pool_getter: Callable[[], "asyncpg.Pool"], schema: str | None = None):
"""
Initialize PostgreSQL file storage.
Args:
pool_getter: Function that returns asyncpg connection pool
schema: Database schema (for multi-tenant support)
"""
self._pool_getter = pool_getter
self._schema = schema
async def store(
self,
file_data: bytes,
key: str,
metadata: dict[str, str] | None = None,
) -> str:
"""Store file in PostgreSQL."""
pool = self._pool_getter()
async with pool.acquire() as conn:
await conn.execute(
f"""
INSERT INTO {fq_table("file_storage", self._schema)}
(storage_key, data)
VALUES ($1, $2)
ON CONFLICT (storage_key) DO UPDATE SET
data = EXCLUDED.data
""",
key,
file_data,
)
logger.debug(f"Stored file {key} ({len(file_data)} bytes) in PostgreSQL")
return key
async def retrieve(self, key: str) -> bytes:
"""Retrieve file from PostgreSQL."""
pool = self._pool_getter()
async with pool.acquire() as conn:
row = await conn.fetchrow(
f"""
SELECT data FROM {fq_table("file_storage", self._schema)}
WHERE storage_key = $1
""",
key,
)
if not row:
raise FileNotFoundError(f"File not found: {key}")
return bytes(row["data"])
async def delete(self, key: str) -> None:
"""Delete file from PostgreSQL."""
pool = self._pool_getter()
async with pool.acquire() as conn:
result = await conn.execute(
f"""
DELETE FROM {fq_table("file_storage", self._schema)}
WHERE storage_key = $1
""",
key,
)
# Check if anything was deleted
if result == "DELETE 0":
logger.warning(f"Attempted to delete non-existent file: {key}")
async def exists(self, key: str) -> bool:
"""Check if file exists in PostgreSQL."""
pool = self._pool_getter()
async with pool.acquire() as conn:
row = await conn.fetchrow(
f"""
SELECT 1 FROM {fq_table("file_storage", self._schema)}
WHERE storage_key = $1
""",
key,
)
return row is not None
async def get_download_url(self, key: str, expires_in: int = 3600) -> str:
"""
Get download URL for PostgreSQL-stored file.
Returns an API endpoint path (not a pre-signed URL since the file
is stored in the database). The expires_in parameter is ignored
for PostgreSQL storage.
"""
# Return API path for download endpoint
# (expires_in ignored for database storage - auth handled at API level)
return f"/v1/default/files/download/{key}"
@@ -1,71 +0,0 @@
"""S3 object storage backend using obstore."""
import logging
from datetime import timedelta
import obstore as obs
from obstore.store import S3Store
from .base import FileStorage
logger = logging.getLogger(__name__)
class S3FileStorage(FileStorage):
"""
S3-compatible object storage backend.
Uses obstore (Rust-backed) for high-throughput async access to
Amazon S3, MinIO, Cloudflare R2, and other S3-compliant APIs.
"""
def __init__(
self,
bucket: str,
region: str | None = None,
endpoint: str | None = None,
access_key_id: str | None = None,
secret_access_key: str | None = None,
):
kwargs: dict = {}
if region:
kwargs["region"] = region
if endpoint:
kwargs["endpoint"] = endpoint
# Allow plain HTTP for local S3-compatible services (MinIO, LocalStack, etc.)
if endpoint.startswith("http://"):
kwargs["allow_http"] = True
if access_key_id:
kwargs["access_key_id"] = access_key_id
if secret_access_key:
kwargs["secret_access_key"] = secret_access_key
self._store = S3Store(bucket, **kwargs)
logger.info(f"Initialized S3 file storage: bucket={bucket}, region={region}, endpoint={endpoint}")
async def store(self, file_data: bytes, key: str, metadata: dict[str, str] | None = None) -> str:
await obs.put_async(self._store, key, file_data)
logger.debug(f"Stored file {key} ({len(file_data)} bytes) in S3")
return key
async def retrieve(self, key: str) -> bytes:
try:
response = await obs.get_async(self._store, key)
return await response.bytes_async()
except Exception as e:
if "not found" in str(e).lower() or "NoSuchKey" in str(e):
raise FileNotFoundError(f"File not found: {key}") from e
raise
async def delete(self, key: str) -> None:
await obs.delete_async(self._store, key)
async def exists(self, key: str) -> bool:
try:
await obs.head_async(self._store, key)
return True
except Exception:
return False
async def get_download_url(self, key: str, expires_in: int = 3600) -> str:
return await obs.sign_async(self._store, "GET", key, timedelta(seconds=expires_in))
-24
View File
@@ -166,8 +166,6 @@ def main():
llm_initial_backoff=config.llm_initial_backoff,
llm_max_backoff=config.llm_max_backoff,
llm_timeout=config.llm_timeout,
llm_groq_service_tier=config.llm_groq_service_tier,
llm_openai_service_tier=config.llm_openai_service_tier,
llm_vertexai_project_id=config.llm_vertexai_project_id,
llm_vertexai_region=config.llm_vertexai_region,
llm_vertexai_service_account_key=config.llm_vertexai_service_account_key,
@@ -247,27 +245,6 @@ def main():
retain_extract_causal_links=config.retain_extract_causal_links,
retain_extraction_mode=config.retain_extraction_mode,
retain_custom_instructions=config.retain_custom_instructions,
retain_batch_tokens=config.retain_batch_tokens,
retain_batch_enabled=config.retain_batch_enabled,
retain_batch_poll_interval_seconds=config.retain_batch_poll_interval_seconds,
file_storage_type=config.file_storage_type,
file_storage_s3_bucket=config.file_storage_s3_bucket,
file_storage_s3_region=config.file_storage_s3_region,
file_storage_s3_endpoint=config.file_storage_s3_endpoint,
file_storage_s3_access_key_id=config.file_storage_s3_access_key_id,
file_storage_s3_secret_access_key=config.file_storage_s3_secret_access_key,
file_storage_gcs_bucket=config.file_storage_gcs_bucket,
file_storage_gcs_service_account_key=config.file_storage_gcs_service_account_key,
file_storage_azure_container=config.file_storage_azure_container,
file_storage_azure_account_name=config.file_storage_azure_account_name,
file_storage_azure_account_key=config.file_storage_azure_account_key,
file_parser=config.file_parser,
file_parser_iris_token=config.file_parser_iris_token,
file_parser_iris_org_id=config.file_parser_iris_org_id,
file_conversion_max_batch_size_mb=config.file_conversion_max_batch_size_mb,
file_conversion_max_batch_size=config.file_conversion_max_batch_size,
enable_file_upload_api=config.enable_file_upload_api,
file_delete_after_retain=config.file_delete_after_retain,
enable_observations=config.enable_observations,
consolidation_batch_size=config.consolidation_batch_size,
consolidation_max_tokens=config.consolidation_max_tokens,
@@ -369,7 +346,6 @@ def main():
"proxy_headers": args.proxy_headers,
"ws": "wsproto", # Use wsproto instead of websockets to avoid deprecation warnings
"loop": loop_impl, # Explicitly set event loop implementation
"timeout_keep_alive": 30, # Exceed aiohttp's 15s client timeout so the client always closes first
}
# Add optional parameters if provided
+11 -29
View File
@@ -42,38 +42,30 @@ def _detect_vector_extension(conn, vector_extension: str = "pgvector") -> str:
vector_extension: Configured extension ("pgvector", "vchord", or "pgvectorscale")
Returns:
"pgvector", "vchord", "pgvectorscale", or "pg_diskann"
"pgvector", "vchord", or "pgvectorscale"
Raises:
RuntimeError: If configured extension is not installed
"""
# Verify the configured extension is installed
if vector_extension == "pgvectorscale":
# pgvectorscale/DiskANN requires pgvector to be installed first
# pgvectorscale requires pgvector to be installed first
pgvector_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vector'")).scalar()
if not pgvector_check:
raise RuntimeError(
"DiskANN (pgvectorscale/pg_diskann) requires pgvector to be installed. "
"Install it with: CREATE EXTENSION vector; then CREATE EXTENSION vectorscale CASCADE; (or pg_diskann on Azure)"
"pgvectorscale requires pgvector to be installed. "
"Install it with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
# Check for either vectorscale (open source) or pg_diskann (Azure)
# Check for vectorscale extension
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
pg_diskann_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'pg_diskann'")).scalar()
if vectorscale_check:
logger.debug("Using vector extension: pgvectorscale (DiskANN)")
return "pgvectorscale"
elif pg_diskann_check:
logger.debug("Using vector extension: pg_diskann (Azure DiskANN)")
return "pg_diskann" # Return distinct name for parameter handling
else:
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. "
"Install either:\n"
" - pgvectorscale (open source): CREATE EXTENSION vectorscale CASCADE;\n"
" - pg_diskann (Azure): CREATE EXTENSION pg_diskann CASCADE;"
"Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
logger.debug("Using configured vector extension: pgvectorscale (DiskANN)")
return "pgvectorscale"
elif vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
@@ -617,7 +609,7 @@ def ensure_vector_extension(
]
# Determine target index type
if target_ext in ("pgvectorscale", "pg_diskann"):
if target_ext == "pgvectorscale":
target_index_type = "diskann"
elif target_ext == "vchord":
target_index_type = "vchordrq"
@@ -721,7 +713,7 @@ def ensure_vector_extension(
# Create new index with appropriate type
if target_ext == "pgvectorscale":
logger.info(f"Creating DiskANN index on {table_name} (pgvectorscale)")
logger.info(f"Creating DiskANN index on {table_name}")
conn.execute(
text(f"""
CREATE INDEX IF NOT EXISTS {index_name}
@@ -730,16 +722,6 @@ def ensure_vector_extension(
WITH (num_neighbors = 50)
""")
)
elif target_ext == "pg_diskann":
logger.info(f"Creating DiskANN index on {table_name} (pg_diskann/Azure)")
conn.execute(
text(f"""
CREATE INDEX IF NOT EXISTS {index_name}
ON {schema_name}.{table_name}
USING diskann (embedding vector_cosine_ops)
WITH (max_neighbors = 50)
""")
)
elif target_ext == "vchord":
logger.info(f"Creating vchordrq index on {table_name}")
conn.execute(
+7 -93
View File
@@ -376,12 +376,7 @@ class WorkerPoller:
del self._in_flight_by_type[operation_type]
async def _execute_task_inner(self, task: ClaimedTask):
"""Inner task execution with error handling.
Note: The executor (MemoryEngine.execute_task) handles status marking internally
(marking operations as completed/failed and handling retries). This method should
NOT override those status updates.
"""
"""Inner task execution with error handling."""
task_type = task.task_dict.get("type", "unknown")
bank_id = task.task_dict.get("bank_id", "unknown")
@@ -391,12 +386,12 @@ class WorkerPoller:
if task.schema:
task.task_dict["_schema"] = task.schema
await self._executor(task.task_dict)
logger.debug(f"Task {task.operation_id} execution finished")
await self._mark_completed(task.operation_id, task.schema)
logger.debug(f"Task {task.operation_id} completed successfully")
except Exception as e:
# The executor should handle its own errors, but if an unexpected exception
# propagates (e.g., from schema setup), log it as a warning
logger.error(f"Task {task.operation_id} raised unexpected exception: {e}")
traceback.print_exc()
error_msg = f"{type(e).__name__}: {e}\n{traceback.format_exc()}"
logger.error(f"Task {task.operation_id} failed: {e}")
await self._retry_or_fail(task.operation_id, error_msg, task.schema)
async def recover_own_tasks(self) -> int:
"""
@@ -406,8 +401,6 @@ class WorkerPoller:
On startup, we reset any tasks stuck in 'processing' for this worker_id
back to 'pending' so they can be picked up again.
Also recovers batch API operations that were in-flight.
If tenant_extension is configured, recovers across all tenant schemas.
Returns:
@@ -420,16 +413,11 @@ class WorkerPoller:
try:
table = fq_table("async_operations", schema)
# First, recover batch API operations (before resetting worker tasks)
batch_count = await self._recover_batch_operations(schema)
total_count += batch_count
# Then reset normal worker tasks
result = await self._pool.execute(
f"""
UPDATE {table}
SET status = 'pending', worker_id = NULL, claimed_at = NULL, updated_at = now()
WHERE status = 'processing' AND worker_id = $1 AND result_metadata->>'batch_id' IS NULL
WHERE status = 'processing' AND worker_id = $1
""",
self._worker_id,
)
@@ -446,80 +434,6 @@ class WorkerPoller:
logger.info(f"Worker {self._worker_id} recovered {total_count} stale tasks from previous run")
return total_count
async def _recover_batch_operations(self, schema: str | None) -> int:
"""
Recover batch API operations that were in-flight when worker crashed.
Finds operations with batch_id in metadata and re-submits them as tasks
so polling can resume.
Args:
schema: Database schema to recover from
Returns:
Number of batch operations recovered
"""
table = fq_table("async_operations", schema)
try:
# Find operations with batch_id in metadata (batch API operations)
rows = await self._pool.fetch(
f"""
SELECT operation_id, task_payload, result_metadata
FROM {table}
WHERE status = 'processing'
AND result_metadata ? 'batch_id'
AND task_payload IS NOT NULL
"""
)
if not rows:
return 0
recovered = 0
for row in rows:
operation_id = str(row["operation_id"])
task_payload = row["task_payload"]
result_metadata = row["result_metadata"]
# Parse metadata
if isinstance(result_metadata, str):
result_metadata = json.loads(result_metadata)
batch_id = result_metadata.get("batch_id")
batch_provider = result_metadata.get("batch_provider", "openai")
logger.info(
f"Recovering batch operation: operation_id={operation_id}, batch_id={batch_id}, provider={batch_provider}"
)
# Parse task_payload
if isinstance(task_payload, str):
task_dict = json.loads(task_payload)
else:
task_dict = task_payload
# Mark operation as ready for re-processing
# Reset to pending with task_payload intact so worker picks it up again
await self._pool.execute(
f"""
UPDATE {table}
SET status = 'pending', worker_id = NULL, claimed_at = NULL, updated_at = now()
WHERE operation_id = $1
""",
operation_id,
)
recovered += 1
logger.info(f"Batch operation {operation_id} reset to pending for re-processing")
return recovered
except Exception as e:
schema_display = f'"{schema}"' if schema else str(schema)
logger.error(f"Failed to recover batch operations for schema {schema_display}: {e}")
return 0
async def run(self):
"""
Main polling loop with fire-and-forget task execution.
-4
View File
@@ -43,8 +43,6 @@ dependencies = [
"cohere>=5.0.0",
"flashrank>=0.2.0",
"litellm>=1.0.0",
"markitdown[pdf,docx,pptx,xlsx,xls]>=0.1.4", # File to markdown conversion
"obstore>=0.4.0", # S3/GCS/Azure object storage client (Rust-backed)
# Local ML models for embeddings/reranking - can be excluded in Docker with INCLUDE_LOCAL_MODELS=false
"sentence-transformers>=3.3.0",
"transformers>=4.53.0", # Security fixes for ReDoS vulnerabilities
@@ -67,7 +65,6 @@ test = [
"pytest-timeout>=2.4.0",
"pytest-xdist>=3.0.0",
"filelock>=3.20.1", # TOCTOU race condition fix
"testcontainers>=4.0.0",
]
[project.scripts]
@@ -117,7 +114,6 @@ dev = [
"filelock>=3.20.1", # TOCTOU race condition fix
"ruff>=0.8.0",
"ty>=0.0.1",
"testcontainers>=4.0.0",
]
[tool.ruff]
@@ -1,423 +0,0 @@
"""Test async batch retain with smart batching and parent-child operations."""
import asyncio
import json
import uuid
import pytest
from hindsight_api.extensions import RequestContext
@pytest.mark.asyncio
async def test_duplicate_document_ids_rejected_async(memory, request_context):
"""Test that async retain rejects batches with duplicate document_ids."""
bank_id = "test_duplicate_async"
contents = [
{"content": "First item", "document_id": "doc1"},
{"content": "Second item", "document_id": "doc2"},
{"content": "Third item", "document_id": "doc1"}, # Duplicate!
]
# Should raise ValueError due to duplicate document_ids
with pytest.raises(ValueError, match="duplicate document_ids.*doc1"):
await memory.submit_async_retain(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
@pytest.mark.asyncio
async def test_duplicate_document_ids_rejected_sync(memory, request_context):
"""Test that sync retain also rejects batches with duplicate document_ids."""
bank_id = "test_duplicate_sync"
contents = [
{"content": "First item", "document_id": "doc1"},
{"content": "Second item", "document_id": "doc1"}, # Duplicate!
]
# Should raise ValueError due to duplicate document_ids
with pytest.raises(ValueError, match="duplicate document_ids.*doc1"):
await memory.retain_batch_async(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
@pytest.mark.asyncio
async def test_small_async_batch_no_splitting(memory, request_context):
"""Test that small async batches create parent with single child (simplified code path)."""
bank_id = "test_small_async"
contents = [{"content": "Alice works at Google", "document_id": f"doc{i}"} for i in range(5)]
# Calculate total chars (should be well under threshold)
total_chars = sum(len(item["content"]) for item in contents)
assert total_chars < 10_000, "Test batch should be small"
# Submit async retain
result = await memory.submit_async_retain(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
# Verify we got an operation_id back
assert "operation_id" in result
assert "items_count" in result
assert result["items_count"] == 5
operation_id = result["operation_id"]
# Wait for task to complete (SyncTaskBackend executes immediately)
await asyncio.sleep(0.1)
# Check operation status
status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=operation_id,
request_context=request_context,
)
# Should be a parent operation with single child (simplified code path)
assert status["status"] == "completed"
assert status["operation_type"] == "batch_retain"
assert "child_operations" in status
assert status["result_metadata"]["num_sub_batches"] == 1 # Single sub-batch
assert len(status["child_operations"]) == 1
assert status["child_operations"][0]["status"] == "completed"
@pytest.mark.asyncio
async def test_large_async_batch_auto_splits(memory, request_context):
"""Test that large async batches automatically split into sub-batches with parent operation."""
from hindsight_api.engine.memory_engine import count_tokens
bank_id = "test_large_async"
# Create a large batch that exceeds the threshold (10k tokens default)
# Repeating "A"s gets heavily compressed by tokenizer, use varied content
# Use ~22k chars per item = ~5.5k tokens per item, 2 items = ~11k tokens total (exceeds 10k)
large_content = "The quick brown fox jumps over the lazy dog. " * 500 # ~22k chars = ~5.5k tokens
contents = [{"content": large_content + f" item {i}", "document_id": f"doc{i}"} for i in range(2)]
# Calculate total tokens (should exceed threshold)
total_tokens = sum(count_tokens(item["content"]) for item in contents)
assert total_tokens > 10_000, "Test batch should exceed threshold"
# Submit async retain
result = await memory.submit_async_retain(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
# Verify we got an operation_id back
assert "operation_id" in result
assert "items_count" in result
assert result["items_count"] == 2
parent_operation_id = result["operation_id"]
# Wait for tasks to complete
await asyncio.sleep(0.5)
# Check parent operation status
parent_status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=parent_operation_id,
request_context=request_context,
)
# Should be a parent operation with children
assert parent_status["operation_type"] == "batch_retain"
assert "child_operations" in parent_status
assert "num_sub_batches" in parent_status["result_metadata"]
assert parent_status["result_metadata"]["num_sub_batches"] >= 2 # Should split into at least 2 batches
assert parent_status["result_metadata"]["items_count"] == 2
# Verify child operations
child_ops = parent_status["child_operations"]
assert len(child_ops) >= 2, "Should have at least 2 child operations"
# All children should be completed (SyncTaskBackend executes immediately)
for child in child_ops:
assert child["status"] == "completed"
assert child["sub_batch_index"] is not None
assert child["items_count"] > 0
# Parent status should be aggregated as "completed"
assert parent_status["status"] == "completed"
@pytest.mark.asyncio
async def test_parent_operation_status_aggregation_pending(memory, request_context):
"""Test that parent operation shows 'pending' when children are pending."""
bank_id = "test_parent_pending"
pool = await memory._get_pool()
# Manually create a parent operation
parent_id = uuid.uuid4()
async with pool.acquire() as conn:
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
parent_id,
bank_id,
"batch_retain",
json.dumps({"items_count": 20, "num_sub_batches": 2, "is_parent": True}),
"pending",
)
# Create 2 child operations - one completed, one pending
child1_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
child1_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 1,
"total_sub_batches": 2,
}
),
"completed",
)
child2_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
child2_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 2,
"total_sub_batches": 2,
}
),
"pending",
)
# Check parent status
parent_status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=str(parent_id),
request_context=request_context,
)
# Parent should aggregate as "pending" since one child is still pending
assert parent_status["status"] == "pending"
assert len(parent_status["child_operations"]) == 2
@pytest.mark.asyncio
async def test_parent_operation_status_aggregation_failed(memory, request_context):
"""Test that parent operation shows 'failed' when any child fails."""
bank_id = "test_parent_failed"
pool = await memory._get_pool()
# Manually create a parent operation
parent_id = uuid.uuid4()
async with pool.acquire() as conn:
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
parent_id,
bank_id,
"batch_retain",
json.dumps({"items_count": 20, "num_sub_batches": 2, "is_parent": True}),
"pending",
)
# Create 2 child operations - one completed, one failed
child1_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
child1_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 1,
"total_sub_batches": 2,
}
),
"completed",
)
child2_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status, error_message)
VALUES ($1, $2, $3, $4, $5, $6)
""",
child2_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 2,
"total_sub_batches": 2,
}
),
"failed",
"Test error",
)
# Check parent status
parent_status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=str(parent_id),
request_context=request_context,
)
# Parent should aggregate as "failed" since one child failed
assert parent_status["status"] == "failed"
assert len(parent_status["child_operations"]) == 2
# Verify child with error is included
failed_child = [c for c in parent_status["child_operations"] if c["status"] == "failed"][0]
assert failed_child["error_message"] == "Test error"
@pytest.mark.asyncio
async def test_parent_operation_status_aggregation_completed(memory, request_context):
"""Test that parent operation shows 'completed' when all children are completed."""
bank_id = "test_parent_completed"
pool = await memory._get_pool()
# Manually create a parent operation
parent_id = uuid.uuid4()
async with pool.acquire() as conn:
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
parent_id,
bank_id,
"batch_retain",
json.dumps({"items_count": 20, "num_sub_batches": 2, "is_parent": True}),
"pending",
)
# Create 2 child operations - both completed
child1_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
child1_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 1,
"total_sub_batches": 2,
}
),
"completed",
)
child2_id = uuid.uuid4()
await conn.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
child2_id,
bank_id,
"retain",
json.dumps(
{
"items_count": 10,
"parent_operation_id": str(parent_id),
"sub_batch_index": 2,
"total_sub_batches": 2,
}
),
"completed",
)
# Check parent status
parent_status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=str(parent_id),
request_context=request_context,
)
# Parent should aggregate as "completed" since all children are completed
assert parent_status["status"] == "completed"
assert len(parent_status["child_operations"]) == 2
assert all(c["status"] == "completed" for c in parent_status["child_operations"])
@pytest.mark.asyncio
async def test_config_retain_batch_tokens_respected(memory, request_context):
"""Test that the retain_batch_tokens config setting is respected."""
from hindsight_api.config import get_config
from hindsight_api.engine.memory_engine import count_tokens
bank_id = "test_config_batch_tokens"
config = get_config()
# Check that config has the retain_batch_tokens setting
assert hasattr(config, "retain_batch_tokens")
assert config.retain_batch_tokens > 0
# Create a batch that's just under the threshold
# Use content that produces roughly half the token limit per item
content_size = config.retain_batch_tokens * 2 # chars (rough estimate: 1 token ~= 4 chars)
contents = [{"content": "A" * content_size, "document_id": f"doc{i}"} for i in range(2)]
total_tokens = sum(count_tokens(item["content"]) for item in contents)
# Should be equal to threshold (boundary case, no splitting since we use > not >=)
assert total_tokens <= config.retain_batch_tokens
# Submit - should NOT split
result = await memory.submit_async_retain(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
# Wait for completion
await asyncio.sleep(0.1)
# Check status - should be a parent with single child (even for small batches)
status = await memory.get_operation_status(
bank_id=bank_id,
operation_id=result["operation_id"],
request_context=request_context,
)
# Even small batches use parent-child pattern now (simpler code path)
assert "child_operations" in status
assert status["result_metadata"]["num_sub_batches"] == 1
+2 -25
View File
@@ -1,6 +1,6 @@
"""Unit tests for async retain tag propagation."""
from unittest.mock import AsyncMock, MagicMock
from unittest.mock import AsyncMock
import pytest
@@ -12,23 +12,9 @@ from hindsight_api.models import RequestContext
async def test_submit_async_retain_includes_document_tags_in_task_payload():
"""submit_async_retain should include document_tags in queued task payload."""
engine = MemoryEngine.__new__(MemoryEngine)
engine._initialized = True
engine._authenticate_tenant = AsyncMock()
engine._submit_async_operation = AsyncMock(return_value={"operation_id": "op-1"})
# Mock the pool and connection for parent operation creation
mock_conn = AsyncMock()
mock_conn.execute = AsyncMock()
mock_conn.transaction = MagicMock()
mock_conn.transaction.return_value.__aenter__ = AsyncMock()
mock_conn.transaction.return_value.__aexit__ = AsyncMock()
mock_pool = AsyncMock()
mock_pool.acquire = AsyncMock(return_value=mock_conn)
mock_pool.release = AsyncMock()
engine._get_pool = AsyncMock(return_value=mock_pool)
request_context = RequestContext(tenant_id="tenant-a", api_key_id="key-a")
contents = [{"content": "Async retain payload test."}]
document_tags = ["scope:tools", "user:alice"]
@@ -41,18 +27,10 @@ async def test_submit_async_retain_includes_document_tags_in_task_payload():
request_context=request_context,
)
# Check result structure
assert "operation_id" in result
assert "items_count" in result
assert result["items_count"] == 1
# Verify authentication was called
assert result == {"operation_id": "op-1", "items_count": 1}
engine._authenticate_tenant.assert_awaited_once_with(request_context)
# Verify child operation was submitted
engine._submit_async_operation.assert_awaited_once()
# Verify child operation payload contains document_tags
kwargs = engine._submit_async_operation.await_args.kwargs
assert kwargs["bank_id"] == "bank-1"
assert kwargs["operation_type"] == "retain"
@@ -67,7 +45,6 @@ async def test_submit_async_retain_includes_document_tags_in_task_payload():
async def test_handle_batch_retain_forwards_document_tags_to_retain_batch_async():
"""Worker handler should forward document_tags from task payload."""
engine = MemoryEngine.__new__(MemoryEngine)
engine._initialized = True
engine.retain_batch_async = AsyncMock(return_value={"items_count": 1})
task_dict = {
-508
View File
@@ -1,508 +0,0 @@
"""
Test OpenAI Batch API integration for retain fact extraction.
Tests cover:
- Normal batch API flow (submit, poll, complete)
- Crash recovery (resume from existing batch_id)
- Provider fallback (when batch API not supported)
- Worker recovery on restart
"""
import pytest
import asyncio
import logging
import json
import uuid
from datetime import datetime, timezone
from unittest.mock import AsyncMock, MagicMock, patch
from hindsight_api import RequestContext
from hindsight_api.engine.retain.fact_extraction import (
extract_facts_from_contents_batch_api,
extract_facts_from_contents,
RetainContent,
)
from hindsight_api.config import HindsightConfig
from hindsight_api.engine.llm_wrapper import create_llm_provider
from hindsight_api.worker.poller import WorkerPoller
logger = logging.getLogger(__name__)
@pytest.fixture
def mock_llm_config():
"""Create a mock LLM config with batch API support."""
mock = MagicMock()
mock.provider = "openai"
mock.model = "gpt-4o-mini"
mock._provider_impl = AsyncMock()
return mock
@pytest.fixture
def test_contents():
"""Create test content for fact extraction."""
return [
RetainContent(
content="Alice is a senior software engineer at TechCorp. She specializes in distributed systems.",
event_date=datetime(2024, 1, 15, tzinfo=timezone.utc),
context="team overview",
),
RetainContent(
content="Bob joined the team last month as a junior developer. He is learning React.",
event_date=datetime(2024, 1, 15, tzinfo=timezone.utc),
context="team overview",
),
]
@pytest.fixture
def hindsight_config():
"""Create test config with batch API enabled."""
config = HindsightConfig.from_env()
config.retain_batch_enabled = True
config.retain_batch_poll_interval_seconds = 1 # Fast polling for tests
config.retain_chunk_size = 4000
config.retain_extraction_mode = "concise"
config.retain_extract_causal_links = False
return config
@pytest.mark.asyncio
async def test_batch_api_normal_flow(mock_llm_config, test_contents, hindsight_config, memory, request_context):
"""Test normal batch API flow: submit, poll, complete."""
bank_id = f"test_batch_{datetime.now(timezone.utc).timestamp()}"
try:
# Mock batch API responses
batch_id = "batch_test123"
# Mock supports_batch_api
mock_llm_config._provider_impl.supports_batch_api = AsyncMock(return_value=True)
# Mock submit_batch - returns batch metadata
mock_llm_config._provider_impl.submit_batch = AsyncMock(
return_value={
"batch_id": batch_id,
"status": "validating",
"request_counts": {"total": 2, "completed": 0, "failed": 0},
}
)
# Mock get_batch_status - simulate polling sequence
status_sequence = [
{"status": "in_progress", "request_counts": {"total": 2, "completed": 1, "failed": 0}},
{"status": "completed", "request_counts": {"total": 2, "completed": 2, "failed": 0}},
]
mock_llm_config._provider_impl.get_batch_status = AsyncMock(side_effect=status_sequence)
# Mock retrieve_batch_results - returns fact extraction results
mock_results = [
{
"custom_id": "chunk_0",
"response": {
"body": {
"choices": [
{
"message": {
"content": json.dumps({
"facts": [
{
"what": "Alice is a senior software engineer at TechCorp",
"when": "present",
"where": "TechCorp",
"who": "Alice",
"why": "Professional background information",
"fact_type": "world",
"fact_kind": "conversation",
}
]
})
}
}
],
"usage": {"prompt_tokens": 100, "completion_tokens": 50, "total_tokens": 150},
}
},
},
{
"custom_id": "chunk_1",
"response": {
"body": {
"choices": [
{
"message": {
"content": json.dumps({
"facts": [
{
"what": "Bob joined the team last month as a junior developer",
"when": "last month",
"where": "team",
"who": "Bob",
"why": "New team member information",
"fact_type": "world",
"fact_kind": "conversation",
}
]
})
}
}
],
"usage": {"prompt_tokens": 100, "completion_tokens": 50, "total_tokens": 150},
}
},
},
]
mock_llm_config._provider_impl.retrieve_batch_results = AsyncMock(return_value=mock_results)
# Call batch API extraction
facts, chunks, usage = await extract_facts_from_contents_batch_api(
contents=test_contents,
llm_config=mock_llm_config,
agent_name="test_agent",
config=hindsight_config,
pool=None, # No DB pool for this test
operation_id=None,
schema=None,
)
# Verify results
assert len(facts) == 2, "Should extract 2 facts (one per chunk)"
# Facts are ExtractedFact objects with .fact_text field
assert "Alice" in facts[0].fact_text and "senior software engineer" in facts[0].fact_text
assert "Bob" in facts[1].fact_text and "junior developer" in facts[1].fact_text
# Verify chunks metadata
assert len(chunks) == 2, "Should have 2 chunks metadata"
assert chunks[0].fact_count == 1
assert chunks[1].fact_count == 1
# Verify token usage
assert usage.input_tokens == 200 # 100 per chunk
assert usage.output_tokens == 100 # 50 per chunk
assert usage.total_tokens == 300
# Verify API calls
mock_llm_config._provider_impl.submit_batch.assert_called_once()
assert mock_llm_config._provider_impl.get_batch_status.call_count == 2
mock_llm_config._provider_impl.retrieve_batch_results.assert_called_once_with(batch_id)
logger.info("✅ Normal batch API flow test passed")
finally:
# Cleanup
try:
await memory.delete_bank(bank_id, request_context=request_context)
except Exception:
pass
@pytest.mark.asyncio
async def test_batch_api_crash_recovery(mock_llm_config, test_contents, hindsight_config, memory, request_context):
"""Test crash recovery: resume polling from existing batch_id."""
bank_id = f"test_crash_{datetime.now(timezone.utc).timestamp()}"
operation_id = str(uuid.uuid4()) # Must be UUID for async_operations table
try:
# Ensure bank exists
await memory.get_bank_profile(bank_id, request_context=request_context)
# Setup: Store batch_id in async_operations table (simulates partial execution)
batch_id = "batch_recovered_456"
pool = memory._pool
schema = request_context.tenant_id
from hindsight_api.engine.task_backend import fq_table
table = fq_table("async_operations", schema)
# Create operation with batch_id already stored
await pool.execute(
f"""
INSERT INTO {table} (operation_id, operation_type, bank_id, status, result_metadata)
VALUES ($1, 'retain', $2, 'processing', $3::jsonb)
""",
operation_id,
bank_id,
json.dumps({
"batch_id": batch_id,
"batch_provider": "openai",
"chunk_count": 2,
}),
)
# Mock batch API responses for resume scenario
mock_llm_config._provider_impl.supports_batch_api = AsyncMock(return_value=True)
# Mock get_batch_status - batch already in progress
mock_llm_config._provider_impl.get_batch_status = AsyncMock(
return_value={
"status": "completed",
"request_counts": {"total": 2, "completed": 2, "failed": 0},
}
)
# Mock retrieve_batch_results
mock_results = [
{
"custom_id": "chunk_0",
"response": {
"body": {
"choices": [
{
"message": {
"content": json.dumps({
"facts": [
{
"what": "Alice is a senior software engineer",
"when": "present",
"where": "TechCorp",
"who": "Alice",
"why": "Background",
"fact_type": "world",
"fact_kind": "conversation",
}
]
})
}
}
],
"usage": {"prompt_tokens": 100, "completion_tokens": 50, "total_tokens": 150},
}
},
},
{
"custom_id": "chunk_1",
"response": {
"body": {
"choices": [
{
"message": {
"content": json.dumps({
"facts": [
{
"what": "Bob is a junior developer",
"when": "last month",
"where": "team",
"who": "Bob",
"why": "New member",
"fact_type": "world",
"fact_kind": "conversation",
}
]
})
}
}
],
"usage": {"prompt_tokens": 100, "completion_tokens": 50, "total_tokens": 150},
}
},
},
]
mock_llm_config._provider_impl.retrieve_batch_results = AsyncMock(return_value=mock_results)
# Call batch API extraction with operation_id (crash recovery scenario)
facts, chunks, usage = await extract_facts_from_contents_batch_api(
contents=test_contents,
llm_config=mock_llm_config,
agent_name="test_agent",
config=hindsight_config,
pool=pool,
operation_id=operation_id, # Provides crash recovery context
schema=schema,
)
# Verify results
assert len(facts) == 2, "Should extract 2 facts after recovery"
# CRITICAL: Verify submit_batch was NOT called (because batch_id already exists)
mock_llm_config._provider_impl.submit_batch.assert_not_called()
# Verify get_batch_status WAS called (polling resumed)
mock_llm_config._provider_impl.get_batch_status.assert_called()
# Verify retrieve_batch_results was called with the recovered batch_id
mock_llm_config._provider_impl.retrieve_batch_results.assert_called_once_with(batch_id)
logger.info("✅ Crash recovery test passed - resumed polling without re-submission")
finally:
# Cleanup
try:
await memory.delete_bank(bank_id, request_context=request_context)
except Exception:
pass
@pytest.mark.asyncio
async def test_batch_api_fallback_unsupported_provider(mock_llm_config, test_contents, hindsight_config):
"""Test fallback to sync mode when provider doesn't support batch API."""
# Mock provider that doesn't support batch API
mock_llm_config._provider_impl.supports_batch_api = AsyncMock(return_value=False)
mock_llm_config.provider = "groq" # Example of provider
# Patch the sync mode function to verify it's called
with patch(
"hindsight_api.engine.retain.fact_extraction.extract_facts_from_contents"
) as mock_sync_extract:
mock_sync_extract.return_value = ([], [], MagicMock())
# Call batch API extraction (should fallback to sync)
await extract_facts_from_contents_batch_api(
contents=test_contents,
llm_config=mock_llm_config,
agent_name="test_agent",
config=hindsight_config,
pool=None,
operation_id=None,
schema=None,
)
# Verify fallback occurred
mock_sync_extract.assert_called_once()
# Verify batch API methods were NOT called
mock_llm_config._provider_impl.submit_batch.assert_not_called()
logger.info("✅ Fallback to sync mode test passed")
@pytest.mark.asyncio
async def test_worker_batch_recovery(memory, request_context):
"""Test that WorkerPoller._recover_batch_operations finds and resets orphaned batches."""
bank_id = f"test_worker_recovery_{datetime.now(timezone.utc).timestamp()}"
operation_id = str(uuid.uuid4()) # Must be UUID for async_operations table
try:
# Ensure bank exists
await memory.get_bank_profile(bank_id, request_context=request_context)
pool = memory._pool
schema = request_context.tenant_id
from hindsight_api.engine.task_backend import fq_table
table = fq_table("async_operations", schema)
# Create orphaned batch operation (simulates worker crash during polling)
batch_id = "batch_orphaned_999"
task_payload = {
"operation_type": "retain",
"bank_id": bank_id,
"contents": [{"content": "test", "event_date": "2024-01-15T00:00:00Z"}],
}
await pool.execute(
f"""
INSERT INTO {table} (operation_id, operation_type, bank_id, status, worker_id, result_metadata, task_payload)
VALUES ($1, 'retain', $2, 'processing', 'worker_crashed', $3::jsonb, $4::jsonb)
""",
operation_id,
bank_id,
json.dumps({
"batch_id": batch_id,
"batch_provider": "openai",
"chunk_count": 1,
}),
json.dumps(task_payload),
)
# Create WorkerPoller
from hindsight_api.extensions.builtin.tenant import DefaultTenantExtension
tenant_extension = DefaultTenantExtension(config={"schema": schema} if schema else {})
poller = WorkerPoller(
pool=pool,
worker_id="test_worker_recovery",
executor=memory,
poll_interval_ms=100,
max_retries=3,
schema=schema,
tenant_extension=tenant_extension,
max_slots=5,
consolidation_max_slots=2,
)
# Run recovery
recovered_count = await poller._recover_batch_operations(schema)
# Verify recovery
assert recovered_count == 1, "Should recover 1 batch operation"
# Verify operation was reset to pending
row = await pool.fetchrow(
f"SELECT status, worker_id FROM {table} WHERE operation_id = $1",
operation_id,
)
assert row["status"] == "pending", "Operation should be reset to pending"
assert row["worker_id"] is None, "Worker ID should be cleared"
logger.info("✅ Worker batch recovery test passed")
finally:
# Cleanup
try:
await memory.delete_bank(bank_id, request_context=request_context)
except Exception:
pass
@pytest.mark.asyncio
async def test_batch_api_via_extract_facts_from_contents(
mock_llm_config, test_contents, hindsight_config, memory, request_context
):
"""Test that extract_facts_from_contents routes to batch API when enabled."""
bank_id = f"test_routing_{datetime.now(timezone.utc).timestamp()}"
try:
# Enable batch API in config
hindsight_config.retain_batch_enabled = True
# Mock batch API support
mock_llm_config._provider_impl.supports_batch_api = AsyncMock(return_value=True)
mock_llm_config._provider_impl.submit_batch = AsyncMock(
return_value={"batch_id": "batch_123", "status": "validating", "request_counts": {}}
)
mock_llm_config._provider_impl.get_batch_status = AsyncMock(
return_value={"status": "completed", "request_counts": {"total": 1, "completed": 1, "failed": 0}}
)
mock_llm_config._provider_impl.retrieve_batch_results = AsyncMock(
return_value=[
{
"custom_id": "chunk_0",
"response": {
"body": {
"choices": [
{
"message": {
"content": json.dumps({"facts": []})
}
}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15},
}
},
}
]
)
# Call main extract_facts_from_contents (should route to batch API)
facts, chunks, usage = await extract_facts_from_contents(
contents=test_contents,
llm_config=mock_llm_config,
agent_name="test_agent",
config=hindsight_config,
pool=None,
operation_id=None,
schema=None,
)
# Verify batch API was called
mock_llm_config._provider_impl.submit_batch.assert_called_once()
logger.info("✅ Routing to batch API test passed")
finally:
# Cleanup
try:
await memory.delete_bank(bank_id, request_context=request_context)
except Exception:
pass
@@ -1,263 +0,0 @@
"""
Real integration test for OpenAI Batch API.
This test makes REAL API calls to OpenAI and measures actual timing.
It will be slow (minutes to hours) depending on OpenAI's queue.
To run:
pytest tests/test_batch_api_integration.py -v -s
To skip in CI:
Add @pytest.mark.skip at the test level
"""
import pytest
import os
import asyncio
import logging
import time
from datetime import datetime, timezone
from dotenv import load_dotenv
from hindsight_api import RequestContext
from hindsight_api.engine.retain.fact_extraction import (
extract_facts_from_contents_batch_api,
RetainContent,
)
from hindsight_api.config import HindsightConfig
from hindsight_api.engine.llm_wrapper import LLMProvider
logger = logging.getLogger(__name__)
# Load .env file for API keys
load_dotenv()
@pytest.fixture
def openai_api_key():
"""Get OpenAI API key from environment."""
# Try both current and commented keys from .env
api_key = os.getenv("HINDSIGHT_API_LLM_API_KEY")
# Check if it's an OpenAI key (starts with sk-proj- or sk-)
if not api_key or not api_key.startswith("sk-"):
# Try the OpenAI-specific env var (if set separately)
api_key = os.getenv("OPENAI_API_KEY")
if not api_key or not api_key.startswith("sk-"):
pytest.skip("OpenAI API key not found in environment. Set OPENAI_API_KEY or uncomment OpenAI config in .env")
return api_key
@pytest.fixture
def real_llm_config(openai_api_key):
"""Create real LLM config for OpenAI."""
# Create config with OpenAI settings
config = HindsightConfig.from_env()
# Use LLMProvider wrapper (which creates _provider_impl internally)
llm_config = LLMProvider(
provider="openai",
api_key=openai_api_key,
base_url="https://api.openai.com/v1",
model="gpt-4o-mini", # Fast, cheap model for testing
reasoning_effort="medium", # Required parameter
)
return llm_config
@pytest.fixture
def test_contents_real():
"""Create realistic test content for fact extraction."""
return [
RetainContent(
content="""
Alice is a senior software engineer at TechCorp, where she has been working for 5 years.
She specializes in distributed systems and microservices architecture. Alice graduated
from MIT with a degree in Computer Science in 2015. She is known for writing clean,
well-documented code and mentoring junior developers.
""",
event_date=datetime(2024, 1, 15, 10, 30, tzinfo=timezone.utc),
context="team member profile",
),
RetainContent(
content="""
Bob joined TechCorp last month as a junior developer. He is learning React and Node.js
and recently completed his first feature, which was a user authentication flow. Bob
graduated from Berkeley with a degree in Computer Science in 2023. He is enthusiastic
and asks great questions during code reviews.
""",
event_date=datetime(2024, 1, 15, 10, 30, tzinfo=timezone.utc),
context="team member profile",
),
RetainContent(
content="""
The team uses Kubernetes for container orchestration and deploys to AWS. They follow
agile methodologies with two-week sprints. Code reviews are mandatory before merging
any pull request. The team meets every morning for a 15-minute standup to discuss
progress and blockers.
""",
event_date=datetime(2024, 1, 15, 10, 30, tzinfo=timezone.utc),
context="team processes",
),
]
@pytest.fixture
def integration_config():
"""Create config for integration test."""
config = HindsightConfig.from_env()
config.retain_batch_enabled = True
config.retain_batch_poll_interval_seconds = 30 # Poll every 30 seconds (reasonable for real API)
config.retain_chunk_size = 4000
config.retain_extraction_mode = "concise"
config.retain_extract_causal_links = False
return config
@pytest.mark.skip(reason="Real API test - takes minutes and costs money. Run manually with: pytest tests/test_batch_api_integration.py::test_real_openai_batch_api -v -s")
@pytest.mark.integration # Mark as integration test
@pytest.mark.slow # Mark as slow test
@pytest.mark.asyncio
async def test_real_openai_batch_api(real_llm_config, test_contents_real, integration_config, memory, request_context):
"""
REAL integration test: Submit actual batch to OpenAI and measure timing.
WARNING: This test:
- Makes real API calls to OpenAI
- Will take minutes to hours to complete
- Costs money (though very little with gpt-4o-mini)
- Requires valid OpenAI API key
To skip this test:
pytest tests/test_batch_api_integration.py --skip-integration
"""
bank_id = f"test_real_batch_{datetime.now(timezone.utc).timestamp()}"
logger.info("=" * 80)
logger.info("STARTING REAL OPENAI BATCH API INTEGRATION TEST")
logger.info("=" * 80)
logger.info(f"Test contents: {len(test_contents_real)} items")
logger.info(f"Poll interval: {integration_config.retain_batch_poll_interval_seconds}s")
logger.info(f"Model: {real_llm_config.model}")
logger.info("This may take several minutes to hours depending on OpenAI's queue...")
logger.info("=" * 80)
try:
# Ensure bank exists
await memory.get_bank_profile(bank_id, request_context=request_context)
# Get database pool and schema for crash recovery testing
pool = memory._pool
schema = request_context.tenant_id
# Track overall timing
test_start_time = time.time()
# Call REAL batch API extraction
logger.info("\n📤 Submitting batch to OpenAI...")
facts, chunks, usage = await extract_facts_from_contents_batch_api(
contents=test_contents_real,
llm_config=real_llm_config,
agent_name="test_agent",
config=integration_config,
pool=pool,
operation_id=None, # No crash recovery for this test
schema=schema,
)
test_end_time = time.time()
total_duration = test_end_time - test_start_time
# Log results
logger.info("\n" + "=" * 80)
logger.info("✅ BATCH COMPLETED SUCCESSFULLY")
logger.info("=" * 80)
logger.info(f"Total duration: {total_duration:.1f} seconds ({total_duration/60:.1f} minutes)")
logger.info(f"Facts extracted: {len(facts)}")
logger.info(f"Chunks processed: {len(chunks)}")
logger.info(f"Token usage: {usage.input_tokens} input + {usage.output_tokens} output = {usage.total_tokens} total")
logger.info(f"Estimated cost: ${(usage.input_tokens * 0.00015 / 1000 + usage.output_tokens * 0.0006 / 1000):.4f}")
logger.info("=" * 80)
# Log sample facts
logger.info("\n📋 Sample extracted facts:")
for i, fact in enumerate(facts[:5]): # Show first 5 facts
logger.info(f"\nFact {i+1}:")
logger.info(f" Type: {fact.fact_type}")
logger.info(f" Text: {fact.fact_text[:100]}...")
logger.info(f" Entities: {fact.entities}")
# Verify results
assert len(facts) > 0, "Should extract at least some facts"
assert len(chunks) == len(test_contents_real), f"Should have {len(test_contents_real)} chunks"
assert usage.total_tokens > 0, "Should have token usage"
# Verify fact structure
for fact in facts:
assert hasattr(fact, "fact_text"), "Fact should have fact_text"
assert hasattr(fact, "fact_type"), "Fact should have fact_type"
assert fact.fact_type in ["world", "experience", "opinion"], f"Invalid fact_type: {fact.fact_type}"
logger.info("\n✅ All assertions passed!")
# Write timing report to file for later analysis
report_path = "/tmp/openai_batch_api_timing_report.txt"
with open(report_path, "w") as f:
f.write(f"OpenAI Batch API Integration Test Report\n")
f.write(f"={'=' * 60}\n\n")
f.write(f"Test Date: {datetime.now(timezone.utc).isoformat()}\n")
f.write(f"Model: {real_llm_config.model}\n")
f.write(f"Contents: {len(test_contents_real)} items\n")
f.write(f"Poll Interval: {integration_config.retain_batch_poll_interval_seconds}s\n\n")
f.write(f"Results:\n")
f.write(f" Total Duration: {total_duration:.1f}s ({total_duration/60:.1f} min)\n")
f.write(f" Facts Extracted: {len(facts)}\n")
f.write(f" Chunks Processed: {len(chunks)}\n")
f.write(f" Token Usage: {usage.total_tokens} ({usage.input_tokens} in + {usage.output_tokens} out)\n")
f.write(f" Estimated Cost: ${(usage.input_tokens * 0.00015 / 1000 + usage.output_tokens * 0.0006 / 1000):.4f}\n")
logger.info(f"\n📄 Timing report written to: {report_path}")
finally:
# Cleanup
try:
await memory.delete_bank(bank_id, request_context=request_context)
logger.info(f"\n🧹 Cleaned up test bank: {bank_id}")
except Exception as e:
logger.error(f"Failed to cleanup bank: {e}")
@pytest.mark.skip(reason="Real API test - requires Groq API key. Run manually if needed.")
@pytest.mark.integration
@pytest.mark.slow
@pytest.mark.asyncio
async def test_real_batch_supports_groq(integration_config):
"""
Test that Groq also supports batch API (if configured).
Groq has the same batch API interface as OpenAI.
"""
groq_api_key = os.getenv("HINDSIGHT_API_LLM_API_KEY")
if not groq_api_key or not groq_api_key.startswith("gsk_"):
pytest.skip("Groq API key not found in environment")
llm_config = LLMProvider(
provider="groq",
api_key=groq_api_key,
base_url="https://api.groq.com/openai/v1",
model="llama-3.1-8b-instant",
reasoning_effort="medium",
)
# Check if Groq supports batch API
supports_batch = await llm_config._provider_impl.supports_batch_api()
logger.info(f"Groq batch API support: {supports_batch}")
# Groq should support batch API (same interface as OpenAI)
assert supports_batch, "Groq should support batch API"
logger.info("✅ Groq batch API support confirmed")
@@ -1,38 +0,0 @@
"""
Test validation for batch API + synchronous retain.
When HINDSIGHT_API_RETAIN_BATCH_ENABLED=true, synchronous retain operations
should be rejected with a 400 error since they will timeout.
"""
import os
import pytest
from hindsight_api.engine.memory_engine import MemoryEngine
from hindsight_api.config import HindsightConfig
from hindsight_api import RequestContext
@pytest.mark.asyncio
async def test_batch_api_validation(memory, request_context):
"""
Test that attempting synchronous retain with batch API enabled
raises an error at the HTTP layer.
This test verifies the validation logic exists - actual HTTP testing
would require full FastAPI app setup.
"""
# Create config with batch API enabled
config = HindsightConfig.from_env()
config.retain_batch_enabled = True
config.retain_batch_poll_interval_seconds = 1
# Verify the validation exists in memory engine
# The actual HTTP validation happens in http.py api_retain()
# This test documents the expected behavior
assert config.retain_batch_enabled is True
assert config.retain_batch_poll_interval_seconds == 1
# When batch API is enabled and async=false, the HTTP endpoint
# should return 400 with message:
# "Batch API is enabled (HINDSIGHT_API_RETAIN_BATCH_ENABLED=true) but async=false"
@@ -135,179 +135,3 @@ async def test_memory_without_document(memory, request_context):
finally:
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_document_persisted_with_zero_facts(memory, request_context):
"""
Test that documents are persisted even when zero facts are extracted.
This is a regression test for issue #324 where documents with no extractable
facts were reported as disappearing from the system.
"""
bank_id = f"test_zero_facts_{datetime.now(timezone.utc).timestamp()}"
try:
document_id = "doc-zero-facts"
# Retain content that produces zero facts (gibberish/random characters)
units = await memory.retain_async(
bank_id=bank_id,
content="xyzabc123 !!!### @@@ $$$", # Random characters unlikely to produce facts
context="Test zero facts",
document_id=document_id,
request_context=request_context,
)
# Should return empty unit list (no facts extracted)
assert len(units) == 0, "Should extract zero facts from gibberish content"
# But document should still be persisted and retrievable
doc = await memory.get_document(document_id, bank_id, request_context=request_context)
assert doc is not None, "Document should be persisted even with zero facts"
assert doc["id"] == document_id
assert doc["bank_id"] == bank_id
assert doc["memory_unit_count"] == 0, "Should have zero memory units"
assert len(doc["original_text"]) > 0, "Should have non-zero text length"
assert "xyzabc123" in doc["original_text"], "Should contain original content"
# Document should also appear in list
docs_list = await memory.list_documents(
bank_id=bank_id,
search_query=None,
limit=100,
offset=0,
request_context=request_context,
)
assert docs_list["total"] == 1, "Document should appear in list"
assert any(d["id"] == document_id for d in docs_list["items"]), "Document should be in items"
listed_doc = next(d for d in docs_list["items"] if d["id"] == document_id)
assert listed_doc["memory_unit_count"] == 0, "Listed document should show zero memory units"
finally:
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_document_persisted_with_zero_facts_batch(memory, request_context):
"""
Test that documents are persisted with zero facts in batch retain operations.
This tests the async batch code path to ensure it also handles zero facts correctly.
"""
bank_id = f"test_zero_facts_batch_{datetime.now(timezone.utc).timestamp()}"
try:
# Mix of content: some produces facts, some produces zero facts
contents = [
{
"content": "Alice works at Google",
"document_id": "doc-with-facts",
},
{
"content": "!@# $$$ %%% ^^^ &&& ***", # Gibberish - zero facts expected
"document_id": "doc-zero-facts",
},
]
unit_ids = await memory.retain_batch_async(
bank_id=bank_id,
contents=contents,
request_context=request_context,
)
# First content should produce facts, second should not
assert len(unit_ids[0]) > 0, "First content should produce facts"
assert len(unit_ids[1]) == 0, "Second content should produce zero facts"
# Both documents should be persisted
doc_with_facts = await memory.get_document("doc-with-facts", bank_id, request_context=request_context)
assert doc_with_facts is not None
assert doc_with_facts["memory_unit_count"] > 0
doc_zero_facts = await memory.get_document("doc-zero-facts", bank_id, request_context=request_context)
assert doc_zero_facts is not None, "Document with zero facts should be persisted"
assert doc_zero_facts["memory_unit_count"] == 0, "Should have zero memory units"
assert "!@#" in doc_zero_facts["original_text"]
# Both should appear in list
docs_list = await memory.list_documents(
bank_id=bank_id,
search_query=None,
limit=100,
offset=0,
request_context=request_context,
)
assert docs_list["total"] == 2, "Both documents should appear in list"
finally:
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_document_persisted_with_zero_facts_async_submit(memory, request_context):
"""
Test that documents are persisted with zero facts in fire-and-forget async retain.
This tests the submit_async_retain (background task) code path to ensure it also
handles zero facts correctly.
"""
import asyncio
bank_id = f"test_zero_facts_async_{datetime.now(timezone.utc).timestamp()}"
try:
# Submit async retain with gibberish content
result = await memory.submit_async_retain(
bank_id=bank_id,
contents=[
{
"content": "!@# $$$ %%% ^^^ &&& ***", # Gibberish - zero facts expected
"document_id": "doc-async-zero-facts",
}
],
request_context=request_context,
)
operation_id = result["operation_id"]
assert operation_id is not None, "Should return operation_id"
# Wait for background task to complete
max_wait = 60 # 60 seconds max
wait_interval = 0.5
elapsed = 0
while elapsed < max_wait:
await asyncio.sleep(wait_interval)
elapsed += wait_interval
# Check if document exists
doc = await memory.get_document(
"doc-async-zero-facts", bank_id, request_context=request_context
)
if doc is not None:
break
# Document should be persisted even with zero facts
assert doc is not None, "Document should be persisted after async task completes"
assert doc["id"] == "doc-async-zero-facts"
assert doc["memory_unit_count"] == 0, "Should have zero memory units"
assert "!@#" in doc["original_text"]
# Document should appear in list
docs_list = await memory.list_documents(
bank_id=bank_id,
search_query=None,
limit=100,
offset=0,
request_context=request_context,
)
assert docs_list["total"] == 1, "Document should appear in list"
assert any(d["id"] == "doc-async-zero-facts" for d in docs_list["items"])
listed_doc = next(d for d in docs_list["items"] if d["id"] == "doc-async-zero-facts")
assert listed_doc["memory_unit_count"] == 0, "Listed document should show zero memory units"
finally:
await memory.delete_bank(bank_id, request_context=request_context)
-553
View File
@@ -1,553 +0,0 @@
"""
End-to-end tests for file retain (upload, convert, retain) functionality.
"""
import io
import json
import pytest
from httpx import ASGITransport, AsyncClient
@pytest.fixture
def sample_pdf_content():
"""Create a simple PDF-like content for testing."""
# This is a minimal PDF that markitdown can parse
return b"""%PDF-1.4
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [3 0 R]
/Count 1
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 612 792]
/Contents 4 0 R
/Resources <<
/Font <<
/F1 <<
/Type /Font
/Subtype /Type1
/BaseFont /Helvetica
>>
>>
>>
>>
endobj
4 0 obj
<<
/Length 44
>>
stream
BT
/F1 12 Tf
100 700 Td
(Test Document) Tj
ET
endstream
endobj
xref
0 5
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000317 00000 n
trailer
<<
/Size 5
/Root 1 0 R
>>
startxref
410
%%EOF
"""
@pytest.fixture
def sample_txt_content():
"""Create simple text content."""
return b"This is a test document.\nIt contains some important information.\nAlice works at Google."
@pytest.mark.asyncio
async def test_file_retain_basic(memory_no_llm_verify, sample_txt_content):
"""Test basic file upload and conversion."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create a bank first
bank_response = await client.put("/v1/default/banks/test-file-bank", json={"name": "Test File Bank"})
assert bank_response.status_code in (200, 201)
# Upload file
request_data = {
"document_tags": ["test"],
"async": True,
}
files = {"files": ("test.txt", sample_txt_content, "text/plain")}
data = {"request": json.dumps(request_data)}
response = await client.post(
"/v1/default/banks/test-file-bank/files/retain",
files=files,
data=data,
)
assert response.status_code == 200
result = response.json()
assert "operation_ids" in result
assert len(result["operation_ids"]) == 1
@pytest.mark.asyncio
async def test_file_retain_with_metadata(memory_no_llm_verify, sample_txt_content):
"""Test file upload with per-file metadata."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create bank
bank_response = await client.put("/v1/default/banks/test-file-meta-bank", json={"name": "Test Meta Bank"})
assert bank_response.status_code in (200, 201)
# Upload file with metadata
request_data = {
"document_tags": ["work", "reports"],
"async": True,
"files_metadata": [
{
"document_id": "test_doc_123",
"context": "quarterly report",
"metadata": {"author": "Alice", "year": "2024"},
"tags": ["Q1"],
}
],
}
files = {"files": ("report.txt", sample_txt_content, "text/plain")}
data = {"request": json.dumps(request_data)}
response = await client.post(
"/v1/default/banks/test-file-meta-bank/files/retain",
files=files,
data=data,
)
assert response.status_code == 200
result = response.json()
assert "operation_ids" in result
assert len(result["operation_ids"]) == 1
@pytest.mark.asyncio
async def test_file_retain_multiple_files(memory_no_llm_verify, sample_txt_content):
"""Test uploading multiple files at once."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create bank
bank_response = await client.put("/v1/default/banks/test-multi-file-bank", json={"name": "Test Multi Bank"})
assert bank_response.status_code in (200, 201)
# Upload multiple files
request_data = {
"async": True,
"files_metadata": [
{"document_id": "doc1", "tags": ["file1"]},
{"document_id": "doc2", "tags": ["file2"]},
],
}
content1 = b"First document content"
content2 = b"Second document content"
files = [
("files", ("file1.txt", content1, "text/plain")),
("files", ("file2.txt", content2, "text/plain")),
]
data = {"request": json.dumps(request_data)}
response = await client.post(
"/v1/default/banks/test-multi-file-bank/files/retain",
files=files,
data=data,
)
assert response.status_code == 200
result = response.json()
assert "operation_ids" in result
assert len(result["operation_ids"]) == 2
@pytest.mark.asyncio
async def test_file_retain_validation_errors(memory_no_llm_verify):
"""Test validation errors."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create bank
bank_response = await client.put("/v1/default/banks/test-validation-bank", json={"name": "Test Validation Bank"})
assert bank_response.status_code in (200, 201)
# Test: metadata count mismatch
request_data = {
"async": True,
"files_metadata": [
{"document_id": "doc1"},
{"document_id": "doc2"}, # 2 metadata entries
],
}
files = {"files": ("file1.txt", b"content", "text/plain")} # But only 1 file
data = {"request": json.dumps(request_data)}
response = await client.post(
"/v1/default/banks/test-validation-bank/files/retain",
files=files,
data=data,
)
assert response.status_code == 400
assert "files_metadata count" in response.json()["detail"]
@pytest.mark.asyncio
async def test_file_retain_no_files(memory_no_llm_verify):
"""Test error when no files provided."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create bank
bank_response = await client.put("/v1/default/banks/test-no-files-bank", json={"name": "Test No Files Bank"})
assert bank_response.status_code in (200, 201)
request_data = {
"async": True,
}
# No files provided
data = {"request": json.dumps(request_data)}
response = await client.post(
"/v1/default/banks/test-no-files-bank/files/retain",
data=data,
)
# FastAPI will return 422 for missing required field
assert response.status_code == 422
@pytest.mark.asyncio
async def test_file_retain_sync_not_supported(memory_no_llm_verify, sample_txt_content):
"""Test that file retain is always async (sync is not supported)."""
from hindsight_api.api.http import create_app
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
# Create bank
bank_response = await client.put("/v1/default/banks/test-sync-bank", json={"name": "Test Sync Bank"})
assert bank_response.status_code in (200, 201)
# File retain is always async - just verify it succeeds and returns operation_ids
files = {"files": ("test.txt", sample_txt_content, "text/plain")}
data = {"request": json.dumps({})}
response = await client.post(
"/v1/default/banks/test-sync-bank/files/retain",
files=files,
data=data,
)
assert response.status_code == 200
result = response.json()
assert "operation_ids" in result
@pytest.mark.asyncio
async def test_file_storage_postgresql(memory_no_llm_verify, sample_txt_content):
"""Test file storage in PostgreSQL."""
# Test that files are stored and retrieved correctly
storage = memory_no_llm_verify._file_storage
# Store a file
key = "test/file1.txt"
stored_key = await storage.store(
file_data=sample_txt_content,
key=key,
metadata={"content_type": "text/plain"},
)
assert stored_key == key
# Retrieve the file
retrieved = await storage.retrieve(key)
assert retrieved == sample_txt_content
# Check if file exists
exists = await storage.exists(key)
assert exists is True
# Delete the file
await storage.delete(key)
# Check file no longer exists
exists_after = await storage.exists(key)
assert exists_after is False
@pytest.mark.asyncio
async def test_markitdown_converter():
"""Test markitdown parser."""
from hindsight_api.engine.parsers import MarkitdownParser
parser = MarkitdownParser()
# Test simple text file
text_content = b"This is a test document.\nWith multiple lines."
result = await parser.convert(text_content, "test.txt")
assert isinstance(result, str)
assert len(result) > 0
assert "test document" in result.lower() or "multiple lines" in result.lower()
@pytest.mark.asyncio
async def test_converter_registry():
"""Test file parser registry."""
from hindsight_api.engine.parsers import FileParserRegistry, MarkitdownParser
registry = FileParserRegistry()
parser = MarkitdownParser()
registry.register(parser)
# Test get by name
retrieved = registry.get_parser("markitdown", "test.txt")
assert retrieved is parser
# Test auto-detection
auto = registry.get_parser(None, "test.pdf")
assert auto is parser
# Test unsupported format
with pytest.raises(ValueError, match="No parser found"):
registry.get_parser(None, "test.xyz")
@pytest.mark.asyncio
async def test_file_conversion_creates_separate_retain_operation(memory_no_llm_verify, sample_txt_content):
"""Test that file conversion and retain are two separate async operations.
The file_convert_retain task should:
1. Convert the file to markdown
2. In a single transaction: create a separate 'retain' operation AND mark itself as 'completed'
3. Free the worker slot immediately after conversion
The retain then runs as its own task. This prevents deadlocks where file conversion
tasks hold worker slots while waiting for inline retain to finish.
"""
from hindsight_api.models import RequestContext
bank_id = "test_file_two_phase_bank"
context = RequestContext(internal=True)
await memory_no_llm_verify.get_bank_profile(bank_id, request_context=context)
class MockFile:
def __init__(self, content, filename, content_type):
self.content = content
self.filename = filename
self.content_type = content_type
async def read(self):
return self.content
mock_file = MockFile(sample_txt_content, "test.txt", "text/plain")
file_items = [
{
"file": mock_file,
"document_id": "test_doc_two_phase",
"context": "test context",
"metadata": {"source": "test"},
"tags": ["test_tag"],
"timestamp": None,
}
]
result = await memory_no_llm_verify.submit_async_file_retain(
bank_id=bank_id,
file_items=file_items,
parser="markitdown",
document_tags=["two_phase_test"],
request_context=context,
)
assert "operation_ids" in result
assert len(result["operation_ids"]) == 1
convert_operation_id = result["operation_ids"][0]
import asyncio
await asyncio.sleep(0.1)
pool = await memory_no_llm_verify._get_pool()
from hindsight_api.engine.memory_engine import get_current_schema
schema = get_current_schema()
async with pool.acquire() as conn:
# 1. The file_convert_retain operation must be completed
convert_op = await conn.fetchrow(
f"SELECT status, operation_type FROM {schema}.async_operations WHERE operation_id = $1",
convert_operation_id,
)
assert convert_op is not None
assert convert_op["operation_type"] == "file_convert_retain"
assert convert_op["status"] == "completed", (
f"file_convert_retain should be 'completed' after conversion, got '{convert_op['status']}'"
)
# 2. A separate retain operation must have been created
retain_op = await conn.fetchrow(
f"""
SELECT status, operation_type
FROM {schema}.async_operations
WHERE bank_id = $1 AND operation_type = 'retain' AND operation_id != $2
""",
bank_id,
convert_operation_id,
)
assert retain_op is not None, "A separate 'retain' operation should have been created by file conversion"
# With SyncTaskBackend the retain runs immediately, so it should be completed
assert retain_op["status"] == "completed"
# 3. The document should exist with file metadata and retained content
doc = await conn.fetchrow(
f"""
SELECT id, original_text, file_original_name, file_content_type
FROM {schema}.documents
WHERE id = $1 AND bank_id = $2
""",
"test_doc_two_phase",
bank_id,
)
assert doc is not None
assert doc["file_original_name"] == "test.txt"
assert doc["file_content_type"] == "text/plain"
assert doc["original_text"] is not None
assert len(doc["original_text"]) > 0
@pytest.mark.asyncio
async def test_file_conversion_failure_sets_status_to_failed(memory_no_llm_verify, sample_txt_content):
"""Test that when file conversion fails, the operation status is set to 'failed' not 'completed'."""
from hindsight_api.engine.parsers.base import FileParser
from hindsight_api.models import RequestContext
bank_id = "test_file_failure_bank"
# Create a mock parser that always fails
class FailingParser(FileParser):
"""Mock parser that raises an error."""
async def convert(self, file_data: bytes, filename: str) -> str:
# Simulate conversion failure
raise RuntimeError(f"Failed to convert '{filename}': Mock conversion error")
def supports(self, filename: str, content_type: str | None = None) -> bool:
return filename.endswith(".fail")
def name(self) -> str:
return "failing_converter"
# Register the failing parser
failing_converter = FailingParser()
memory_no_llm_verify._parser_registry.register(failing_converter)
# Create bank
context = RequestContext(internal=True)
await memory_no_llm_verify.get_bank_profile(bank_id, request_context=context)
# Create mock file
class MockFile:
def __init__(self, content, filename, content_type):
self.content = content
self.filename = filename
self.content_type = content_type
async def read(self):
return self.content
mock_file = MockFile(sample_txt_content, "test.fail", "application/octet-stream")
file_items = [
{
"file": mock_file,
"document_id": "test_doc_fail",
"context": None,
"metadata": {},
"tags": [],
"timestamp": None,
}
]
# Submit async file retain with failing parser
result = await memory_no_llm_verify.submit_async_file_retain(
bank_id=bank_id,
file_items=file_items,
parser="failing_converter",
document_tags=None,
request_context=context,
)
assert "operation_ids" in result
assert len(result["operation_ids"]) == 1
operation_id = result["operation_ids"][0]
# Wait for async processing (with SyncTaskBackend, this is immediate)
import asyncio
await asyncio.sleep(0.2)
# Check operation status - should be 'failed' not 'completed'
pool = await memory_no_llm_verify._get_pool()
from hindsight_api.engine.memory_engine import get_current_schema
async with pool.acquire() as conn:
operation = await conn.fetchrow(
f"""
SELECT status, error_message
FROM {get_current_schema()}.async_operations
WHERE operation_id = $1
""",
operation_id,
)
assert operation is not None, f"Operation {operation_id} not found"
assert operation["status"] == "failed", f"Expected status 'failed' but got '{operation['status']}'"
assert operation["error_message"] is not None
assert "Mock conversion error" in operation["error_message"]
assert "test.fail" in operation["error_message"]
-252
View File
@@ -1,252 +0,0 @@
"""
Integration tests for S3FileStorage against a SeaweedFS Docker container.
SeaweedFS (Apache 2.0) provides an S3-compatible API via `weed server -s3`.
Requires Docker to be running. Tests are skipped automatically if Docker is unavailable.
"""
import json
import logging
import subprocess
import tempfile
import time
import uuid
import httpx
import pytest
from httpx import ASGITransport, AsyncClient
logger = logging.getLogger(__name__)
try:
from testcontainers.core.container import DockerContainer
_has_testcontainers = True
except ImportError:
_has_testcontainers = False
pytestmark = [
pytest.mark.skipif(not _has_testcontainers, reason="testcontainers not installed"),
]
SEAWEEDFS_S3_PORT = 8333
TEST_BUCKET = "hindsight-test"
ACCESS_KEY = "test_access_key"
SECRET_KEY = "test_secret_key"
# SeaweedFS S3 IAM config granting full access to our test credentials
_S3_CONFIG = {
"identities": [
{
"name": "test-user",
"credentials": [{"accessKey": ACCESS_KEY, "secretKey": SECRET_KEY}],
"actions": ["Admin", "Read", "Write", "List"],
}
]
}
def _docker_available() -> bool:
"""Check if Docker daemon is running."""
try:
result = subprocess.run(
["docker", "info"],
capture_output=True,
timeout=5,
)
return result.returncode == 0
except (FileNotFoundError, subprocess.TimeoutExpired):
return False
def _wait_for_seaweedfs(endpoint: str, timeout: int = 30) -> None:
"""Poll SeaweedFS S3 endpoint until ready."""
deadline = time.time() + timeout
while time.time() < deadline:
try:
resp = httpx.get(endpoint, timeout=2)
# 200 = no auth, 403 = auth enabled but gateway is up — either means ready
if resp.status_code in (200, 403):
logger.info("SeaweedFS S3 is ready at %s", endpoint)
return
except httpx.HTTPError:
pass
time.sleep(0.5)
raise TimeoutError(f"SeaweedFS did not become ready at {endpoint} within {timeout}s")
@pytest.fixture(scope="module")
def seaweedfs_container():
"""Start a SeaweedFS container for the test module, shared across all tests.
Mounts an s3.json config file to set up S3 credentials for the test user.
"""
if not _docker_available():
pytest.skip("Docker is not available")
# Write S3 IAM config to a temp file that persists for the module scope
s3_config_file = tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False)
json.dump(_S3_CONFIG, s3_config_file)
s3_config_file.flush()
container = (
DockerContainer(image="chrislusf/seaweedfs:latest")
.with_exposed_ports(SEAWEEDFS_S3_PORT)
.with_volume_mapping(s3_config_file.name, "/etc/seaweedfs/s3.json", "ro")
.with_command(
f"server -s3 -s3.port={SEAWEEDFS_S3_PORT} -s3.config=/etc/seaweedfs/s3.json -ip.bind=0.0.0.0"
)
)
container.start()
try:
host = container.get_container_host_ip()
port = container.get_exposed_port(SEAWEEDFS_S3_PORT)
endpoint = f"http://{host}:{port}"
_wait_for_seaweedfs(endpoint)
# Create test bucket using obstore (proper SigV4 signing)
import obstore as obs
from obstore.store import S3Store
admin_store = S3Store(
TEST_BUCKET,
endpoint=endpoint,
region="us-east-1",
access_key_id=ACCESS_KEY,
secret_access_key=SECRET_KEY,
allow_http=True,
)
# SeaweedFS auto-creates buckets on first write
obs.put(admin_store, ".bucket-init", b"")
obs.delete(admin_store, ".bucket-init")
logger.info("Test bucket '%s' is ready", TEST_BUCKET)
yield {
"endpoint": endpoint,
"access_key": ACCESS_KEY,
"secret_key": SECRET_KEY,
"bucket": TEST_BUCKET,
}
finally:
container.stop()
import os
os.unlink(s3_config_file.name)
@pytest.fixture
def s3_storage(seaweedfs_container):
"""Create an S3FileStorage instance pointing at the SeaweedFS container."""
from hindsight_api.engine.storage.s3 import S3FileStorage
return S3FileStorage(
bucket=seaweedfs_container["bucket"],
region="us-east-1",
endpoint=seaweedfs_container["endpoint"],
access_key_id=seaweedfs_container["access_key"],
secret_access_key=seaweedfs_container["secret_key"],
)
@pytest.mark.asyncio
async def test_s3_storage_store_and_retrieve(s3_storage):
"""Store a file, retrieve it, verify bytes match."""
content = b"Hello, SeaweedFS! This is a test file."
key = f"test/{uuid.uuid4()}.txt"
stored_key = await s3_storage.store(
file_data=content,
key=key,
metadata={"content_type": "text/plain"},
)
assert stored_key == key
retrieved = await s3_storage.retrieve(key)
assert retrieved == content
@pytest.mark.asyncio
async def test_s3_storage_exists_and_delete(s3_storage):
"""Store, check exists=True, delete, check exists=False."""
content = b"File to be deleted."
key = f"test/{uuid.uuid4()}.txt"
await s3_storage.store(file_data=content, key=key)
assert await s3_storage.exists(key) is True
await s3_storage.delete(key)
assert await s3_storage.exists(key) is False
@pytest.mark.asyncio
async def test_s3_storage_file_not_found(s3_storage):
"""Retrieve a non-existent key, expect FileNotFoundError."""
with pytest.raises(FileNotFoundError):
await s3_storage.retrieve(f"nonexistent/{uuid.uuid4()}.txt")
@pytest.mark.asyncio
async def test_s3_storage_get_download_url(s3_storage):
"""Store a file, get a presigned URL, verify it's a valid URL string."""
content = b"Presigned URL test content."
key = f"test/{uuid.uuid4()}.txt"
await s3_storage.store(file_data=content, key=key)
url = await s3_storage.get_download_url(key, expires_in=300)
assert isinstance(url, str)
assert url.startswith("http")
assert key in url
@pytest.mark.asyncio
async def test_s3_file_retain_api_end_to_end(seaweedfs_container, memory_no_llm_verify):
"""Full HTTP API flow: upload file via /files/retain with S3 storage backend."""
from hindsight_api.api.http import create_app
from hindsight_api.engine.storage.s3 import S3FileStorage
# Swap the engine's file storage to use the SeaweedFS-backed S3 storage
original_storage = memory_no_llm_verify._file_storage
s3_storage = S3FileStorage(
bucket=seaweedfs_container["bucket"],
region="us-east-1",
endpoint=seaweedfs_container["endpoint"],
access_key_id=seaweedfs_container["access_key"],
secret_access_key=seaweedfs_container["secret_key"],
)
memory_no_llm_verify._file_storage = s3_storage
try:
app = create_app(memory_no_llm_verify, initialize_memory=False)
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
bank_id = f"test-s3-bank-{uuid.uuid4().hex[:8]}"
bank_response = await client.put(f"/v1/default/banks/{bank_id}", json={"name": "S3 Test Bank"})
assert bank_response.status_code in (200, 201)
txt_content = b"Alice works at Acme Corp. She joined in 2024."
request_data = {
"document_tags": ["s3-test"],
"async": True,
}
files = {"files": ("notes.txt", txt_content, "text/plain")}
data = {"request": json.dumps(request_data)}
response = await client.post(
f"/v1/default/banks/{bank_id}/files/retain",
files=files,
data=data,
)
assert response.status_code == 200
result = response.json()
assert "operation_ids" in result
assert len(result["operation_ids"]) == 1
finally:
memory_no_llm_verify._file_storage = original_storage
@@ -528,7 +528,7 @@ async def test_delete_bank(api_client):
{
"content": "Bob is the CTO and leads the engineering team.",
"context": "team info",
"document_id": "team-doc-2",
"document_id": "team-doc-1",
},
]
},
-72
View File
@@ -1,72 +0,0 @@
"""
Integration tests for the Iris file parser.
Tests are skipped automatically if HINDSIGHT_API_FILE_PARSER_IRIS_TOKEN
and HINDSIGHT_API_FILE_PARSER_IRIS_ORG_ID are not set in the environment.
"""
import os
import pytest
from hindsight_api.config import ENV_FILE_PARSER_IRIS_ORG_ID, ENV_FILE_PARSER_IRIS_TOKEN
from hindsight_api.engine.parsers.iris import IrisParser
_token = os.getenv(ENV_FILE_PARSER_IRIS_TOKEN)
_org_id = os.getenv(ENV_FILE_PARSER_IRIS_ORG_ID)
pytestmark = pytest.mark.skipif(
not (_token and _org_id),
reason="HINDSIGHT_API_FILE_PARSER_IRIS_TOKEN and HINDSIGHT_API_FILE_PARSER_IRIS_ORG_ID not set",
)
# Minimal valid PDF with the text "Hello from Hindsight"
_SAMPLE_PDF = b"""%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792]
/Contents 4 0 R /Resources << /Font << /F1 << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >> >> >> >>
endobj
4 0 obj
<< /Length 44 >>
stream
BT /F1 12 Tf 100 700 Td (Hello from Hindsight) Tj ET
endstream
endobj
xref
0 5
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000274 00000 n
trailer << /Size 5 /Root 1 0 R >>
startxref
369
%%EOF"""
@pytest.fixture
def iris_parser() -> IrisParser:
return IrisParser(token=_token, org_id=_org_id)
@pytest.mark.asyncio
async def test_iris_parser_converts_pdf(iris_parser: IrisParser):
"""IrisParser should extract text from a valid PDF."""
result = await iris_parser.convert(_SAMPLE_PDF, "sample.pdf")
assert isinstance(result, str)
assert len(result) > 0
@pytest.mark.asyncio
async def test_iris_parser_name(iris_parser: IrisParser):
"""IrisParser.name() should return 'iris'."""
assert iris_parser.name() == "iris"
-41
View File
@@ -352,47 +352,6 @@ class TestMainModuleExtensionLoading:
"main.py should use import string when workers > 1"
assert uvicorn_calls[0]["workers"] == 2
def test_main_sets_keepalive_timeout(self, monkeypatch):
"""
Verify that uvicorn is configured with timeout_keep_alive > aiohttp's
default client keepalive timeout (15s), so the server never closes
connections before the client does.
"""
monkeypatch.setenv("HINDSIGHT_API_WORKERS", "1")
monkeypatch.delenv("HINDSIGHT_API_TENANT_EXTENSION", raising=False)
uvicorn_calls = []
def capture_uvicorn_run(**kwargs):
uvicorn_calls.append(kwargs)
with patch("hindsight_api.main.MemoryEngine") as mock_engine, \
patch("hindsight_api.main.create_app") as mock_create_app, \
patch("hindsight_api.main._get_raw_config") as mock_get_config, \
patch("hindsight_api.main.print_banner"), \
patch("uvicorn.run", side_effect=capture_uvicorn_run):
mock_config = MagicMock()
mock_config.host = "0.0.0.0"
mock_config.port = 8888
mock_config.log_level = "info"
mock_config.mcp_enabled = False
mock_config.run_migrations_on_startup = False
mock_config.database_url = "postgresql://test:test@localhost/test"
mock_get_config.return_value = mock_config
mock_engine.return_value = MagicMock()
mock_create_app.return_value = MagicMock()
with patch.object(sys, 'argv', ['hindsight-api']):
from hindsight_api.main import main
main()
assert len(uvicorn_calls) == 1
assert "timeout_keep_alive" in uvicorn_calls[0], \
"uvicorn config must set timeout_keep_alive"
assert uvicorn_calls[0]["timeout_keep_alive"] > 15, \
"timeout_keep_alive must exceed aiohttp's 15s client default"
# Mock extensions for testing
from hindsight_api.extensions import (
+30 -70
View File
@@ -206,12 +206,8 @@ class TestWorkerPoller:
assert len(claimed) == 3
@pytest.mark.asyncio
async def test_execute_task_executor_marks_completed(self, pool, clean_operations):
"""Test that executor's status marking is preserved by the poller.
The executor (MemoryEngine.execute_task) handles marking operations as completed/failed.
The poller should NOT override those status updates.
"""
async def test_execute_task_marks_completed(self, pool, clean_operations):
"""Test that successful task execution marks task as completed."""
from hindsight_api.worker import WorkerPoller
from hindsight_api.worker.poller import ClaimedTask
@@ -232,16 +228,7 @@ class TestWorkerPoller:
executed = []
async def mock_executor(task_dict):
"""Executor that marks its own status as completed (like MemoryEngine.execute_task)."""
executed.append(task_dict)
await pool.execute(
"""
UPDATE async_operations
SET status = 'completed', completed_at = now(), updated_at = now()
WHERE operation_id = $1
""",
op_id,
)
poller = WorkerPoller(
pool=pool,
@@ -259,7 +246,7 @@ class TestWorkerPoller:
assert completed, "Task did not complete within timeout"
assert len(executed) == 1
# Verify task is marked as completed (by executor, not overridden by poller)
# Verify task is marked as completed
row = await pool.fetchrow(
"SELECT status, completed_at FROM async_operations WHERE operation_id = $1",
op_id,
@@ -268,24 +255,19 @@ class TestWorkerPoller:
assert row["completed_at"] is not None
@pytest.mark.asyncio
async def test_executor_exception_does_not_crash_poller(self, pool, clean_operations):
"""Test that unexpected exceptions from executor are caught and don't crash the poller.
If the executor raises an unexpected exception (which MemoryEngine.execute_task should NOT do,
but could happen from schema setup or other infrastructure issues), the poller should catch it
gracefully. Status remains 'processing' since neither executor nor poller handled it.
"""
async def test_execute_task_retries_on_failure(self, pool, clean_operations):
"""Test that failed task execution triggers retry mechanism."""
from hindsight_api.worker import WorkerPoller
from hindsight_api.worker.poller import ClaimedTask
# Create a pending task
# Create a pending task with retry_count=0
bank_id = f"test-worker-{uuid.uuid4().hex[:8]}"
op_id = uuid.uuid4()
payload = json.dumps({"type": "test_task", "operation_id": str(op_id), "bank_id": bank_id})
await pool.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, status, task_payload, worker_id)
VALUES ($1, $2, 'test', 'processing', $3::jsonb, 'test-worker-1')
INSERT INTO async_operations (operation_id, bank_id, operation_type, status, task_payload, worker_id, retry_count)
VALUES ($1, $2, 'test', 'processing', $3::jsonb, 'test-worker-1', 0)
""",
op_id,
bank_id,
@@ -293,15 +275,16 @@ class TestWorkerPoller:
)
async def failing_executor(task_dict):
raise ValueError("Unexpected infrastructure failure")
raise ValueError("Simulated failure")
poller = WorkerPoller(
pool=pool,
worker_id="test-worker-1",
executor=failing_executor,
max_retries=3,
)
# Execute - should catch exception without crashing
# Execute (should fail and retry) - fire-and-forget
task_dict = json.loads(payload)
claimed_task = ClaimedTask(operation_id=str(op_id), task_dict=task_dict, schema=None)
await poller.execute_task(claimed_task)
@@ -310,84 +293,61 @@ class TestWorkerPoller:
completed = await poller.wait_for_active_tasks(timeout=5.0)
assert completed, "Task did not complete within timeout"
# Status stays 'processing' since the poller no longer manages status
# Verify task is back to pending with incremented retry_count
row = await pool.fetchrow(
"SELECT status FROM async_operations WHERE operation_id = $1",
"SELECT status, retry_count, worker_id FROM async_operations WHERE operation_id = $1",
op_id,
)
assert row["status"] == "processing"
assert row["status"] == "pending"
assert row["retry_count"] == 1
assert row["worker_id"] is None # Worker ID cleared for retry
@pytest.mark.asyncio
async def test_executor_failed_status_not_overridden(self, pool, clean_operations):
"""REGRESSION TEST: Verify poller does NOT overwrite executor's 'failed' status to 'completed'.
This test catches the bug where the poller always called _mark_completed() after executor
returned, overwriting the 'failed' status that the executor had already set.
Scenario:
1. Executor catches an internal error and marks the operation as 'failed' in the DB
2. Executor returns normally (does NOT re-raise) - this is how MemoryEngine.execute_task works
3. The poller must NOT overwrite the 'failed' status to 'completed'
With the old buggy code, this test would FAIL (status would be 'completed').
"""
async def test_execute_task_fails_after_max_retries(self, pool, clean_operations):
"""Test that task is marked failed after exceeding max retries."""
from hindsight_api.worker import WorkerPoller
from hindsight_api.worker.poller import ClaimedTask
# Create a task that has already used all retries
bank_id = f"test-worker-{uuid.uuid4().hex[:8]}"
op_id = uuid.uuid4()
payload = json.dumps({"type": "test_task", "operation_id": str(op_id), "bank_id": bank_id})
await pool.execute(
"""
INSERT INTO async_operations (operation_id, bank_id, operation_type, status, task_payload, worker_id)
VALUES ($1, $2, 'test', 'processing', $3::jsonb, 'test-worker-1')
INSERT INTO async_operations (operation_id, bank_id, operation_type, status, task_payload, worker_id, retry_count)
VALUES ($1, $2, 'test', 'processing', $3::jsonb, 'test-worker-1', 3)
""",
op_id,
bank_id,
payload,
)
async def executor_that_marks_failed(task_dict):
"""Simulates MemoryEngine.execute_task behavior on internal error.
The executor catches the error, marks the operation as 'failed',
and returns normally (does NOT re-raise the exception).
"""
# Simulate internal failure handling (like MemoryEngine._mark_operation_failed)
await pool.execute(
"""
UPDATE async_operations
SET status = 'failed', error_message = $2, completed_at = now(), updated_at = now()
WHERE operation_id = $1
""",
op_id,
"Simulated conversion error: file format not supported",
)
# Returns normally - this is the key: executor does NOT re-raise
async def failing_executor(task_dict):
raise ValueError("Simulated failure")
poller = WorkerPoller(
pool=pool,
worker_id="test-worker-1",
executor=executor_that_marks_failed,
executor=failing_executor,
max_retries=3,
)
# Execute (should fail permanently) - fire-and-forget
task_dict = json.loads(payload)
claimed_task = ClaimedTask(operation_id=str(op_id), task_dict=task_dict, schema=None)
await poller.execute_task(claimed_task)
# Wait for background task to complete
completed = await poller.wait_for_active_tasks(timeout=5.0)
assert completed, "Task did not complete within timeout"
# THE KEY ASSERTION: Status must be 'failed', NOT 'completed'
# Verify task is marked as failed
row = await pool.fetchrow(
"SELECT status, error_message FROM async_operations WHERE operation_id = $1",
op_id,
)
assert row["status"] == "failed", (
f"REGRESSION: Poller overwrote executor's 'failed' status to '{row['status']}'. "
"The poller must not override status set by the executor."
)
assert "Simulated conversion error" in row["error_message"]
assert row["status"] == "failed"
assert "Max retries" in row["error_message"]
@pytest.mark.asyncio
async def test_claim_batch_skips_consolidation_when_same_bank_processing(self, pool, clean_operations):
+2 -2
View File
@@ -20,8 +20,8 @@ clap = { version = "4.5", features = ["derive", "env"] }
# Async runtime
tokio = { version = "1", features = ["full"] }
# HTTP client (for timeout configuration and multipart file uploads)
reqwest = { version = "0.12", features = ["multipart"] }
# HTTP client (for timeout configuration)
reqwest = "0.12"
# Serialization (for config and output formatting)
serde = { version = "1.0", features = ["derive"] }
+2 -70
View File
@@ -58,16 +58,9 @@ pub struct MemoryPutResult {
pub operation_id: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct FileRetainResult {
pub operation_ids: Vec<String>,
}
#[derive(Clone)]
pub struct ApiClient {
client: AsyncClient,
http_client: reqwest::Client,
base_url: String,
runtime: std::sync::Arc<tokio::runtime::Runtime>,
}
@@ -91,8 +84,8 @@ impl ApiClient {
let http_client = client_builder.build()?;
let client = AsyncClient::new_with_client(&base_url, http_client.clone());
Ok(ApiClient { client, http_client, base_url, runtime })
let client = AsyncClient::new_with_client(&base_url, http_client);
Ok(ApiClient { client, runtime })
}
pub fn list_agents(&self, _verbose: bool) -> Result<Vec<types::BankListItem>> {
@@ -175,67 +168,6 @@ impl ApiClient {
})
}
/// Upload files to the file retain endpoint (multipart/form-data).
/// Returns a list of operation IDs for tracking. Always async server-side.
pub fn file_retain(
&self,
bank_id: &str,
files: Vec<(String, Vec<u8>)>,
context: Option<String>,
verbose: bool,
) -> Result<FileRetainResult> {
self.runtime.block_on(async {
let url = format!("{}/v1/default/banks/{}/files/retain", self.base_url, bank_id);
let files_metadata: Vec<serde_json::Value> = files
.iter()
.map(|(name, _)| {
let mut meta = serde_json::json!({});
if let Some(ctx) = &context {
meta["context"] = serde_json::Value::String(ctx.clone());
}
// Use filename stem as document_id for deduplication
if let Some(stem) = std::path::Path::new(name)
.file_stem()
.and_then(|s| s.to_str())
{
meta["document_id"] = serde_json::Value::String(stem.to_string());
}
meta
})
.collect();
let request_json = serde_json::json!({
"files_metadata": files_metadata,
});
let mut form = reqwest::multipart::Form::new()
.text("request", request_json.to_string());
for (filename, content) in files {
let part = reqwest::multipart::Part::bytes(content)
.file_name(filename)
.mime_str("application/octet-stream")?;
form = form.part("files", part);
}
if verbose {
eprintln!("POST {}", url);
}
let response = self.http_client.post(&url).multipart(form).send().await?;
if !response.status().is_success() {
let status = response.status();
let text = response.text().await.unwrap_or_default();
anyhow::bail!("File retain failed ({}): {}", status, text);
}
let result: FileRetainResult = response.json().await?;
Ok(result)
})
}
/// Poll an operation until it completes or fails.
/// Returns Ok(true) if completed successfully, Ok(false) if failed, Err if polling error.
pub fn poll_operation(&self, agent_id: &str, operation_id: &str, verbose: bool) -> Result<(bool, Option<String>)> {
+125 -127
View File
@@ -220,23 +220,14 @@ pub fn get(
}
}
// Helper function to check if a file is supported by the file converter (markitdown)
fn is_supported_file(path: &std::path::Path) -> bool {
const SUPPORTED_EXTENSIONS: &[&str] = &[
// Documents
"pdf", "docx", "doc", "pptx", "ppt", "xlsx", "xls",
// Images (OCR)
"jpg", "jpeg", "png", "gif", "bmp", "webp", "tiff",
// Web / markup
"html", "htm",
// Text / data
"txt", "md", "csv", "json", "yaml", "yml", "toml", "xml", "rst", "adoc", "log",
// Audio (transcription)
"mp3", "wav", "ogg", "flac",
// Helper function to check if a file has a text-based extension
fn is_text_file(path: &std::path::Path) -> bool {
const TEXT_EXTENSIONS: &[&str] = &[
"txt", "md", "json", "yaml", "yml", "toml", "xml", "csv", "log", "rst", "adoc",
];
path.extension()
.and_then(|ext| ext.to_str())
.map(|ext| SUPPORTED_EXTENSIONS.contains(&ext.to_lowercase().as_str()))
.map(|ext| TEXT_EXTENSIONS.contains(&ext.to_lowercase().as_str()))
.unwrap_or(false)
}
@@ -436,10 +427,10 @@ pub fn retain_files(
anyhow::bail!("Path does not exist: {}", path.display());
}
let mut file_paths = Vec::new();
let mut files = Vec::new();
if path.is_file() {
file_paths.push(path);
files.push(path);
} else if path.is_dir() {
if recursive {
for entry in WalkDir::new(&path)
@@ -447,110 +438,133 @@ pub fn retain_files(
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
{
let file_path = entry.path();
if is_supported_file(file_path) {
file_paths.push(file_path.to_path_buf());
let path = entry.path();
if is_text_file(&path) {
files.push(path.to_path_buf());
}
}
} else {
for entry in fs::read_dir(&path)? {
let entry = entry?;
let file_path = entry.path();
if file_path.is_file() && is_supported_file(&file_path) {
file_paths.push(file_path);
let path = entry.path();
if path.is_file() && is_text_file(&path) {
files.push(path);
}
}
}
}
if file_paths.is_empty() {
ui::print_warning("No supported files found. Supported formats: pdf, docx, pptx, xlsx, jpg, png, html, txt, md, csv, mp3, wav, and more.");
if files.is_empty() {
ui::print_warning("No text files found (supported: txt, md, json, yaml, yml, toml, xml, csv, log, rst, adoc)");
return Ok(());
}
ui::print_info(&format!("Found {} file(s) to import", file_paths.len()));
ui::print_info(&format!("Found {} files to import", files.len()));
// Batch files (max 10 per request)
const BATCH_SIZE: usize = 10;
let batches: Vec<&[PathBuf]> = file_paths.chunks(BATCH_SIZE).collect();
let mut all_operation_ids: Vec<String> = Vec::new();
let pb = ui::create_progress_bar(files.len() as u64, "Processing files");
let pb = ui::create_progress_bar(file_paths.len() as u64, "Uploading files");
let mut items = Vec::new();
for batch in &batches {
let mut file_data: Vec<(String, Vec<u8>)> = Vec::new();
for file_path in *batch {
let filename = file_path
.file_name()
.and_then(|n| n.to_str())
.map(|s| s.to_string())
.unwrap_or_else(|| "file".to_string());
let content = fs::read(file_path)
.with_context(|| format!("Failed to read file: {}", file_path.display()))?;
file_data.push((filename, content));
pb.inc(1);
}
for file_path in &files {
let content = fs::read_to_string(file_path)
.with_context(|| format!("Failed to read file: {}", file_path.display()))?;
let result = client.file_retain(agent_id, file_data, context.clone(), verbose)?;
all_operation_ids.extend(result.operation_ids);
let doc_id = file_path
.file_stem()
.and_then(|s| s.to_str())
.map(|s| s.to_string())
.unwrap_or_else(config::generate_doc_id);
items.push(MemoryItem {
content,
context: context.clone(),
metadata: None,
timestamp: None,
document_id: Some(doc_id),
entities: None,
tags: None,
});
pb.inc(1);
}
pb.finish_with_message("Files uploaded");
pb.finish_with_message("Files processed");
if r#async {
if output_format == OutputFormat::Pretty {
ui::print_success("Files queued for processing");
println!(" Files: {}", file_paths.len());
for op_id in &all_operation_ids {
println!(" Operation ID: {}", op_id);
}
} else {
let result = serde_json::json!({ "operation_ids": all_operation_ids });
output::print_output(&result, output_format)?;
}
// Always use async mode for the API call
let request = RetainRequest {
items,
async_: true,
document_tags: None,
};
let spinner = if output_format == OutputFormat::Pretty {
Some(ui::create_spinner("Submitting retain request..."))
} else {
// Poll all operations until they complete
let poll_spinner = if output_format == OutputFormat::Pretty {
Some(ui::create_spinner("Processing files..."))
} else {
None
};
None
};
let mut failed = Vec::new();
for op_id in &all_operation_ids {
let (success, error_msg) = client.poll_operation(agent_id, op_id, verbose)?;
if !success {
failed.push(error_msg.unwrap_or_else(|| "Unknown error".to_string()));
}
}
let response = client.retain(agent_id, &request, true, verbose);
if let Some(mut sp) = poll_spinner {
sp.finish();
}
if let Some(mut sp) = spinner {
sp.finish();
}
if failed.is_empty() {
if output_format == OutputFormat::Pretty {
ui::print_success("Files retained successfully");
println!(" Files processed: {}", file_paths.len());
} else {
let result = serde_json::json!({
"success": true,
"files_count": file_paths.len(),
"operation_ids": all_operation_ids,
});
output::print_output(&result, output_format)?;
}
} else {
for msg in &failed {
match response {
Ok(result) => {
if r#async {
// User requested async mode - return immediately
if output_format == OutputFormat::Pretty {
ui::print_error(&format!("Retain operation failed: {}", msg));
ui::print_success("Files queued for processing");
println!(" Items: {}", result.items_count);
if let Some(op_id) = &result.operation_id {
println!(" Operation ID: {}", op_id);
}
} else {
output::print_output(&result, output_format)?;
}
} else {
// Poll until completion
if let Some(operation_id) = &result.operation_id {
let poll_spinner = if output_format == OutputFormat::Pretty {
Some(ui::create_spinner("Processing memories..."))
} else {
None
};
let (success, error_msg) = client.poll_operation(agent_id, operation_id, verbose)?;
if let Some(mut sp) = poll_spinner {
sp.finish();
}
if success {
if output_format == OutputFormat::Pretty {
ui::print_success("Files retained successfully");
println!(" Items processed: {}", result.items_count);
} else {
output::print_output(&result, output_format)?;
}
} else {
let msg = error_msg.unwrap_or_else(|| "Unknown error".to_string());
if output_format == OutputFormat::Pretty {
ui::print_error(&format!("Retain operation failed: {}", msg));
}
anyhow::bail!("Retain operation failed: {}", msg);
}
} else {
// No operation ID returned, shouldn't happen with async=true
if output_format == OutputFormat::Pretty {
ui::print_success("Files retained successfully");
println!(" Items processed: {}", result.items_count);
} else {
output::print_output(&result, output_format)?;
}
}
}
anyhow::bail!("{} operation(s) failed", failed.len());
Ok(())
}
Err(e) => Err(e)
}
Ok(())
}
pub fn delete(
@@ -665,71 +679,55 @@ mod tests {
use std::path::Path;
#[test]
fn test_is_supported_file_text_extensions() {
fn test_is_text_file_supported_extensions() {
let supported = [
"file.txt", "file.md", "file.json", "file.yaml", "file.yml",
"file.toml", "file.xml", "file.csv", "file.log", "file.rst", "file.adoc",
];
for filename in supported {
assert!(
is_supported_file(Path::new(filename)),
"{} should be recognized as a supported file",
is_text_file(Path::new(filename)),
"{} should be recognized as a text file",
filename
);
}
}
#[test]
fn test_is_supported_file_binary_extensions() {
let supported = [
"file.pdf", "file.docx", "file.pptx", "file.xlsx",
"file.png", "file.jpg", "file.jpeg", "file.gif",
"file.mp3", "file.wav",
];
for filename in supported {
assert!(
is_supported_file(Path::new(filename)),
"{} should be recognized as a supported file",
filename
);
}
fn test_is_text_file_case_insensitive() {
assert!(is_text_file(Path::new("file.JSON")));
assert!(is_text_file(Path::new("file.TXT")));
assert!(is_text_file(Path::new("file.Md")));
assert!(is_text_file(Path::new("file.YAML")));
}
#[test]
fn test_is_supported_file_case_insensitive() {
assert!(is_supported_file(Path::new("file.JSON")));
assert!(is_supported_file(Path::new("file.TXT")));
assert!(is_supported_file(Path::new("file.Md")));
assert!(is_supported_file(Path::new("file.YAML")));
assert!(is_supported_file(Path::new("file.PDF")));
}
#[test]
fn test_is_supported_file_unsupported_extensions() {
fn test_is_text_file_unsupported_extensions() {
let unsupported = [
"file.pdf", "file.doc", "file.docx", "file.png", "file.jpg",
"file.exe", "file.bin", "file.zip", "file.tar", "file.gz",
];
for filename in unsupported {
assert!(
!is_supported_file(Path::new(filename)),
"{} should NOT be recognized as a supported file",
!is_text_file(Path::new(filename)),
"{} should NOT be recognized as a text file",
filename
);
}
}
#[test]
fn test_is_supported_file_no_extension() {
assert!(!is_supported_file(Path::new("README")));
assert!(!is_supported_file(Path::new("Makefile")));
assert!(!is_supported_file(Path::new(".gitignore")));
fn test_is_text_file_no_extension() {
assert!(!is_text_file(Path::new("README")));
assert!(!is_text_file(Path::new("Makefile")));
assert!(!is_text_file(Path::new(".gitignore")));
}
#[test]
fn test_is_supported_file_with_path() {
assert!(is_supported_file(Path::new("/some/path/to/file.json")));
assert!(is_supported_file(Path::new("../relative/path/file.md")));
assert!(is_supported_file(Path::new("/path/to/image.png")));
fn test_is_text_file_with_path() {
assert!(is_text_file(Path::new("/some/path/to/file.json")));
assert!(is_text_file(Path::new("../relative/path/file.md")));
assert!(!is_text_file(Path::new("/path/to/image.png")));
}
#[test]
-24
View File
@@ -1,24 +0,0 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
-226
View File
@@ -1,226 +0,0 @@
# Go API client for hindsight
HTTP API for Hindsight
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) 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:
```sh
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:
```go
import hindsight "github.com/vectorize-io/hindsight-client-go"
```
To use a proxy, set the environment variable `HTTP_PROXY`:
```go
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`.
```go
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`.
```go
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.
```go
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**](docs/BanksAPI.md#addbankbackground) | **Post** /v1/default/banks/{bank_id}/background | Add/merge memory bank background (deprecated)
*BanksAPI* | [**ClearObservations**](docs/BanksAPI.md#clearobservations) | **Delete** /v1/default/banks/{bank_id}/observations | Clear all observations
*BanksAPI* | [**CreateOrUpdateBank**](docs/BanksAPI.md#createorupdatebank) | **Put** /v1/default/banks/{bank_id} | Create or update memory bank
*BanksAPI* | [**DeleteBank**](docs/BanksAPI.md#deletebank) | **Delete** /v1/default/banks/{bank_id} | Delete memory bank
*BanksAPI* | [**GetAgentStats**](docs/BanksAPI.md#getagentstats) | **Get** /v1/default/banks/{bank_id}/stats | Get statistics for memory bank
*BanksAPI* | [**GetBankConfig**](docs/BanksAPI.md#getbankconfig) | **Get** /v1/default/banks/{bank_id}/config | Get bank configuration
*BanksAPI* | [**GetBankProfile**](docs/BanksAPI.md#getbankprofile) | **Get** /v1/default/banks/{bank_id}/profile | Get memory bank profile
*BanksAPI* | [**ListBanks**](docs/BanksAPI.md#listbanks) | **Get** /v1/default/banks | List all memory banks
*BanksAPI* | [**ResetBankConfig**](docs/BanksAPI.md#resetbankconfig) | **Delete** /v1/default/banks/{bank_id}/config | Reset bank configuration
*BanksAPI* | [**TriggerConsolidation**](docs/BanksAPI.md#triggerconsolidation) | **Post** /v1/default/banks/{bank_id}/consolidate | Trigger consolidation
*BanksAPI* | [**UpdateBank**](docs/BanksAPI.md#updatebank) | **Patch** /v1/default/banks/{bank_id} | Partial update memory bank
*BanksAPI* | [**UpdateBankConfig**](docs/BanksAPI.md#updatebankconfig) | **Patch** /v1/default/banks/{bank_id}/config | Update bank configuration
*BanksAPI* | [**UpdateBankDisposition**](docs/BanksAPI.md#updatebankdisposition) | **Put** /v1/default/banks/{bank_id}/profile | Update memory bank disposition
*DirectivesAPI* | [**CreateDirective**](docs/DirectivesAPI.md#createdirective) | **Post** /v1/default/banks/{bank_id}/directives | Create directive
*DirectivesAPI* | [**DeleteDirective**](docs/DirectivesAPI.md#deletedirective) | **Delete** /v1/default/banks/{bank_id}/directives/{directive_id} | Delete directive
*DirectivesAPI* | [**GetDirective**](docs/DirectivesAPI.md#getdirective) | **Get** /v1/default/banks/{bank_id}/directives/{directive_id} | Get directive
*DirectivesAPI* | [**ListDirectives**](docs/DirectivesAPI.md#listdirectives) | **Get** /v1/default/banks/{bank_id}/directives | List directives
*DirectivesAPI* | [**UpdateDirective**](docs/DirectivesAPI.md#updatedirective) | **Patch** /v1/default/banks/{bank_id}/directives/{directive_id} | Update directive
*DocumentsAPI* | [**DeleteDocument**](docs/DocumentsAPI.md#deletedocument) | **Delete** /v1/default/banks/{bank_id}/documents/{document_id} | Delete a document
*DocumentsAPI* | [**GetChunk**](docs/DocumentsAPI.md#getchunk) | **Get** /v1/default/chunks/{chunk_id} | Get chunk details
*DocumentsAPI* | [**GetDocument**](docs/DocumentsAPI.md#getdocument) | **Get** /v1/default/banks/{bank_id}/documents/{document_id} | Get document details
*DocumentsAPI* | [**ListDocuments**](docs/DocumentsAPI.md#listdocuments) | **Get** /v1/default/banks/{bank_id}/documents | List documents
*EntitiesAPI* | [**GetEntity**](docs/EntitiesAPI.md#getentity) | **Get** /v1/default/banks/{bank_id}/entities/{entity_id} | Get entity details
*EntitiesAPI* | [**ListEntities**](docs/EntitiesAPI.md#listentities) | **Get** /v1/default/banks/{bank_id}/entities | List entities
*EntitiesAPI* | [**RegenerateEntityObservations**](docs/EntitiesAPI.md#regenerateentityobservations) | **Post** /v1/default/banks/{bank_id}/entities/{entity_id}/regenerate | Regenerate entity observations (deprecated)
*MemoryAPI* | [**ClearBankMemories**](docs/MemoryAPI.md#clearbankmemories) | **Delete** /v1/default/banks/{bank_id}/memories | Clear memory bank memories
*MemoryAPI* | [**GetGraph**](docs/MemoryAPI.md#getgraph) | **Get** /v1/default/banks/{bank_id}/graph | Get memory graph data
*MemoryAPI* | [**GetMemory**](docs/MemoryAPI.md#getmemory) | **Get** /v1/default/banks/{bank_id}/memories/{memory_id} | Get memory unit
*MemoryAPI* | [**ListMemories**](docs/MemoryAPI.md#listmemories) | **Get** /v1/default/banks/{bank_id}/memories/list | List memory units
*MemoryAPI* | [**ListTags**](docs/MemoryAPI.md#listtags) | **Get** /v1/default/banks/{bank_id}/tags | List tags
*MemoryAPI* | [**RecallMemories**](docs/MemoryAPI.md#recallmemories) | **Post** /v1/default/banks/{bank_id}/memories/recall | Recall memory
*MemoryAPI* | [**Reflect**](docs/MemoryAPI.md#reflect) | **Post** /v1/default/banks/{bank_id}/reflect | Reflect and generate answer
*MemoryAPI* | [**RetainMemories**](docs/MemoryAPI.md#retainmemories) | **Post** /v1/default/banks/{bank_id}/memories | Retain memories
*MentalModelsAPI* | [**CreateMentalModel**](docs/MentalModelsAPI.md#creatementalmodel) | **Post** /v1/default/banks/{bank_id}/mental-models | Create mental model
*MentalModelsAPI* | [**DeleteMentalModel**](docs/MentalModelsAPI.md#deletementalmodel) | **Delete** /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Delete mental model
*MentalModelsAPI* | [**GetMentalModel**](docs/MentalModelsAPI.md#getmentalmodel) | **Get** /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Get mental model
*MentalModelsAPI* | [**ListMentalModels**](docs/MentalModelsAPI.md#listmentalmodels) | **Get** /v1/default/banks/{bank_id}/mental-models | List mental models
*MentalModelsAPI* | [**RefreshMentalModel**](docs/MentalModelsAPI.md#refreshmentalmodel) | **Post** /v1/default/banks/{bank_id}/mental-models/{mental_model_id}/refresh | Refresh mental model
*MentalModelsAPI* | [**UpdateMentalModel**](docs/MentalModelsAPI.md#updatementalmodel) | **Patch** /v1/default/banks/{bank_id}/mental-models/{mental_model_id} | Update mental model
*MonitoringAPI* | [**GetVersion**](docs/MonitoringAPI.md#getversion) | **Get** /version | Get API version and feature flags
*MonitoringAPI* | [**HealthEndpointHealthGet**](docs/MonitoringAPI.md#healthendpointhealthget) | **Get** /health | Health check endpoint
*MonitoringAPI* | [**MetricsEndpointMetricsGet**](docs/MonitoringAPI.md#metricsendpointmetricsget) | **Get** /metrics | Prometheus metrics endpoint
*OperationsAPI* | [**CancelOperation**](docs/OperationsAPI.md#canceloperation) | **Delete** /v1/default/banks/{bank_id}/operations/{operation_id} | Cancel a pending async operation
*OperationsAPI* | [**GetOperationStatus**](docs/OperationsAPI.md#getoperationstatus) | **Get** /v1/default/banks/{bank_id}/operations/{operation_id} | Get operation status
*OperationsAPI* | [**ListOperations**](docs/OperationsAPI.md#listoperations) | **Get** /v1/default/banks/{bank_id}/operations | List async operations
## Documentation For Models
- [AddBackgroundRequest](docs/AddBackgroundRequest.md)
- [AsyncOperationSubmitResponse](docs/AsyncOperationSubmitResponse.md)
- [BackgroundResponse](docs/BackgroundResponse.md)
- [BankConfigResponse](docs/BankConfigResponse.md)
- [BankConfigUpdate](docs/BankConfigUpdate.md)
- [BankListItem](docs/BankListItem.md)
- [BankListResponse](docs/BankListResponse.md)
- [BankProfileResponse](docs/BankProfileResponse.md)
- [BankStatsResponse](docs/BankStatsResponse.md)
- [Budget](docs/Budget.md)
- [CancelOperationResponse](docs/CancelOperationResponse.md)
- [ChunkData](docs/ChunkData.md)
- [ChunkIncludeOptions](docs/ChunkIncludeOptions.md)
- [ChunkResponse](docs/ChunkResponse.md)
- [ConsolidationResponse](docs/ConsolidationResponse.md)
- [CreateBankRequest](docs/CreateBankRequest.md)
- [CreateDirectiveRequest](docs/CreateDirectiveRequest.md)
- [CreateMentalModelRequest](docs/CreateMentalModelRequest.md)
- [CreateMentalModelResponse](docs/CreateMentalModelResponse.md)
- [DeleteDocumentResponse](docs/DeleteDocumentResponse.md)
- [DeleteResponse](docs/DeleteResponse.md)
- [DirectiveListResponse](docs/DirectiveListResponse.md)
- [DirectiveResponse](docs/DirectiveResponse.md)
- [DispositionTraits](docs/DispositionTraits.md)
- [DocumentResponse](docs/DocumentResponse.md)
- [EntityDetailResponse](docs/EntityDetailResponse.md)
- [EntityIncludeOptions](docs/EntityIncludeOptions.md)
- [EntityInput](docs/EntityInput.md)
- [EntityListItem](docs/EntityListItem.md)
- [EntityListResponse](docs/EntityListResponse.md)
- [EntityObservationResponse](docs/EntityObservationResponse.md)
- [EntityStateResponse](docs/EntityStateResponse.md)
- [FeaturesInfo](docs/FeaturesInfo.md)
- [GraphDataResponse](docs/GraphDataResponse.md)
- [HTTPValidationError](docs/HTTPValidationError.md)
- [IncludeOptions](docs/IncludeOptions.md)
- [ListDocumentsResponse](docs/ListDocumentsResponse.md)
- [ListMemoryUnitsResponse](docs/ListMemoryUnitsResponse.md)
- [ListTagsResponse](docs/ListTagsResponse.md)
- [MemoryItem](docs/MemoryItem.md)
- [MentalModelListResponse](docs/MentalModelListResponse.md)
- [MentalModelResponse](docs/MentalModelResponse.md)
- [MentalModelTrigger](docs/MentalModelTrigger.md)
- [OperationResponse](docs/OperationResponse.md)
- [OperationStatusResponse](docs/OperationStatusResponse.md)
- [OperationsListResponse](docs/OperationsListResponse.md)
- [RecallRequest](docs/RecallRequest.md)
- [RecallResponse](docs/RecallResponse.md)
- [RecallResult](docs/RecallResult.md)
- [ReflectBasedOn](docs/ReflectBasedOn.md)
- [ReflectDirective](docs/ReflectDirective.md)
- [ReflectFact](docs/ReflectFact.md)
- [ReflectIncludeOptions](docs/ReflectIncludeOptions.md)
- [ReflectLLMCall](docs/ReflectLLMCall.md)
- [ReflectMentalModel](docs/ReflectMentalModel.md)
- [ReflectRequest](docs/ReflectRequest.md)
- [ReflectResponse](docs/ReflectResponse.md)
- [ReflectToolCall](docs/ReflectToolCall.md)
- [ReflectTrace](docs/ReflectTrace.md)
- [RetainRequest](docs/RetainRequest.md)
- [RetainResponse](docs/RetainResponse.md)
- [TagItem](docs/TagItem.md)
- [TokenUsage](docs/TokenUsage.md)
- [ToolCallsIncludeOptions](docs/ToolCallsIncludeOptions.md)
- [UpdateDirectiveRequest](docs/UpdateDirectiveRequest.md)
- [UpdateDispositionRequest](docs/UpdateDispositionRequest.md)
- [UpdateMentalModelRequest](docs/UpdateMentalModelRequest.md)
- [ValidationError](docs/ValidationError.md)
- [ValidationErrorLocInner](docs/ValidationErrorLocInner.md)
- [VersionResponse](docs/VersionResponse.md)
## 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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-737
View File
@@ -1,737 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
"reflect"
)
// DirectivesAPIService DirectivesAPI service
type DirectivesAPIService service
type ApiCreateDirectiveRequest struct {
ctx context.Context
ApiService *DirectivesAPIService
bankId string
createDirectiveRequest *CreateDirectiveRequest
authorization *string
}
func (r ApiCreateDirectiveRequest) CreateDirectiveRequest(createDirectiveRequest CreateDirectiveRequest) ApiCreateDirectiveRequest {
r.createDirectiveRequest = &createDirectiveRequest
return r
}
func (r ApiCreateDirectiveRequest) Authorization(authorization string) ApiCreateDirectiveRequest {
r.authorization = &authorization
return r
}
func (r ApiCreateDirectiveRequest) Execute() (*DirectiveResponse, *http.Response, error) {
return r.ApiService.CreateDirectiveExecute(r)
}
/*
CreateDirective Create directive
Create a hard rule that will be injected into prompts.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiCreateDirectiveRequest
*/
func (a *DirectivesAPIService) CreateDirective(ctx context.Context, bankId string) ApiCreateDirectiveRequest {
return ApiCreateDirectiveRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return DirectiveResponse
func (a *DirectivesAPIService) CreateDirectiveExecute(r ApiCreateDirectiveRequest) (*DirectiveResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DirectiveResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DirectivesAPIService.CreateDirective")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/directives"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.createDirectiveRequest == nil {
return localVarReturnValue, nil, reportError("createDirectiveRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
// body params
localVarPostBody = r.createDirectiveRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiDeleteDirectiveRequest struct {
ctx context.Context
ApiService *DirectivesAPIService
bankId string
directiveId string
authorization *string
}
func (r ApiDeleteDirectiveRequest) Authorization(authorization string) ApiDeleteDirectiveRequest {
r.authorization = &authorization
return r
}
func (r ApiDeleteDirectiveRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.DeleteDirectiveExecute(r)
}
/*
DeleteDirective Delete directive
Delete a directive.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param directiveId
@return ApiDeleteDirectiveRequest
*/
func (a *DirectivesAPIService) DeleteDirective(ctx context.Context, bankId string, directiveId string) ApiDeleteDirectiveRequest {
return ApiDeleteDirectiveRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
directiveId: directiveId,
}
}
// Execute executes the request
// @return interface{}
func (a *DirectivesAPIService) DeleteDirectiveExecute(r ApiDeleteDirectiveRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DirectivesAPIService.DeleteDirective")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/directives/{directive_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"directive_id"+"}", url.PathEscape(parameterValueToString(r.directiveId, "directiveId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetDirectiveRequest struct {
ctx context.Context
ApiService *DirectivesAPIService
bankId string
directiveId string
authorization *string
}
func (r ApiGetDirectiveRequest) Authorization(authorization string) ApiGetDirectiveRequest {
r.authorization = &authorization
return r
}
func (r ApiGetDirectiveRequest) Execute() (*DirectiveResponse, *http.Response, error) {
return r.ApiService.GetDirectiveExecute(r)
}
/*
GetDirective Get directive
Get a specific directive by ID.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param directiveId
@return ApiGetDirectiveRequest
*/
func (a *DirectivesAPIService) GetDirective(ctx context.Context, bankId string, directiveId string) ApiGetDirectiveRequest {
return ApiGetDirectiveRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
directiveId: directiveId,
}
}
// Execute executes the request
// @return DirectiveResponse
func (a *DirectivesAPIService) GetDirectiveExecute(r ApiGetDirectiveRequest) (*DirectiveResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DirectiveResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DirectivesAPIService.GetDirective")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/directives/{directive_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"directive_id"+"}", url.PathEscape(parameterValueToString(r.directiveId, "directiveId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListDirectivesRequest struct {
ctx context.Context
ApiService *DirectivesAPIService
bankId string
tags *[]string
tagsMatch *string
activeOnly *bool
limit *int32
offset *int32
authorization *string
}
// Filter by tags
func (r ApiListDirectivesRequest) Tags(tags []string) ApiListDirectivesRequest {
r.tags = &tags
return r
}
// How to match tags
func (r ApiListDirectivesRequest) TagsMatch(tagsMatch string) ApiListDirectivesRequest {
r.tagsMatch = &tagsMatch
return r
}
// Only return active directives
func (r ApiListDirectivesRequest) ActiveOnly(activeOnly bool) ApiListDirectivesRequest {
r.activeOnly = &activeOnly
return r
}
func (r ApiListDirectivesRequest) Limit(limit int32) ApiListDirectivesRequest {
r.limit = &limit
return r
}
func (r ApiListDirectivesRequest) Offset(offset int32) ApiListDirectivesRequest {
r.offset = &offset
return r
}
func (r ApiListDirectivesRequest) Authorization(authorization string) ApiListDirectivesRequest {
r.authorization = &authorization
return r
}
func (r ApiListDirectivesRequest) Execute() (*DirectiveListResponse, *http.Response, error) {
return r.ApiService.ListDirectivesExecute(r)
}
/*
ListDirectives List directives
List hard rules that are injected into prompts.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiListDirectivesRequest
*/
func (a *DirectivesAPIService) ListDirectives(ctx context.Context, bankId string) ApiListDirectivesRequest {
return ApiListDirectivesRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return DirectiveListResponse
func (a *DirectivesAPIService) ListDirectivesExecute(r ApiListDirectivesRequest) (*DirectiveListResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DirectiveListResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DirectivesAPIService.ListDirectives")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/directives"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.tags != nil {
t := *r.tags
if reflect.TypeOf(t).Kind() == reflect.Slice {
s := reflect.ValueOf(t)
for i := 0; i < s.Len(); i++ {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags", s.Index(i).Interface(), "form", "multi")
}
} else {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags", t, "form", "multi")
}
}
if r.tagsMatch != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags_match", r.tagsMatch, "form", "")
} else {
var defaultValue string = "any"
r.tagsMatch = &defaultValue
}
if r.activeOnly != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "active_only", r.activeOnly, "form", "")
} else {
var defaultValue bool = true
r.activeOnly = &defaultValue
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
} else {
var defaultValue int32 = 100
r.limit = &defaultValue
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
} else {
var defaultValue int32 = 0
r.offset = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiUpdateDirectiveRequest struct {
ctx context.Context
ApiService *DirectivesAPIService
bankId string
directiveId string
updateDirectiveRequest *UpdateDirectiveRequest
authorization *string
}
func (r ApiUpdateDirectiveRequest) UpdateDirectiveRequest(updateDirectiveRequest UpdateDirectiveRequest) ApiUpdateDirectiveRequest {
r.updateDirectiveRequest = &updateDirectiveRequest
return r
}
func (r ApiUpdateDirectiveRequest) Authorization(authorization string) ApiUpdateDirectiveRequest {
r.authorization = &authorization
return r
}
func (r ApiUpdateDirectiveRequest) Execute() (*DirectiveResponse, *http.Response, error) {
return r.ApiService.UpdateDirectiveExecute(r)
}
/*
UpdateDirective Update directive
Update a directive's properties.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param directiveId
@return ApiUpdateDirectiveRequest
*/
func (a *DirectivesAPIService) UpdateDirective(ctx context.Context, bankId string, directiveId string) ApiUpdateDirectiveRequest {
return ApiUpdateDirectiveRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
directiveId: directiveId,
}
}
// Execute executes the request
// @return DirectiveResponse
func (a *DirectivesAPIService) UpdateDirectiveExecute(r ApiUpdateDirectiveRequest) (*DirectiveResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DirectiveResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DirectivesAPIService.UpdateDirective")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/directives/{directive_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"directive_id"+"}", url.PathEscape(parameterValueToString(r.directiveId, "directiveId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.updateDirectiveRequest == nil {
return localVarReturnValue, nil, reportError("updateDirectiveRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
// body params
localVarPostBody = r.updateDirectiveRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-560
View File
@@ -1,560 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// DocumentsAPIService DocumentsAPI service
type DocumentsAPIService service
type ApiDeleteDocumentRequest struct {
ctx context.Context
ApiService *DocumentsAPIService
bankId string
documentId string
authorization *string
}
func (r ApiDeleteDocumentRequest) Authorization(authorization string) ApiDeleteDocumentRequest {
r.authorization = &authorization
return r
}
func (r ApiDeleteDocumentRequest) Execute() (*DeleteDocumentResponse, *http.Response, error) {
return r.ApiService.DeleteDocumentExecute(r)
}
/*
DeleteDocument Delete a document
Delete a document and all its associated memory units and links.
This will cascade delete:
- The document itself
- All memory units extracted from this document
- All links (temporal, semantic, entity) associated with those memory units
This operation cannot be undone.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param documentId
@return ApiDeleteDocumentRequest
*/
func (a *DocumentsAPIService) DeleteDocument(ctx context.Context, bankId string, documentId string) ApiDeleteDocumentRequest {
return ApiDeleteDocumentRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
documentId: documentId,
}
}
// Execute executes the request
// @return DeleteDocumentResponse
func (a *DocumentsAPIService) DeleteDocumentExecute(r ApiDeleteDocumentRequest) (*DeleteDocumentResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DeleteDocumentResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DocumentsAPIService.DeleteDocument")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/documents/{document_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"document_id"+"}", url.PathEscape(parameterValueToString(r.documentId, "documentId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetChunkRequest struct {
ctx context.Context
ApiService *DocumentsAPIService
chunkId string
authorization *string
}
func (r ApiGetChunkRequest) Authorization(authorization string) ApiGetChunkRequest {
r.authorization = &authorization
return r
}
func (r ApiGetChunkRequest) Execute() (*ChunkResponse, *http.Response, error) {
return r.ApiService.GetChunkExecute(r)
}
/*
GetChunk Get chunk details
Get a specific chunk by its ID
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param chunkId
@return ApiGetChunkRequest
*/
func (a *DocumentsAPIService) GetChunk(ctx context.Context, chunkId string) ApiGetChunkRequest {
return ApiGetChunkRequest{
ApiService: a,
ctx: ctx,
chunkId: chunkId,
}
}
// Execute executes the request
// @return ChunkResponse
func (a *DocumentsAPIService) GetChunkExecute(r ApiGetChunkRequest) (*ChunkResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ChunkResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DocumentsAPIService.GetChunk")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/chunks/{chunk_id}"
localVarPath = strings.Replace(localVarPath, "{"+"chunk_id"+"}", url.PathEscape(parameterValueToString(r.chunkId, "chunkId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetDocumentRequest struct {
ctx context.Context
ApiService *DocumentsAPIService
bankId string
documentId string
authorization *string
}
func (r ApiGetDocumentRequest) Authorization(authorization string) ApiGetDocumentRequest {
r.authorization = &authorization
return r
}
func (r ApiGetDocumentRequest) Execute() (*DocumentResponse, *http.Response, error) {
return r.ApiService.GetDocumentExecute(r)
}
/*
GetDocument Get document details
Get a specific document including its original text
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param documentId
@return ApiGetDocumentRequest
*/
func (a *DocumentsAPIService) GetDocument(ctx context.Context, bankId string, documentId string) ApiGetDocumentRequest {
return ApiGetDocumentRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
documentId: documentId,
}
}
// Execute executes the request
// @return DocumentResponse
func (a *DocumentsAPIService) GetDocumentExecute(r ApiGetDocumentRequest) (*DocumentResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *DocumentResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DocumentsAPIService.GetDocument")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/documents/{document_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"document_id"+"}", url.PathEscape(parameterValueToString(r.documentId, "documentId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListDocumentsRequest struct {
ctx context.Context
ApiService *DocumentsAPIService
bankId string
q *string
limit *int32
offset *int32
authorization *string
}
func (r ApiListDocumentsRequest) Q(q string) ApiListDocumentsRequest {
r.q = &q
return r
}
func (r ApiListDocumentsRequest) Limit(limit int32) ApiListDocumentsRequest {
r.limit = &limit
return r
}
func (r ApiListDocumentsRequest) Offset(offset int32) ApiListDocumentsRequest {
r.offset = &offset
return r
}
func (r ApiListDocumentsRequest) Authorization(authorization string) ApiListDocumentsRequest {
r.authorization = &authorization
return r
}
func (r ApiListDocumentsRequest) Execute() (*ListDocumentsResponse, *http.Response, error) {
return r.ApiService.ListDocumentsExecute(r)
}
/*
ListDocuments List documents
List documents with pagination and optional search. Documents are the source content from which memory units are extracted.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiListDocumentsRequest
*/
func (a *DocumentsAPIService) ListDocuments(ctx context.Context, bankId string) ApiListDocumentsRequest {
return ApiListDocumentsRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return ListDocumentsResponse
func (a *DocumentsAPIService) ListDocumentsExecute(r ApiListDocumentsRequest) (*ListDocumentsResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ListDocumentsResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DocumentsAPIService.ListDocuments")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/documents"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.q != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "q", r.q, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
} else {
var defaultValue int32 = 100
r.limit = &defaultValue
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
} else {
var defaultValue int32 = 0
r.offset = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-427
View File
@@ -1,427 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// EntitiesAPIService EntitiesAPI service
type EntitiesAPIService service
type ApiGetEntityRequest struct {
ctx context.Context
ApiService *EntitiesAPIService
bankId string
entityId string
authorization *string
}
func (r ApiGetEntityRequest) Authorization(authorization string) ApiGetEntityRequest {
r.authorization = &authorization
return r
}
func (r ApiGetEntityRequest) Execute() (*EntityDetailResponse, *http.Response, error) {
return r.ApiService.GetEntityExecute(r)
}
/*
GetEntity Get entity details
Get detailed information about an entity including observations (mental model).
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param entityId
@return ApiGetEntityRequest
*/
func (a *EntitiesAPIService) GetEntity(ctx context.Context, bankId string, entityId string) ApiGetEntityRequest {
return ApiGetEntityRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
entityId: entityId,
}
}
// Execute executes the request
// @return EntityDetailResponse
func (a *EntitiesAPIService) GetEntityExecute(r ApiGetEntityRequest) (*EntityDetailResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EntityDetailResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitiesAPIService.GetEntity")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/entities/{entity_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"entity_id"+"}", url.PathEscape(parameterValueToString(r.entityId, "entityId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListEntitiesRequest struct {
ctx context.Context
ApiService *EntitiesAPIService
bankId string
limit *int32
offset *int32
authorization *string
}
// Maximum number of entities to return
func (r ApiListEntitiesRequest) Limit(limit int32) ApiListEntitiesRequest {
r.limit = &limit
return r
}
// Offset for pagination
func (r ApiListEntitiesRequest) Offset(offset int32) ApiListEntitiesRequest {
r.offset = &offset
return r
}
func (r ApiListEntitiesRequest) Authorization(authorization string) ApiListEntitiesRequest {
r.authorization = &authorization
return r
}
func (r ApiListEntitiesRequest) Execute() (*EntityListResponse, *http.Response, error) {
return r.ApiService.ListEntitiesExecute(r)
}
/*
ListEntities List entities
List all entities (people, organizations, etc.) known by the bank, ordered by mention count. Supports pagination.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiListEntitiesRequest
*/
func (a *EntitiesAPIService) ListEntities(ctx context.Context, bankId string) ApiListEntitiesRequest {
return ApiListEntitiesRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return EntityListResponse
func (a *EntitiesAPIService) ListEntitiesExecute(r ApiListEntitiesRequest) (*EntityListResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EntityListResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitiesAPIService.ListEntities")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/entities"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
} else {
var defaultValue int32 = 100
r.limit = &defaultValue
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
} else {
var defaultValue int32 = 0
r.offset = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiRegenerateEntityObservationsRequest struct {
ctx context.Context
ApiService *EntitiesAPIService
bankId string
entityId string
authorization *string
}
func (r ApiRegenerateEntityObservationsRequest) Authorization(authorization string) ApiRegenerateEntityObservationsRequest {
r.authorization = &authorization
return r
}
func (r ApiRegenerateEntityObservationsRequest) Execute() (*EntityDetailResponse, *http.Response, error) {
return r.ApiService.RegenerateEntityObservationsExecute(r)
}
/*
RegenerateEntityObservations Regenerate entity observations (deprecated)
This endpoint is deprecated. Entity observations have been replaced by mental models.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param entityId
@return ApiRegenerateEntityObservationsRequest
Deprecated
*/
func (a *EntitiesAPIService) RegenerateEntityObservations(ctx context.Context, bankId string, entityId string) ApiRegenerateEntityObservationsRequest {
return ApiRegenerateEntityObservationsRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
entityId: entityId,
}
}
// Execute executes the request
// @return EntityDetailResponse
// Deprecated
func (a *EntitiesAPIService) RegenerateEntityObservationsExecute(r ApiRegenerateEntityObservationsRequest) (*EntityDetailResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *EntityDetailResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EntitiesAPIService.RegenerateEntityObservations")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/entities/{entity_id}/regenerate"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"entity_id"+"}", url.PathEscape(parameterValueToString(r.entityId, "entityId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-209
View File
@@ -1,209 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"os"
"strings"
)
// FilesAPIService FilesAPI service
type FilesAPIService service
type ApiFileRetainRequest struct {
ctx context.Context
ApiService *FilesAPIService
bankId string
files []*os.File
request *string
authorization *string
}
// Files to upload and convert
func (r ApiFileRetainRequest) Files(files []*os.File) ApiFileRetainRequest {
r.files = files
return r
}
// JSON string with FileRetainRequest model
func (r ApiFileRetainRequest) Request(request string) ApiFileRetainRequest {
r.request = &request
return r
}
func (r ApiFileRetainRequest) Authorization(authorization string) ApiFileRetainRequest {
r.authorization = &authorization
return r
}
func (r ApiFileRetainRequest) Execute() (*FileRetainResponse, *http.Response, error) {
return r.ApiService.FileRetainExecute(r)
}
/*
FileRetain Convert files to memories
Upload files (PDF, DOCX, etc.), convert them to markdown, and retain as memories.
This endpoint handles file upload, conversion, and memory creation in a single operation.
**Features:**
- Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription)
- Automatic file-to-markdown conversion using pluggable parsers
- Files stored in object storage (PostgreSQL by default, S3 for production)
- Each file becomes a separate document with optional metadata/tags
- Always processes asynchronously returns operation IDs immediately
**The system automatically:**
1. Stores uploaded files in object storage
2. Converts files to markdown
3. Creates document records with file metadata
4. Extracts facts and creates memory units (same as regular retain)
Use the operations endpoint to monitor progress.
**Request format:** multipart/form-data with:
- `files`: One or more files to upload
- `request`: JSON string with FileRetainRequest model (files_metadata)
**Note:** File parser is configured server-side via `HINDSIGHT_API_FILE_PARSER` (default: markitdown).
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiFileRetainRequest
*/
func (a *FilesAPIService) FileRetain(ctx context.Context, bankId string) ApiFileRetainRequest {
return ApiFileRetainRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return FileRetainResponse
func (a *FilesAPIService) FileRetainExecute(r ApiFileRetainRequest) (*FileRetainResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *FileRetainResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FilesAPIService.FileRetain")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/files/retain"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.files == nil {
return localVarReturnValue, nil, reportError("files is required and must be specified")
}
if r.request == nil {
return localVarReturnValue, nil, reportError("request is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"multipart/form-data"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
var filesLocalVarFormFileName string
var filesLocalVarFileName string
var filesLocalVarFileBytes []byte
filesLocalVarFormFileName = "files"
filesLocalVarFile := r.files
if filesLocalVarFile != nil {
// loop through the array to prepare multiple files upload
for _, filesLocalVarFileValue := range filesLocalVarFile {
fbs, _ := io.ReadAll(filesLocalVarFileValue)
filesLocalVarFileBytes = fbs
filesLocalVarFileName = filesLocalVarFileValue.Name()
filesLocalVarFileValue.Close()
formFiles = append(formFiles, formFile{fileBytes: filesLocalVarFileBytes, fileName: filesLocalVarFileName, formFileName: filesLocalVarFormFileName})
}
}
parameterAddToHeaderOrQuery(localVarFormParams, "request", r.request, "", "")
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
File diff suppressed because it is too large Load Diff
-850
View File
@@ -1,850 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
"reflect"
)
// MentalModelsAPIService MentalModelsAPI service
type MentalModelsAPIService service
type ApiCreateMentalModelRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
createMentalModelRequest *CreateMentalModelRequest
authorization *string
}
func (r ApiCreateMentalModelRequest) CreateMentalModelRequest(createMentalModelRequest CreateMentalModelRequest) ApiCreateMentalModelRequest {
r.createMentalModelRequest = &createMentalModelRequest
return r
}
func (r ApiCreateMentalModelRequest) Authorization(authorization string) ApiCreateMentalModelRequest {
r.authorization = &authorization
return r
}
func (r ApiCreateMentalModelRequest) Execute() (*CreateMentalModelResponse, *http.Response, error) {
return r.ApiService.CreateMentalModelExecute(r)
}
/*
CreateMentalModel Create mental model
Create a mental model by running reflect with the source query in the background. Returns an operation ID to track progress. The content is auto-generated by the reflect endpoint. Use the operations endpoint to check completion status.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiCreateMentalModelRequest
*/
func (a *MentalModelsAPIService) CreateMentalModel(ctx context.Context, bankId string) ApiCreateMentalModelRequest {
return ApiCreateMentalModelRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return CreateMentalModelResponse
func (a *MentalModelsAPIService) CreateMentalModelExecute(r ApiCreateMentalModelRequest) (*CreateMentalModelResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *CreateMentalModelResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.CreateMentalModel")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.createMentalModelRequest == nil {
return localVarReturnValue, nil, reportError("createMentalModelRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
// body params
localVarPostBody = r.createMentalModelRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiDeleteMentalModelRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
mentalModelId string
authorization *string
}
func (r ApiDeleteMentalModelRequest) Authorization(authorization string) ApiDeleteMentalModelRequest {
r.authorization = &authorization
return r
}
func (r ApiDeleteMentalModelRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.DeleteMentalModelExecute(r)
}
/*
DeleteMentalModel Delete mental model
Delete a mental model.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param mentalModelId
@return ApiDeleteMentalModelRequest
*/
func (a *MentalModelsAPIService) DeleteMentalModel(ctx context.Context, bankId string, mentalModelId string) ApiDeleteMentalModelRequest {
return ApiDeleteMentalModelRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
mentalModelId: mentalModelId,
}
}
// Execute executes the request
// @return interface{}
func (a *MentalModelsAPIService) DeleteMentalModelExecute(r ApiDeleteMentalModelRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.DeleteMentalModel")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models/{mental_model_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"mental_model_id"+"}", url.PathEscape(parameterValueToString(r.mentalModelId, "mentalModelId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetMentalModelRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
mentalModelId string
authorization *string
}
func (r ApiGetMentalModelRequest) Authorization(authorization string) ApiGetMentalModelRequest {
r.authorization = &authorization
return r
}
func (r ApiGetMentalModelRequest) Execute() (*MentalModelResponse, *http.Response, error) {
return r.ApiService.GetMentalModelExecute(r)
}
/*
GetMentalModel Get mental model
Get a specific mental model by ID.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param mentalModelId
@return ApiGetMentalModelRequest
*/
func (a *MentalModelsAPIService) GetMentalModel(ctx context.Context, bankId string, mentalModelId string) ApiGetMentalModelRequest {
return ApiGetMentalModelRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
mentalModelId: mentalModelId,
}
}
// Execute executes the request
// @return MentalModelResponse
func (a *MentalModelsAPIService) GetMentalModelExecute(r ApiGetMentalModelRequest) (*MentalModelResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MentalModelResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.GetMentalModel")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models/{mental_model_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"mental_model_id"+"}", url.PathEscape(parameterValueToString(r.mentalModelId, "mentalModelId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListMentalModelsRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
tags *[]string
tagsMatch *string
limit *int32
offset *int32
authorization *string
}
// Filter by tags
func (r ApiListMentalModelsRequest) Tags(tags []string) ApiListMentalModelsRequest {
r.tags = &tags
return r
}
// How to match tags
func (r ApiListMentalModelsRequest) TagsMatch(tagsMatch string) ApiListMentalModelsRequest {
r.tagsMatch = &tagsMatch
return r
}
func (r ApiListMentalModelsRequest) Limit(limit int32) ApiListMentalModelsRequest {
r.limit = &limit
return r
}
func (r ApiListMentalModelsRequest) Offset(offset int32) ApiListMentalModelsRequest {
r.offset = &offset
return r
}
func (r ApiListMentalModelsRequest) Authorization(authorization string) ApiListMentalModelsRequest {
r.authorization = &authorization
return r
}
func (r ApiListMentalModelsRequest) Execute() (*MentalModelListResponse, *http.Response, error) {
return r.ApiService.ListMentalModelsExecute(r)
}
/*
ListMentalModels List mental models
List user-curated living documents that stay current.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiListMentalModelsRequest
*/
func (a *MentalModelsAPIService) ListMentalModels(ctx context.Context, bankId string) ApiListMentalModelsRequest {
return ApiListMentalModelsRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return MentalModelListResponse
func (a *MentalModelsAPIService) ListMentalModelsExecute(r ApiListMentalModelsRequest) (*MentalModelListResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MentalModelListResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.ListMentalModels")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.tags != nil {
t := *r.tags
if reflect.TypeOf(t).Kind() == reflect.Slice {
s := reflect.ValueOf(t)
for i := 0; i < s.Len(); i++ {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags", s.Index(i).Interface(), "form", "multi")
}
} else {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags", t, "form", "multi")
}
}
if r.tagsMatch != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "tags_match", r.tagsMatch, "form", "")
} else {
var defaultValue string = "any"
r.tagsMatch = &defaultValue
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
} else {
var defaultValue int32 = 100
r.limit = &defaultValue
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
} else {
var defaultValue int32 = 0
r.offset = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiRefreshMentalModelRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
mentalModelId string
authorization *string
}
func (r ApiRefreshMentalModelRequest) Authorization(authorization string) ApiRefreshMentalModelRequest {
r.authorization = &authorization
return r
}
func (r ApiRefreshMentalModelRequest) Execute() (*AsyncOperationSubmitResponse, *http.Response, error) {
return r.ApiService.RefreshMentalModelExecute(r)
}
/*
RefreshMentalModel Refresh mental model
Submit an async task to re-run the source query through reflect and update the content.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param mentalModelId
@return ApiRefreshMentalModelRequest
*/
func (a *MentalModelsAPIService) RefreshMentalModel(ctx context.Context, bankId string, mentalModelId string) ApiRefreshMentalModelRequest {
return ApiRefreshMentalModelRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
mentalModelId: mentalModelId,
}
}
// Execute executes the request
// @return AsyncOperationSubmitResponse
func (a *MentalModelsAPIService) RefreshMentalModelExecute(r ApiRefreshMentalModelRequest) (*AsyncOperationSubmitResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *AsyncOperationSubmitResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.RefreshMentalModel")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models/{mental_model_id}/refresh"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"mental_model_id"+"}", url.PathEscape(parameterValueToString(r.mentalModelId, "mentalModelId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiUpdateMentalModelRequest struct {
ctx context.Context
ApiService *MentalModelsAPIService
bankId string
mentalModelId string
updateMentalModelRequest *UpdateMentalModelRequest
authorization *string
}
func (r ApiUpdateMentalModelRequest) UpdateMentalModelRequest(updateMentalModelRequest UpdateMentalModelRequest) ApiUpdateMentalModelRequest {
r.updateMentalModelRequest = &updateMentalModelRequest
return r
}
func (r ApiUpdateMentalModelRequest) Authorization(authorization string) ApiUpdateMentalModelRequest {
r.authorization = &authorization
return r
}
func (r ApiUpdateMentalModelRequest) Execute() (*MentalModelResponse, *http.Response, error) {
return r.ApiService.UpdateMentalModelExecute(r)
}
/*
UpdateMentalModel Update mental model
Update a mental model's name and/or source query.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param mentalModelId
@return ApiUpdateMentalModelRequest
*/
func (a *MentalModelsAPIService) UpdateMentalModel(ctx context.Context, bankId string, mentalModelId string) ApiUpdateMentalModelRequest {
return ApiUpdateMentalModelRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
mentalModelId: mentalModelId,
}
}
// Execute executes the request
// @return MentalModelResponse
func (a *MentalModelsAPIService) UpdateMentalModelExecute(r ApiUpdateMentalModelRequest) (*MentalModelResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *MentalModelResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MentalModelsAPIService.UpdateMentalModel")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/mental-models/{mental_model_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"mental_model_id"+"}", url.PathEscape(parameterValueToString(r.mentalModelId, "mentalModelId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.updateMentalModelRequest == nil {
return localVarReturnValue, nil, reportError("updateMentalModelRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
// body params
localVarPostBody = r.updateMentalModelRequest
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-320
View File
@@ -1,320 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
)
// MonitoringAPIService MonitoringAPI service
type MonitoringAPIService service
type ApiGetVersionRequest struct {
ctx context.Context
ApiService *MonitoringAPIService
}
func (r ApiGetVersionRequest) Execute() (*VersionResponse, *http.Response, error) {
return r.ApiService.GetVersionExecute(r)
}
/*
GetVersion Get API version and feature flags
Returns API version information and enabled feature flags. Use this to check which capabilities are available in this deployment.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiGetVersionRequest
*/
func (a *MonitoringAPIService) GetVersion(ctx context.Context) ApiGetVersionRequest {
return ApiGetVersionRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return VersionResponse
func (a *MonitoringAPIService) GetVersionExecute(r ApiGetVersionRequest) (*VersionResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *VersionResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MonitoringAPIService.GetVersion")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/version"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiHealthEndpointHealthGetRequest struct {
ctx context.Context
ApiService *MonitoringAPIService
}
func (r ApiHealthEndpointHealthGetRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.HealthEndpointHealthGetExecute(r)
}
/*
HealthEndpointHealthGet Health check endpoint
Checks the health of the API and database connection
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiHealthEndpointHealthGetRequest
*/
func (a *MonitoringAPIService) HealthEndpointHealthGet(ctx context.Context) ApiHealthEndpointHealthGetRequest {
return ApiHealthEndpointHealthGetRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return interface{}
func (a *MonitoringAPIService) HealthEndpointHealthGetExecute(r ApiHealthEndpointHealthGetRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MonitoringAPIService.HealthEndpointHealthGet")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/health"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiMetricsEndpointMetricsGetRequest struct {
ctx context.Context
ApiService *MonitoringAPIService
}
func (r ApiMetricsEndpointMetricsGetRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.MetricsEndpointMetricsGetExecute(r)
}
/*
MetricsEndpointMetricsGet Prometheus metrics endpoint
Exports metrics in Prometheus format for scraping
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiMetricsEndpointMetricsGetRequest
*/
func (a *MonitoringAPIService) MetricsEndpointMetricsGet(ctx context.Context) ApiMetricsEndpointMetricsGetRequest {
return ApiMetricsEndpointMetricsGetRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return interface{}
func (a *MonitoringAPIService) MetricsEndpointMetricsGetExecute(r ApiMetricsEndpointMetricsGetRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MonitoringAPIService.MetricsEndpointMetricsGet")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/metrics"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-434
View File
@@ -1,434 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// OperationsAPIService OperationsAPI service
type OperationsAPIService service
type ApiCancelOperationRequest struct {
ctx context.Context
ApiService *OperationsAPIService
bankId string
operationId string
authorization *string
}
func (r ApiCancelOperationRequest) Authorization(authorization string) ApiCancelOperationRequest {
r.authorization = &authorization
return r
}
func (r ApiCancelOperationRequest) Execute() (*CancelOperationResponse, *http.Response, error) {
return r.ApiService.CancelOperationExecute(r)
}
/*
CancelOperation Cancel a pending async operation
Cancel a pending async operation by removing it from the queue
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param operationId
@return ApiCancelOperationRequest
*/
func (a *OperationsAPIService) CancelOperation(ctx context.Context, bankId string, operationId string) ApiCancelOperationRequest {
return ApiCancelOperationRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
operationId: operationId,
}
}
// Execute executes the request
// @return CancelOperationResponse
func (a *OperationsAPIService) CancelOperationExecute(r ApiCancelOperationRequest) (*CancelOperationResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *CancelOperationResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OperationsAPIService.CancelOperation")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/operations/{operation_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"operation_id"+"}", url.PathEscape(parameterValueToString(r.operationId, "operationId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiGetOperationStatusRequest struct {
ctx context.Context
ApiService *OperationsAPIService
bankId string
operationId string
authorization *string
}
func (r ApiGetOperationStatusRequest) Authorization(authorization string) ApiGetOperationStatusRequest {
r.authorization = &authorization
return r
}
func (r ApiGetOperationStatusRequest) Execute() (*OperationStatusResponse, *http.Response, error) {
return r.ApiService.GetOperationStatusExecute(r)
}
/*
GetOperationStatus Get operation status
Get the status of a specific async operation. Returns 'pending', 'completed', or 'failed'. Completed operations are removed from storage, so 'completed' means the operation finished successfully.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@param operationId
@return ApiGetOperationStatusRequest
*/
func (a *OperationsAPIService) GetOperationStatus(ctx context.Context, bankId string, operationId string) ApiGetOperationStatusRequest {
return ApiGetOperationStatusRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
operationId: operationId,
}
}
// Execute executes the request
// @return OperationStatusResponse
func (a *OperationsAPIService) GetOperationStatusExecute(r ApiGetOperationStatusRequest) (*OperationStatusResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *OperationStatusResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OperationsAPIService.GetOperationStatus")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/operations/{operation_id}"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"operation_id"+"}", url.PathEscape(parameterValueToString(r.operationId, "operationId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiListOperationsRequest struct {
ctx context.Context
ApiService *OperationsAPIService
bankId string
status *string
limit *int32
offset *int32
authorization *string
}
// Filter by status: pending, completed, or failed
func (r ApiListOperationsRequest) Status(status string) ApiListOperationsRequest {
r.status = &status
return r
}
// Maximum number of operations to return
func (r ApiListOperationsRequest) Limit(limit int32) ApiListOperationsRequest {
r.limit = &limit
return r
}
// Number of operations to skip
func (r ApiListOperationsRequest) Offset(offset int32) ApiListOperationsRequest {
r.offset = &offset
return r
}
func (r ApiListOperationsRequest) Authorization(authorization string) ApiListOperationsRequest {
r.authorization = &authorization
return r
}
func (r ApiListOperationsRequest) Execute() (*OperationsListResponse, *http.Response, error) {
return r.ApiService.ListOperationsExecute(r)
}
/*
ListOperations List async operations
Get a list of async operations for a specific agent, with optional filtering by status. Results are sorted by most recent first.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bankId
@return ApiListOperationsRequest
*/
func (a *OperationsAPIService) ListOperations(ctx context.Context, bankId string) ApiListOperationsRequest {
return ApiListOperationsRequest{
ApiService: a,
ctx: ctx,
bankId: bankId,
}
}
// Execute executes the request
// @return OperationsListResponse
func (a *OperationsAPIService) ListOperationsExecute(r ApiListOperationsRequest) (*OperationsListResponse, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *OperationsListResponse
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "OperationsAPIService.ListOperations")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/default/banks/{bank_id}/operations"
localVarPath = strings.Replace(localVarPath, "{"+"bank_id"+"}", url.PathEscape(parameterValueToString(r.bankId, "bankId")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.status != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
} else {
var defaultValue int32 = 20
r.limit = &defaultValue
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
} else {
var defaultValue int32 = 0
r.offset = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.authorization != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "authorization", r.authorization, "simple", "")
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 422 {
var v HTTPValidationError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
-676
View File
@@ -1,676 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"bytes"
"context"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"net/http/httputil"
"net/url"
"os"
"path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
)
var (
JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" )
)
// APIClient manages communication with the Hindsight HTTP API API v0.4.11
// In most cases there should be only one, shared, APIClient.
type APIClient struct {
cfg *Configuration
common service // Reuse a single struct instead of allocating one for each service on the heap.
// API Services
BanksAPI *BanksAPIService
DirectivesAPI *DirectivesAPIService
DocumentsAPI *DocumentsAPIService
EntitiesAPI *EntitiesAPIService
FilesAPI *FilesAPIService
MemoryAPI *MemoryAPIService
MentalModelsAPI *MentalModelsAPIService
MonitoringAPI *MonitoringAPIService
OperationsAPI *OperationsAPIService
}
type service struct {
client *APIClient
}
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
// optionally a custom http.Client to allow for advanced features such as caching.
func NewAPIClient(cfg *Configuration) *APIClient {
if cfg.HTTPClient == nil {
cfg.HTTPClient = http.DefaultClient
}
c := &APIClient{}
c.cfg = cfg
c.common.client = c
// API Services
c.BanksAPI = (*BanksAPIService)(&c.common)
c.DirectivesAPI = (*DirectivesAPIService)(&c.common)
c.DocumentsAPI = (*DocumentsAPIService)(&c.common)
c.EntitiesAPI = (*EntitiesAPIService)(&c.common)
c.FilesAPI = (*FilesAPIService)(&c.common)
c.MemoryAPI = (*MemoryAPIService)(&c.common)
c.MentalModelsAPI = (*MentalModelsAPIService)(&c.common)
c.MonitoringAPI = (*MonitoringAPIService)(&c.common)
c.OperationsAPI = (*OperationsAPIService)(&c.common)
return c
}
func atoi(in string) (int, error) {
return strconv.Atoi(in)
}
// selectHeaderContentType select a content type from the available list.
func selectHeaderContentType(contentTypes []string) string {
if len(contentTypes) == 0 {
return ""
}
if contains(contentTypes, "application/json") {
return "application/json"
}
return contentTypes[0] // use the first content type specified in 'consumes'
}
// selectHeaderAccept join all accept types and return
func selectHeaderAccept(accepts []string) string {
if len(accepts) == 0 {
return ""
}
if contains(accepts, "application/json") {
return "application/json"
}
return strings.Join(accepts, ",")
}
// contains is a case insensitive match, finding needle in a haystack
func contains(haystack []string, needle string) bool {
for _, a := range haystack {
if strings.EqualFold(a, needle) {
return true
}
}
return false
}
// Verify optional parameters are of the correct type.
func typeCheckParameter(obj interface{}, expected string, name string) error {
// Make sure there is an object.
if obj == nil {
return nil
}
// Check the type is as expected.
if reflect.TypeOf(obj).String() != expected {
return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String())
}
return nil
}
func parameterValueToString( obj interface{}, key string ) string {
if reflect.TypeOf(obj).Kind() != reflect.Ptr {
return fmt.Sprintf("%v", obj)
}
var param,ok = obj.(MappedNullable)
if !ok {
return ""
}
dataMap,err := param.ToMap()
if err != nil {
return ""
}
return fmt.Sprintf("%v", dataMap[key])
}
// parameterAddToHeaderOrQuery adds the provided object to the request header or url query
// supporting deep object syntax
func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) {
var v = reflect.ValueOf(obj)
var value = ""
if v == reflect.ValueOf(nil) {
value = "null"
} else {
switch v.Kind() {
case reflect.Invalid:
value = "invalid"
case reflect.Struct:
if t,ok := obj.(MappedNullable); ok {
dataMap,err := t.ToMap()
if err != nil {
return
}
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType)
return
}
if t, ok := obj.(time.Time); ok {
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType)
return
}
value = v.Type().String() + " value"
case reflect.Slice:
var indValue = reflect.ValueOf(obj)
if indValue == reflect.ValueOf(nil) {
return
}
var lenIndValue = indValue.Len()
for i:=0;i<lenIndValue;i++ {
var arrayValue = indValue.Index(i)
var keyPrefixForCollectionType = keyPrefix
if style == "deepObject" {
keyPrefixForCollectionType = keyPrefix + "[" + strconv.Itoa(i) + "]"
}
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefixForCollectionType, arrayValue.Interface(), style, collectionType)
}
return
case reflect.Map:
var indValue = reflect.ValueOf(obj)
if indValue == reflect.ValueOf(nil) {
return
}
iter := indValue.MapRange()
for iter.Next() {
k,v := iter.Key(), iter.Value()
parameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, k.String()), v.Interface(), style, collectionType)
}
return
case reflect.Interface:
fallthrough
case reflect.Ptr:
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, v.Elem().Interface(), style, collectionType)
return
case reflect.Int, reflect.Int8, reflect.Int16,
reflect.Int32, reflect.Int64:
value = strconv.FormatInt(v.Int(), 10)
case reflect.Uint, reflect.Uint8, reflect.Uint16,
reflect.Uint32, reflect.Uint64, reflect.Uintptr:
value = strconv.FormatUint(v.Uint(), 10)
case reflect.Float32, reflect.Float64:
value = strconv.FormatFloat(v.Float(), 'g', -1, 32)
case reflect.Bool:
value = strconv.FormatBool(v.Bool())
case reflect.String:
value = v.String()
default:
value = v.Type().String() + " value"
}
}
switch valuesMap := headerOrQueryParams.(type) {
case url.Values:
if collectionType == "csv" && valuesMap.Get(keyPrefix) != "" {
valuesMap.Set(keyPrefix, valuesMap.Get(keyPrefix) + "," + value)
} else {
valuesMap.Add(keyPrefix, value)
}
break
case map[string]string:
valuesMap[keyPrefix] = value
break
}
}
// helper for converting interface{} parameters to json strings
func parameterToJson(obj interface{}) (string, error) {
jsonBuf, err := json.Marshal(obj)
if err != nil {
return "", err
}
return string(jsonBuf), err
}
// callAPI do the request.
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
if c.cfg.Debug {
dump, err := httputil.DumpRequestOut(request, true)
if err != nil {
return nil, err
}
log.Printf("\n%s\n", string(dump))
}
resp, err := c.cfg.HTTPClient.Do(request)
if err != nil {
return resp, err
}
if c.cfg.Debug {
dump, err := httputil.DumpResponse(resp, true)
if err != nil {
return resp, err
}
log.Printf("\n%s\n", string(dump))
}
return resp, err
}
// Allow modification of underlying config for alternate implementations and testing
// Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
func (c *APIClient) GetConfig() *Configuration {
return c.cfg
}
type formFile struct {
fileBytes []byte
fileName string
formFileName string
}
// prepareRequest build the request
func (c *APIClient) prepareRequest(
ctx context.Context,
path string, method string,
postBody interface{},
headerParams map[string]string,
queryParams url.Values,
formParams url.Values,
formFiles []formFile) (localVarRequest *http.Request, err error) {
var body *bytes.Buffer
// Detect postBody type and post.
if postBody != nil {
contentType := headerParams["Content-Type"]
if contentType == "" {
contentType = detectContentType(postBody)
headerParams["Content-Type"] = contentType
}
body, err = setBody(postBody, contentType)
if err != nil {
return nil, err
}
}
// add form parameters and file if available.
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(formFiles) > 0) {
if body != nil {
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
}
body = &bytes.Buffer{}
w := multipart.NewWriter(body)
for k, v := range formParams {
for _, iv := range v {
if strings.HasPrefix(k, "@") { // file
err = addFile(w, k[1:], iv)
if err != nil {
return nil, err
}
} else { // form value
w.WriteField(k, iv)
}
}
}
for _, formFile := range formFiles {
if len(formFile.fileBytes) > 0 && formFile.fileName != "" {
w.Boundary()
part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName))
if err != nil {
return nil, err
}
_, err = part.Write(formFile.fileBytes)
if err != nil {
return nil, err
}
}
}
// Set the Boundary in the Content-Type
headerParams["Content-Type"] = w.FormDataContentType()
// Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
w.Close()
}
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
if body != nil {
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
}
body = &bytes.Buffer{}
body.WriteString(formParams.Encode())
// Set Content-Length
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
}
// Setup path and query parameters
url, err := url.Parse(path)
if err != nil {
return nil, err
}
// Override request host, if applicable
if c.cfg.Host != "" {
url.Host = c.cfg.Host
}
// Override request scheme, if applicable
if c.cfg.Scheme != "" {
url.Scheme = c.cfg.Scheme
}
// Adding Query Param
query := url.Query()
for k, v := range queryParams {
for _, iv := range v {
query.Add(k, iv)
}
}
// Encode the parameters.
url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string {
pieces := strings.Split(s, "=")
pieces[0] = queryDescape.Replace(pieces[0])
return strings.Join(pieces, "=")
})
// Generate a new request
if body != nil {
localVarRequest, err = http.NewRequest(method, url.String(), body)
} else {
localVarRequest, err = http.NewRequest(method, url.String(), nil)
}
if err != nil {
return nil, err
}
// add header parameters, if any
if len(headerParams) > 0 {
headers := http.Header{}
for h, v := range headerParams {
headers[h] = []string{v}
}
localVarRequest.Header = headers
}
// Add the user agent to the request.
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
if ctx != nil {
// add context to the request
localVarRequest = localVarRequest.WithContext(ctx)
// Walk through any authentication.
}
for header, value := range c.cfg.DefaultHeader {
localVarRequest.Header.Add(header, value)
}
return localVarRequest, nil
}
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
if len(b) == 0 {
return nil
}
if s, ok := v.(*string); ok {
*s = string(b)
return nil
}
if f, ok := v.(*os.File); ok {
f, err = os.CreateTemp("", "HttpClientFile")
if err != nil {
return
}
_, err = f.Write(b)
if err != nil {
return
}
_, err = f.Seek(0, io.SeekStart)
return
}
if f, ok := v.(**os.File); ok {
*f, err = os.CreateTemp("", "HttpClientFile")
if err != nil {
return
}
_, err = (*f).Write(b)
if err != nil {
return
}
_, err = (*f).Seek(0, io.SeekStart)
return
}
if XmlCheck.MatchString(contentType) {
if err = xml.Unmarshal(b, v); err != nil {
return err
}
return nil
}
if JsonCheck.MatchString(contentType) {
if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined
if err = unmarshalObj.UnmarshalJSON(b); err != nil {
return err
}
} else {
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
}
} else if err = json.Unmarshal(b, v); err != nil { // simple model
return err
}
return nil
}
return errors.New("undefined response type")
}
// Add a file to the multipart request
func addFile(w *multipart.Writer, fieldName, path string) error {
file, err := os.Open(filepath.Clean(path))
if err != nil {
return err
}
err = file.Close()
if err != nil {
return err
}
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
if err != nil {
return err
}
_, err = io.Copy(part, file)
return err
}
// Set request body from an interface{}
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
if bodyBuf == nil {
bodyBuf = &bytes.Buffer{}
}
if reader, ok := body.(io.Reader); ok {
_, err = bodyBuf.ReadFrom(reader)
} else if fp, ok := body.(*os.File); ok {
_, err = bodyBuf.ReadFrom(fp)
} else if b, ok := body.([]byte); ok {
_, err = bodyBuf.Write(b)
} else if s, ok := body.(string); ok {
_, err = bodyBuf.WriteString(s)
} else if s, ok := body.(*string); ok {
_, err = bodyBuf.WriteString(*s)
} else if JsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body)
} else if XmlCheck.MatchString(contentType) {
var bs []byte
bs, err = xml.Marshal(body)
if err == nil {
bodyBuf.Write(bs)
}
}
if err != nil {
return nil, err
}
if bodyBuf.Len() == 0 {
err = fmt.Errorf("invalid body type %s\n", contentType)
return nil, err
}
return bodyBuf, nil
}
// detectContentType method is used to figure out `Request.Body` content type for request header
func detectContentType(body interface{}) string {
contentType := "text/plain; charset=utf-8"
kind := reflect.TypeOf(body).Kind()
switch kind {
case reflect.Struct, reflect.Map, reflect.Ptr:
contentType = "application/json; charset=utf-8"
case reflect.String:
contentType = "text/plain; charset=utf-8"
default:
if b, ok := body.([]byte); ok {
contentType = http.DetectContentType(b)
} else if kind == reflect.Slice {
contentType = "application/json; charset=utf-8"
}
}
return contentType
}
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
type cacheControl map[string]string
func parseCacheControl(headers http.Header) cacheControl {
cc := cacheControl{}
ccHeader := headers.Get("Cache-Control")
for _, part := range strings.Split(ccHeader, ",") {
part = strings.Trim(part, " ")
if part == "" {
continue
}
if strings.ContainsRune(part, '=') {
keyval := strings.Split(part, "=")
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
} else {
cc[part] = ""
}
}
return cc
}
// CacheExpires helper function to determine remaining time before repeating a request.
func CacheExpires(r *http.Response) time.Time {
// Figure out when the cache expires.
var expires time.Time
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
if err != nil {
return time.Now()
}
respCacheControl := parseCacheControl(r.Header)
if maxAge, ok := respCacheControl["max-age"]; ok {
lifetime, err := time.ParseDuration(maxAge + "s")
if err != nil {
expires = now
} else {
expires = now.Add(lifetime)
}
} else {
expiresHeader := r.Header.Get("Expires")
if expiresHeader != "" {
expires, err = time.Parse(time.RFC1123, expiresHeader)
if err != nil {
expires = now
}
}
}
return expires
}
func strlen(s string) int {
return utf8.RuneCountInString(s)
}
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
type GenericOpenAPIError struct {
body []byte
error string
model interface{}
}
// Error returns non-empty string if there was an error.
func (e GenericOpenAPIError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e GenericOpenAPIError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e GenericOpenAPIError) Model() interface{} {
return e.model
}
// format error message using title and detail when model implements rfc7807
func formatErrorMessage(status string, v interface{}) string {
str := ""
metaValue := reflect.ValueOf(v).Elem()
if metaValue.Kind() == reflect.Struct {
field := metaValue.FieldByName("Title")
if field != (reflect.Value{}) {
str = fmt.Sprintf("%s", field.Interface())
}
field = metaValue.FieldByName("Detail")
if field != (reflect.Value{}) {
str = fmt.Sprintf("%s (%s)", str, field.Interface())
}
}
return strings.TrimSpace(fmt.Sprintf("%s %s", status, str))
}
-215
View File
@@ -1,215 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"context"
"fmt"
"net/http"
"strings"
)
// contextKeys are used to identify the type of value in the context.
// Since these are string, it is possible to get a short description of the
// context key for logging and debugging using key.String().
type contextKey string
func (c contextKey) String() string {
return "auth " + string(c)
}
var (
// ContextServerIndex uses a server configuration from the index.
ContextServerIndex = contextKey("serverIndex")
// ContextOperationServerIndices uses a server configuration from the index mapping.
ContextOperationServerIndices = contextKey("serverOperationIndices")
// ContextServerVariables overrides a server configuration variables.
ContextServerVariables = contextKey("serverVariables")
// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
ContextOperationServerVariables = contextKey("serverOperationVariables")
)
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type BasicAuth struct {
UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"`
}
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIKey struct {
Key string
Prefix string
}
// ServerVariable stores the information about a server variable
type ServerVariable struct {
Description string
DefaultValue string
EnumValues []string
}
// ServerConfiguration stores the information about a server
type ServerConfiguration struct {
URL string
Description string
Variables map[string]ServerVariable
}
// ServerConfigurations stores multiple ServerConfiguration items
type ServerConfigurations []ServerConfiguration
// Configuration stores the configuration of the API client
type Configuration struct {
Host string `json:"host,omitempty"`
Scheme string `json:"scheme,omitempty"`
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Debug bool `json:"debug,omitempty"`
Servers ServerConfigurations
OperationServers map[string]ServerConfigurations
HTTPClient *http.Client
}
// NewConfiguration returns a new Configuration object
func NewConfiguration() *Configuration {
cfg := &Configuration{
DefaultHeader: make(map[string]string),
UserAgent: "OpenAPI-Generator/1.0.0/go",
Debug: false,
Servers: ServerConfigurations{
{
URL: "",
Description: "No description provided",
},
},
OperationServers: map[string]ServerConfigurations{
},
}
return cfg
}
// AddDefaultHeader adds a new HTTP header to the default header in the request
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}
// URL formats template on a index using given variables
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
if index < 0 || len(sc) <= index {
return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
}
server := sc[index]
url := server.URL
// go through variables and replace placeholders
for name, variable := range server.Variables {
if value, ok := variables[name]; ok {
found := bool(len(variable.EnumValues) == 0)
for _, enumValue := range variable.EnumValues {
if value == enumValue {
found = true
}
}
if !found {
return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
}
url = strings.Replace(url, "{"+name+"}", value, -1)
} else {
url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
}
}
return url, nil
}
// ServerURL returns URL based on server settings
func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
return c.Servers.URL(index, variables)
}
func getServerIndex(ctx context.Context) (int, error) {
si := ctx.Value(ContextServerIndex)
if si != nil {
if index, ok := si.(int); ok {
return index, nil
}
return 0, reportError("Invalid type %T should be int", si)
}
return 0, nil
}
func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) {
osi := ctx.Value(ContextOperationServerIndices)
if osi != nil {
if operationIndices, ok := osi.(map[string]int); !ok {
return 0, reportError("Invalid type %T should be map[string]int", osi)
} else {
index, ok := operationIndices[endpoint]
if ok {
return index, nil
}
}
}
return getServerIndex(ctx)
}
func getServerVariables(ctx context.Context) (map[string]string, error) {
sv := ctx.Value(ContextServerVariables)
if sv != nil {
if variables, ok := sv.(map[string]string); ok {
return variables, nil
}
return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv)
}
return nil, nil
}
func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) {
osv := ctx.Value(ContextOperationServerVariables)
if osv != nil {
if operationVariables, ok := osv.(map[string]map[string]string); !ok {
return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv)
} else {
variables, ok := operationVariables[endpoint]
if ok {
return variables, nil
}
}
}
return getServerVariables(ctx)
}
// ServerURLWithContext returns a new server URL given an endpoint
func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) {
sc, ok := c.OperationServers[endpoint]
if !ok {
sc = c.Servers
}
if ctx == nil {
return sc.URL(0, nil)
}
index, err := getServerOperationIndex(ctx, endpoint)
if err != nil {
return "", err
}
variables, err := getServerOperationVariables(ctx, endpoint)
if err != nil {
return "", err
}
return sc.URL(index, variables)
}
-11
View File
@@ -1,11 +0,0 @@
module github.com/vectorize-io/hindsight-client-go
go 1.18
require github.com/stretchr/testify v1.11.1
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
-10
View File
@@ -1,10 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-479
View File
@@ -1,479 +0,0 @@
//go:build integration
package hindsight
import (
"context"
"fmt"
"os"
"testing"
"time"
)
func apiURL(t *testing.T) string {
t.Helper()
u := os.Getenv("HINDSIGHT_API_URL")
if u == "" {
u = "http://localhost:8888"
}
return u
}
func newClient(t *testing.T) *APIClient {
t.Helper()
cfg := NewConfiguration()
cfg.Servers = ServerConfigurations{
{URL: apiURL(t)},
}
return NewAPIClient(cfg)
}
func uniqueBank(t *testing.T) string {
t.Helper()
return fmt.Sprintf("go_test_%d", time.Now().UnixNano())
}
// --- Retain tests ---
func TestRetainSingle(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
req := RetainRequest{
Items: []MemoryItem{
{Content: "Alice loves artificial intelligence and machine learning"},
},
}
resp, httpResp, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
}
func TestRetainWithContext(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
timestamp := time.Date(2024, 1, 15, 10, 30, 0, 0, time.UTC)
req := RetainRequest{
Items: []MemoryItem{
{
Content: "Bob went hiking in the mountains",
Timestamp: *NewNullableTime(PtrTime(timestamp)),
Context: *NewNullableString(PtrString("outdoor activities")),
},
},
}
resp, httpResp, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
}
func TestRetainBatch(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
req := RetainRequest{
Items: []MemoryItem{
{Content: "Charlie enjoys reading science fiction books"},
{Content: "Diana is learning to play the guitar"},
{Content: "Eve completed a marathon last month"},
},
}
resp, httpResp, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
if resp.GetItemsCount() != 3 {
t.Errorf("expected items_count=3, got %d", resp.GetItemsCount())
}
}
func TestRetainWithTags(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
req := RetainRequest{
Items: []MemoryItem{
{
Content: "New feature implementation for project Z",
Tags: []string{"project_z", "features"},
},
},
}
resp, httpResp, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
}
func TestRetainBatchWithDocumentTags(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
req := RetainRequest{
Items: []MemoryItem{
{Content: "Document with tags test 1"},
{Content: "Document with tags test 2"},
},
DocumentTags: []string{"test_doc", "batch"},
}
resp, httpResp, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
}
// --- Recall tests ---
func setupRecallBank(t *testing.T, client *APIClient, bankID string) {
t.Helper()
ctx := context.Background()
req := RetainRequest{
Items: []MemoryItem{
{Content: "Alice enjoys hiking in the mountains"},
{Content: "Bob loves to read science fiction novels"},
{Content: "Charlie is learning to play the piano"},
},
}
_, _, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
// Give the system time to process
time.Sleep(time.Second)
}
func TestRecallBasic(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
setupRecallBank(t, client, bankID)
req := RecallRequest{
Query: "outdoor activities",
}
resp, httpResp, err := client.MemoryAPI.RecallMemories(ctx, bankID).RecallRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.Results == nil {
t.Error("expected results, got nil")
}
}
func TestRecallWithMaxTokens(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
setupRecallBank(t, client, bankID)
req := RecallRequest{
Query: "outdoor activities",
MaxTokens: PtrInt32(1024),
}
resp, httpResp, err := client.MemoryAPI.RecallMemories(ctx, bankID).RecallRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.Results == nil {
t.Error("expected results, got nil")
}
}
func TestRecallFullFeatured(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
setupRecallBank(t, client, bankID)
req := RecallRequest{
Query: "What are people's hobbies?",
Types: []string{"world"},
MaxTokens: PtrInt32(2048),
Trace: PtrBool(true),
}
resp, httpResp, err := client.MemoryAPI.RecallMemories(ctx, bankID).RecallRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.Results == nil {
t.Error("expected results, got nil")
}
// Verify trace data is present
if resp.Trace != nil && len(resp.Trace) > 0 {
t.Logf("✓ Trace data received with %d keys", len(resp.Trace))
}
}
// --- Reflect tests ---
func setupReflectBank(t *testing.T, client *APIClient, bankID string) {
t.Helper()
ctx := context.Background()
// Create bank with mission
createReq := CreateBankRequest{
Mission: *NewNullableString(PtrString("I am a helpful AI assistant interested in technology and science.")),
}
_, _, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(createReq).Execute()
if err != nil {
t.Fatal(err)
}
// Add memories
retainReq := RetainRequest{
Items: []MemoryItem{
{Content: "Quantum computing uses quantum bits (qubits) for processing"},
{Content: "Neural networks are inspired by biological neurons"},
},
}
_, _, err = client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(retainReq).Execute()
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
}
func TestReflectBasic(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
setupReflectBank(t, client, bankID)
req := ReflectRequest{
Query: "What do you know about computing?",
}
resp, httpResp, err := client.MemoryAPI.Reflect(ctx, bankID).ReflectRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.GetText() == "" {
t.Error("expected non-empty answer")
}
}
func TestReflectWithMaxTokens(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
setupReflectBank(t, client, bankID)
req := ReflectRequest{
Query: "Tell me about neural networks",
MaxTokens: PtrInt32(500),
}
resp, httpResp, err := client.MemoryAPI.Reflect(ctx, bankID).ReflectRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.GetText() == "" {
t.Error("expected non-empty answer")
}
}
// --- Bank tests ---
func TestCreateBank(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
req := CreateBankRequest{
Mission: *NewNullableString(PtrString("Test mission")),
}
resp, httpResp, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(req).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.GetBankId() != bankID {
t.Errorf("expected bank_id=%s, got %s", bankID, resp.GetBankId())
}
}
func TestSetMission(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
// Create bank with initial mission
createReq := CreateBankRequest{
Mission: *NewNullableString(PtrString("Initial mission")),
}
_, _, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(createReq).Execute()
if err != nil {
t.Fatal(err)
}
// Update mission by creating/updating bank again
updateReq := CreateBankRequest{
Mission: *NewNullableString(PtrString("Updated mission")),
}
resp, httpResp, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(updateReq).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.GetMission() != "Updated mission" {
t.Errorf("expected mission='Updated mission', got %s", resp.GetMission())
}
}
func TestListBanks(t *testing.T) {
client := newClient(t)
ctx := context.Background()
resp, httpResp, err := client.BanksAPI.ListBanks(ctx).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if resp.Banks == nil {
t.Error("expected banks list, got nil")
}
}
func TestDeleteBank(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
// Create bank
createReq := CreateBankRequest{}
_, _, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(createReq).Execute()
if err != nil {
t.Fatal(err)
}
// Delete bank
resp, httpResp, err := client.BanksAPI.DeleteBank(ctx, bankID).Execute()
if err != nil {
t.Fatal(err)
}
defer httpResp.Body.Close()
if !resp.GetSuccess() {
t.Error("expected success=true")
}
}
// --- End-to-end workflow test ---
func TestCompleteWorkflow(t *testing.T) {
client := newClient(t)
ctx := context.Background()
bankID := uniqueBank(t)
// 1. Create bank
createReq := CreateBankRequest{
Mission: *NewNullableString(PtrString("I am a helpful assistant")),
}
_, _, err := client.BanksAPI.CreateOrUpdateBank(ctx, bankID).CreateBankRequest(createReq).Execute()
if err != nil {
t.Fatal(err)
}
// 2. Retain memories
retainReq := RetainRequest{
Items: []MemoryItem{
{Content: "Paris is the capital of France"},
{Content: "The Eiffel Tower is in Paris"},
},
}
retainResp, _, err := client.MemoryAPI.RetainMemories(ctx, bankID).RetainRequest(retainReq).Execute()
if err != nil {
t.Fatal(err)
}
if !retainResp.GetSuccess() {
t.Error("retain failed")
}
time.Sleep(time.Second)
// 3. Recall
recallReq := RecallRequest{
Query: "What is in Paris?",
}
recallResp, _, err := client.MemoryAPI.RecallMemories(ctx, bankID).RecallRequest(recallReq).Execute()
if err != nil {
t.Fatal(err)
}
if len(recallResp.Results) == 0 {
t.Error("expected recall results")
}
// 4. Reflect
reflectReq := ReflectRequest{
Query: "Tell me about Paris",
}
reflectResp, _, err := client.MemoryAPI.Reflect(ctx, bankID).ReflectRequest(reflectReq).Execute()
if err != nil {
t.Fatal(err)
}
if reflectResp.GetText() == "" {
t.Error("expected reflect answer")
}
t.Log("✓ Complete workflow passed")
}
@@ -1,200 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the AddBackgroundRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &AddBackgroundRequest{}
// AddBackgroundRequest Request model for adding/merging background information. Deprecated: use SetMissionRequest instead.
type AddBackgroundRequest struct {
// New background information to add or merge
Content string `json:"content"`
// Deprecated - disposition is no longer auto-inferred from mission
UpdateDisposition *bool `json:"update_disposition,omitempty"`
}
type _AddBackgroundRequest AddBackgroundRequest
// NewAddBackgroundRequest instantiates a new AddBackgroundRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewAddBackgroundRequest(content string) *AddBackgroundRequest {
this := AddBackgroundRequest{}
this.Content = content
var updateDisposition bool = true
this.UpdateDisposition = &updateDisposition
return &this
}
// NewAddBackgroundRequestWithDefaults instantiates a new AddBackgroundRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewAddBackgroundRequestWithDefaults() *AddBackgroundRequest {
this := AddBackgroundRequest{}
var updateDisposition bool = true
this.UpdateDisposition = &updateDisposition
return &this
}
// GetContent returns the Content field value
func (o *AddBackgroundRequest) GetContent() string {
if o == nil {
var ret string
return ret
}
return o.Content
}
// GetContentOk returns a tuple with the Content field value
// and a boolean to check if the value has been set.
func (o *AddBackgroundRequest) GetContentOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Content, true
}
// SetContent sets field value
func (o *AddBackgroundRequest) SetContent(v string) {
o.Content = v
}
// GetUpdateDisposition returns the UpdateDisposition field value if set, zero value otherwise.
func (o *AddBackgroundRequest) GetUpdateDisposition() bool {
if o == nil || IsNil(o.UpdateDisposition) {
var ret bool
return ret
}
return *o.UpdateDisposition
}
// GetUpdateDispositionOk returns a tuple with the UpdateDisposition field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *AddBackgroundRequest) GetUpdateDispositionOk() (*bool, bool) {
if o == nil || IsNil(o.UpdateDisposition) {
return nil, false
}
return o.UpdateDisposition, true
}
// HasUpdateDisposition returns a boolean if a field has been set.
func (o *AddBackgroundRequest) HasUpdateDisposition() bool {
if o != nil && !IsNil(o.UpdateDisposition) {
return true
}
return false
}
// SetUpdateDisposition gets a reference to the given bool and assigns it to the UpdateDisposition field.
func (o *AddBackgroundRequest) SetUpdateDisposition(v bool) {
o.UpdateDisposition = &v
}
func (o AddBackgroundRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o AddBackgroundRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["content"] = o.Content
if !IsNil(o.UpdateDisposition) {
toSerialize["update_disposition"] = o.UpdateDisposition
}
return toSerialize, nil
}
func (o *AddBackgroundRequest) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"content",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varAddBackgroundRequest := _AddBackgroundRequest{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varAddBackgroundRequest)
if err != nil {
return err
}
*o = AddBackgroundRequest(varAddBackgroundRequest)
return err
}
type NullableAddBackgroundRequest struct {
value *AddBackgroundRequest
isSet bool
}
func (v NullableAddBackgroundRequest) Get() *AddBackgroundRequest {
return v.value
}
func (v *NullableAddBackgroundRequest) Set(val *AddBackgroundRequest) {
v.value = val
v.isSet = true
}
func (v NullableAddBackgroundRequest) IsSet() bool {
return v.isSet
}
func (v *NullableAddBackgroundRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableAddBackgroundRequest(val *AddBackgroundRequest) *NullableAddBackgroundRequest {
return &NullableAddBackgroundRequest{value: val, isSet: true}
}
func (v NullableAddBackgroundRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableAddBackgroundRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,186 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the AsyncOperationSubmitResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &AsyncOperationSubmitResponse{}
// AsyncOperationSubmitResponse Response model for submitting an async operation.
type AsyncOperationSubmitResponse struct {
OperationId string `json:"operation_id"`
Status string `json:"status"`
}
type _AsyncOperationSubmitResponse AsyncOperationSubmitResponse
// NewAsyncOperationSubmitResponse instantiates a new AsyncOperationSubmitResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewAsyncOperationSubmitResponse(operationId string, status string) *AsyncOperationSubmitResponse {
this := AsyncOperationSubmitResponse{}
this.OperationId = operationId
this.Status = status
return &this
}
// NewAsyncOperationSubmitResponseWithDefaults instantiates a new AsyncOperationSubmitResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewAsyncOperationSubmitResponseWithDefaults() *AsyncOperationSubmitResponse {
this := AsyncOperationSubmitResponse{}
return &this
}
// GetOperationId returns the OperationId field value
func (o *AsyncOperationSubmitResponse) GetOperationId() string {
if o == nil {
var ret string
return ret
}
return o.OperationId
}
// GetOperationIdOk returns a tuple with the OperationId field value
// and a boolean to check if the value has been set.
func (o *AsyncOperationSubmitResponse) GetOperationIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OperationId, true
}
// SetOperationId sets field value
func (o *AsyncOperationSubmitResponse) SetOperationId(v string) {
o.OperationId = v
}
// GetStatus returns the Status field value
func (o *AsyncOperationSubmitResponse) GetStatus() string {
if o == nil {
var ret string
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *AsyncOperationSubmitResponse) GetStatusOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *AsyncOperationSubmitResponse) SetStatus(v string) {
o.Status = v
}
func (o AsyncOperationSubmitResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o AsyncOperationSubmitResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["operation_id"] = o.OperationId
toSerialize["status"] = o.Status
return toSerialize, nil
}
func (o *AsyncOperationSubmitResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"operation_id",
"status",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varAsyncOperationSubmitResponse := _AsyncOperationSubmitResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varAsyncOperationSubmitResponse)
if err != nil {
return err
}
*o = AsyncOperationSubmitResponse(varAsyncOperationSubmitResponse)
return err
}
type NullableAsyncOperationSubmitResponse struct {
value *AsyncOperationSubmitResponse
isSet bool
}
func (v NullableAsyncOperationSubmitResponse) Get() *AsyncOperationSubmitResponse {
return v.value
}
func (v *NullableAsyncOperationSubmitResponse) Set(val *AsyncOperationSubmitResponse) {
v.value = val
v.isSet = true
}
func (v NullableAsyncOperationSubmitResponse) IsSet() bool {
return v.isSet
}
func (v *NullableAsyncOperationSubmitResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableAsyncOperationSubmitResponse(val *AsyncOperationSubmitResponse) *NullableAsyncOperationSubmitResponse {
return &NullableAsyncOperationSubmitResponse{value: val, isSet: true}
}
func (v NullableAsyncOperationSubmitResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableAsyncOperationSubmitResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,250 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BackgroundResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BackgroundResponse{}
// BackgroundResponse Response model for background update. Deprecated: use MissionResponse instead.
type BackgroundResponse struct {
Mission string `json:"mission"`
Background NullableString `json:"background,omitempty"`
Disposition NullableDispositionTraits `json:"disposition,omitempty"`
}
type _BackgroundResponse BackgroundResponse
// NewBackgroundResponse instantiates a new BackgroundResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBackgroundResponse(mission string) *BackgroundResponse {
this := BackgroundResponse{}
this.Mission = mission
return &this
}
// NewBackgroundResponseWithDefaults instantiates a new BackgroundResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBackgroundResponseWithDefaults() *BackgroundResponse {
this := BackgroundResponse{}
return &this
}
// GetMission returns the Mission field value
func (o *BackgroundResponse) GetMission() string {
if o == nil {
var ret string
return ret
}
return o.Mission
}
// GetMissionOk returns a tuple with the Mission field value
// and a boolean to check if the value has been set.
func (o *BackgroundResponse) GetMissionOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Mission, true
}
// SetMission sets field value
func (o *BackgroundResponse) SetMission(v string) {
o.Mission = v
}
// GetBackground returns the Background field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BackgroundResponse) GetBackground() string {
if o == nil || IsNil(o.Background.Get()) {
var ret string
return ret
}
return *o.Background.Get()
}
// GetBackgroundOk returns a tuple with the Background field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BackgroundResponse) GetBackgroundOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Background.Get(), o.Background.IsSet()
}
// HasBackground returns a boolean if a field has been set.
func (o *BackgroundResponse) HasBackground() bool {
if o != nil && o.Background.IsSet() {
return true
}
return false
}
// SetBackground gets a reference to the given NullableString and assigns it to the Background field.
func (o *BackgroundResponse) SetBackground(v string) {
o.Background.Set(&v)
}
// SetBackgroundNil sets the value for Background to be an explicit nil
func (o *BackgroundResponse) SetBackgroundNil() {
o.Background.Set(nil)
}
// UnsetBackground ensures that no value is present for Background, not even an explicit nil
func (o *BackgroundResponse) UnsetBackground() {
o.Background.Unset()
}
// GetDisposition returns the Disposition field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BackgroundResponse) GetDisposition() DispositionTraits {
if o == nil || IsNil(o.Disposition.Get()) {
var ret DispositionTraits
return ret
}
return *o.Disposition.Get()
}
// GetDispositionOk returns a tuple with the Disposition field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BackgroundResponse) GetDispositionOk() (*DispositionTraits, bool) {
if o == nil {
return nil, false
}
return o.Disposition.Get(), o.Disposition.IsSet()
}
// HasDisposition returns a boolean if a field has been set.
func (o *BackgroundResponse) HasDisposition() bool {
if o != nil && o.Disposition.IsSet() {
return true
}
return false
}
// SetDisposition gets a reference to the given NullableDispositionTraits and assigns it to the Disposition field.
func (o *BackgroundResponse) SetDisposition(v DispositionTraits) {
o.Disposition.Set(&v)
}
// SetDispositionNil sets the value for Disposition to be an explicit nil
func (o *BackgroundResponse) SetDispositionNil() {
o.Disposition.Set(nil)
}
// UnsetDisposition ensures that no value is present for Disposition, not even an explicit nil
func (o *BackgroundResponse) UnsetDisposition() {
o.Disposition.Unset()
}
func (o BackgroundResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BackgroundResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["mission"] = o.Mission
if o.Background.IsSet() {
toSerialize["background"] = o.Background.Get()
}
if o.Disposition.IsSet() {
toSerialize["disposition"] = o.Disposition.Get()
}
return toSerialize, nil
}
func (o *BackgroundResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"mission",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBackgroundResponse := _BackgroundResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBackgroundResponse)
if err != nil {
return err
}
*o = BackgroundResponse(varBackgroundResponse)
return err
}
type NullableBackgroundResponse struct {
value *BackgroundResponse
isSet bool
}
func (v NullableBackgroundResponse) Get() *BackgroundResponse {
return v.value
}
func (v *NullableBackgroundResponse) Set(val *BackgroundResponse) {
v.value = val
v.isSet = true
}
func (v NullableBackgroundResponse) IsSet() bool {
return v.isSet
}
func (v *NullableBackgroundResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBackgroundResponse(val *BackgroundResponse) *NullableBackgroundResponse {
return &NullableBackgroundResponse{value: val, isSet: true}
}
func (v NullableBackgroundResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBackgroundResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,217 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankConfigResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankConfigResponse{}
// BankConfigResponse Response model for bank configuration.
type BankConfigResponse struct {
// Bank identifier
BankId string `json:"bank_id"`
// Fully resolved configuration with all hierarchical overrides applied (Python field names)
Config map[string]interface{} `json:"config"`
// Bank-specific configuration overrides only (Python field names)
Overrides map[string]interface{} `json:"overrides"`
}
type _BankConfigResponse BankConfigResponse
// NewBankConfigResponse instantiates a new BankConfigResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankConfigResponse(bankId string, config map[string]interface{}, overrides map[string]interface{}) *BankConfigResponse {
this := BankConfigResponse{}
this.BankId = bankId
this.Config = config
this.Overrides = overrides
return &this
}
// NewBankConfigResponseWithDefaults instantiates a new BankConfigResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankConfigResponseWithDefaults() *BankConfigResponse {
this := BankConfigResponse{}
return &this
}
// GetBankId returns the BankId field value
func (o *BankConfigResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *BankConfigResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *BankConfigResponse) SetBankId(v string) {
o.BankId = v
}
// GetConfig returns the Config field value
func (o *BankConfigResponse) GetConfig() map[string]interface{} {
if o == nil {
var ret map[string]interface{}
return ret
}
return o.Config
}
// GetConfigOk returns a tuple with the Config field value
// and a boolean to check if the value has been set.
func (o *BankConfigResponse) GetConfigOk() (map[string]interface{}, bool) {
if o == nil {
return map[string]interface{}{}, false
}
return o.Config, true
}
// SetConfig sets field value
func (o *BankConfigResponse) SetConfig(v map[string]interface{}) {
o.Config = v
}
// GetOverrides returns the Overrides field value
func (o *BankConfigResponse) GetOverrides() map[string]interface{} {
if o == nil {
var ret map[string]interface{}
return ret
}
return o.Overrides
}
// GetOverridesOk returns a tuple with the Overrides field value
// and a boolean to check if the value has been set.
func (o *BankConfigResponse) GetOverridesOk() (map[string]interface{}, bool) {
if o == nil {
return map[string]interface{}{}, false
}
return o.Overrides, true
}
// SetOverrides sets field value
func (o *BankConfigResponse) SetOverrides(v map[string]interface{}) {
o.Overrides = v
}
func (o BankConfigResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankConfigResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["bank_id"] = o.BankId
toSerialize["config"] = o.Config
toSerialize["overrides"] = o.Overrides
return toSerialize, nil
}
func (o *BankConfigResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"bank_id",
"config",
"overrides",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankConfigResponse := _BankConfigResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankConfigResponse)
if err != nil {
return err
}
*o = BankConfigResponse(varBankConfigResponse)
return err
}
type NullableBankConfigResponse struct {
value *BankConfigResponse
isSet bool
}
func (v NullableBankConfigResponse) Get() *BankConfigResponse {
return v.value
}
func (v *NullableBankConfigResponse) Set(val *BankConfigResponse) {
v.value = val
v.isSet = true
}
func (v NullableBankConfigResponse) IsSet() bool {
return v.isSet
}
func (v *NullableBankConfigResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankConfigResponse(val *BankConfigResponse) *NullableBankConfigResponse {
return &NullableBankConfigResponse{value: val, isSet: true}
}
func (v NullableBankConfigResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankConfigResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,159 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankConfigUpdate type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankConfigUpdate{}
// BankConfigUpdate Request model for updating bank configuration.
type BankConfigUpdate struct {
// Configuration overrides. Keys can be in Python field format (llm_provider) or environment variable format (HINDSIGHT_API_LLM_PROVIDER). Only hierarchical fields can be overridden per-bank.
Updates map[string]interface{} `json:"updates"`
}
type _BankConfigUpdate BankConfigUpdate
// NewBankConfigUpdate instantiates a new BankConfigUpdate object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankConfigUpdate(updates map[string]interface{}) *BankConfigUpdate {
this := BankConfigUpdate{}
this.Updates = updates
return &this
}
// NewBankConfigUpdateWithDefaults instantiates a new BankConfigUpdate object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankConfigUpdateWithDefaults() *BankConfigUpdate {
this := BankConfigUpdate{}
return &this
}
// GetUpdates returns the Updates field value
func (o *BankConfigUpdate) GetUpdates() map[string]interface{} {
if o == nil {
var ret map[string]interface{}
return ret
}
return o.Updates
}
// GetUpdatesOk returns a tuple with the Updates field value
// and a boolean to check if the value has been set.
func (o *BankConfigUpdate) GetUpdatesOk() (map[string]interface{}, bool) {
if o == nil {
return map[string]interface{}{}, false
}
return o.Updates, true
}
// SetUpdates sets field value
func (o *BankConfigUpdate) SetUpdates(v map[string]interface{}) {
o.Updates = v
}
func (o BankConfigUpdate) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankConfigUpdate) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["updates"] = o.Updates
return toSerialize, nil
}
func (o *BankConfigUpdate) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"updates",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankConfigUpdate := _BankConfigUpdate{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankConfigUpdate)
if err != nil {
return err
}
*o = BankConfigUpdate(varBankConfigUpdate)
return err
}
type NullableBankConfigUpdate struct {
value *BankConfigUpdate
isSet bool
}
func (v NullableBankConfigUpdate) Get() *BankConfigUpdate {
return v.value
}
func (v *NullableBankConfigUpdate) Set(val *BankConfigUpdate) {
v.value = val
v.isSet = true
}
func (v NullableBankConfigUpdate) IsSet() bool {
return v.isSet
}
func (v *NullableBankConfigUpdate) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankConfigUpdate(val *BankConfigUpdate) *NullableBankConfigUpdate {
return &NullableBankConfigUpdate{value: val, isSet: true}
}
func (v NullableBankConfigUpdate) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankConfigUpdate) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,370 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankListItem type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankListItem{}
// BankListItem Bank list item with profile summary.
type BankListItem struct {
BankId string `json:"bank_id"`
Name NullableString `json:"name,omitempty"`
Disposition DispositionTraits `json:"disposition"`
Mission NullableString `json:"mission,omitempty"`
CreatedAt NullableString `json:"created_at,omitempty"`
UpdatedAt NullableString `json:"updated_at,omitempty"`
}
type _BankListItem BankListItem
// NewBankListItem instantiates a new BankListItem object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankListItem(bankId string, disposition DispositionTraits) *BankListItem {
this := BankListItem{}
this.BankId = bankId
this.Disposition = disposition
return &this
}
// NewBankListItemWithDefaults instantiates a new BankListItem object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankListItemWithDefaults() *BankListItem {
this := BankListItem{}
return &this
}
// GetBankId returns the BankId field value
func (o *BankListItem) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *BankListItem) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *BankListItem) SetBankId(v string) {
o.BankId = v
}
// GetName returns the Name field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankListItem) GetName() string {
if o == nil || IsNil(o.Name.Get()) {
var ret string
return ret
}
return *o.Name.Get()
}
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankListItem) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Name.Get(), o.Name.IsSet()
}
// HasName returns a boolean if a field has been set.
func (o *BankListItem) HasName() bool {
if o != nil && o.Name.IsSet() {
return true
}
return false
}
// SetName gets a reference to the given NullableString and assigns it to the Name field.
func (o *BankListItem) SetName(v string) {
o.Name.Set(&v)
}
// SetNameNil sets the value for Name to be an explicit nil
func (o *BankListItem) SetNameNil() {
o.Name.Set(nil)
}
// UnsetName ensures that no value is present for Name, not even an explicit nil
func (o *BankListItem) UnsetName() {
o.Name.Unset()
}
// GetDisposition returns the Disposition field value
func (o *BankListItem) GetDisposition() DispositionTraits {
if o == nil {
var ret DispositionTraits
return ret
}
return o.Disposition
}
// GetDispositionOk returns a tuple with the Disposition field value
// and a boolean to check if the value has been set.
func (o *BankListItem) GetDispositionOk() (*DispositionTraits, bool) {
if o == nil {
return nil, false
}
return &o.Disposition, true
}
// SetDisposition sets field value
func (o *BankListItem) SetDisposition(v DispositionTraits) {
o.Disposition = v
}
// GetMission returns the Mission field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankListItem) GetMission() string {
if o == nil || IsNil(o.Mission.Get()) {
var ret string
return ret
}
return *o.Mission.Get()
}
// GetMissionOk returns a tuple with the Mission field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankListItem) GetMissionOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Mission.Get(), o.Mission.IsSet()
}
// HasMission returns a boolean if a field has been set.
func (o *BankListItem) HasMission() bool {
if o != nil && o.Mission.IsSet() {
return true
}
return false
}
// SetMission gets a reference to the given NullableString and assigns it to the Mission field.
func (o *BankListItem) SetMission(v string) {
o.Mission.Set(&v)
}
// SetMissionNil sets the value for Mission to be an explicit nil
func (o *BankListItem) SetMissionNil() {
o.Mission.Set(nil)
}
// UnsetMission ensures that no value is present for Mission, not even an explicit nil
func (o *BankListItem) UnsetMission() {
o.Mission.Unset()
}
// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankListItem) GetCreatedAt() string {
if o == nil || IsNil(o.CreatedAt.Get()) {
var ret string
return ret
}
return *o.CreatedAt.Get()
}
// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankListItem) GetCreatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.CreatedAt.Get(), o.CreatedAt.IsSet()
}
// HasCreatedAt returns a boolean if a field has been set.
func (o *BankListItem) HasCreatedAt() bool {
if o != nil && o.CreatedAt.IsSet() {
return true
}
return false
}
// SetCreatedAt gets a reference to the given NullableString and assigns it to the CreatedAt field.
func (o *BankListItem) SetCreatedAt(v string) {
o.CreatedAt.Set(&v)
}
// SetCreatedAtNil sets the value for CreatedAt to be an explicit nil
func (o *BankListItem) SetCreatedAtNil() {
o.CreatedAt.Set(nil)
}
// UnsetCreatedAt ensures that no value is present for CreatedAt, not even an explicit nil
func (o *BankListItem) UnsetCreatedAt() {
o.CreatedAt.Unset()
}
// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankListItem) GetUpdatedAt() string {
if o == nil || IsNil(o.UpdatedAt.Get()) {
var ret string
return ret
}
return *o.UpdatedAt.Get()
}
// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankListItem) GetUpdatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.UpdatedAt.Get(), o.UpdatedAt.IsSet()
}
// HasUpdatedAt returns a boolean if a field has been set.
func (o *BankListItem) HasUpdatedAt() bool {
if o != nil && o.UpdatedAt.IsSet() {
return true
}
return false
}
// SetUpdatedAt gets a reference to the given NullableString and assigns it to the UpdatedAt field.
func (o *BankListItem) SetUpdatedAt(v string) {
o.UpdatedAt.Set(&v)
}
// SetUpdatedAtNil sets the value for UpdatedAt to be an explicit nil
func (o *BankListItem) SetUpdatedAtNil() {
o.UpdatedAt.Set(nil)
}
// UnsetUpdatedAt ensures that no value is present for UpdatedAt, not even an explicit nil
func (o *BankListItem) UnsetUpdatedAt() {
o.UpdatedAt.Unset()
}
func (o BankListItem) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankListItem) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["bank_id"] = o.BankId
if o.Name.IsSet() {
toSerialize["name"] = o.Name.Get()
}
toSerialize["disposition"] = o.Disposition
if o.Mission.IsSet() {
toSerialize["mission"] = o.Mission.Get()
}
if o.CreatedAt.IsSet() {
toSerialize["created_at"] = o.CreatedAt.Get()
}
if o.UpdatedAt.IsSet() {
toSerialize["updated_at"] = o.UpdatedAt.Get()
}
return toSerialize, nil
}
func (o *BankListItem) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"bank_id",
"disposition",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankListItem := _BankListItem{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankListItem)
if err != nil {
return err
}
*o = BankListItem(varBankListItem)
return err
}
type NullableBankListItem struct {
value *BankListItem
isSet bool
}
func (v NullableBankListItem) Get() *BankListItem {
return v.value
}
func (v *NullableBankListItem) Set(val *BankListItem) {
v.value = val
v.isSet = true
}
func (v NullableBankListItem) IsSet() bool {
return v.isSet
}
func (v *NullableBankListItem) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankListItem(val *BankListItem) *NullableBankListItem {
return &NullableBankListItem{value: val, isSet: true}
}
func (v NullableBankListItem) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankListItem) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,158 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankListResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankListResponse{}
// BankListResponse Response model for listing all banks.
type BankListResponse struct {
Banks []BankListItem `json:"banks"`
}
type _BankListResponse BankListResponse
// NewBankListResponse instantiates a new BankListResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankListResponse(banks []BankListItem) *BankListResponse {
this := BankListResponse{}
this.Banks = banks
return &this
}
// NewBankListResponseWithDefaults instantiates a new BankListResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankListResponseWithDefaults() *BankListResponse {
this := BankListResponse{}
return &this
}
// GetBanks returns the Banks field value
func (o *BankListResponse) GetBanks() []BankListItem {
if o == nil {
var ret []BankListItem
return ret
}
return o.Banks
}
// GetBanksOk returns a tuple with the Banks field value
// and a boolean to check if the value has been set.
func (o *BankListResponse) GetBanksOk() ([]BankListItem, bool) {
if o == nil {
return nil, false
}
return o.Banks, true
}
// SetBanks sets field value
func (o *BankListResponse) SetBanks(v []BankListItem) {
o.Banks = v
}
func (o BankListResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankListResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["banks"] = o.Banks
return toSerialize, nil
}
func (o *BankListResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"banks",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankListResponse := _BankListResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankListResponse)
if err != nil {
return err
}
*o = BankListResponse(varBankListResponse)
return err
}
type NullableBankListResponse struct {
value *BankListResponse
isSet bool
}
func (v NullableBankListResponse) Get() *BankListResponse {
return v.value
}
func (v *NullableBankListResponse) Set(val *BankListResponse) {
v.value = val
v.isSet = true
}
func (v NullableBankListResponse) IsSet() bool {
return v.isSet
}
func (v *NullableBankListResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankListResponse(val *BankListResponse) *NullableBankListResponse {
return &NullableBankListResponse{value: val, isSet: true}
}
func (v NullableBankListResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankListResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,289 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankProfileResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankProfileResponse{}
// BankProfileResponse Response model for bank profile.
type BankProfileResponse struct {
BankId string `json:"bank_id"`
Name string `json:"name"`
Disposition DispositionTraits `json:"disposition"`
// The agent's mission - who they are and what they're trying to accomplish
Mission string `json:"mission"`
Background NullableString `json:"background,omitempty"`
}
type _BankProfileResponse BankProfileResponse
// NewBankProfileResponse instantiates a new BankProfileResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankProfileResponse(bankId string, name string, disposition DispositionTraits, mission string) *BankProfileResponse {
this := BankProfileResponse{}
this.BankId = bankId
this.Name = name
this.Disposition = disposition
this.Mission = mission
return &this
}
// NewBankProfileResponseWithDefaults instantiates a new BankProfileResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankProfileResponseWithDefaults() *BankProfileResponse {
this := BankProfileResponse{}
return &this
}
// GetBankId returns the BankId field value
func (o *BankProfileResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *BankProfileResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *BankProfileResponse) SetBankId(v string) {
o.BankId = v
}
// GetName returns the Name field value
func (o *BankProfileResponse) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *BankProfileResponse) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *BankProfileResponse) SetName(v string) {
o.Name = v
}
// GetDisposition returns the Disposition field value
func (o *BankProfileResponse) GetDisposition() DispositionTraits {
if o == nil {
var ret DispositionTraits
return ret
}
return o.Disposition
}
// GetDispositionOk returns a tuple with the Disposition field value
// and a boolean to check if the value has been set.
func (o *BankProfileResponse) GetDispositionOk() (*DispositionTraits, bool) {
if o == nil {
return nil, false
}
return &o.Disposition, true
}
// SetDisposition sets field value
func (o *BankProfileResponse) SetDisposition(v DispositionTraits) {
o.Disposition = v
}
// GetMission returns the Mission field value
func (o *BankProfileResponse) GetMission() string {
if o == nil {
var ret string
return ret
}
return o.Mission
}
// GetMissionOk returns a tuple with the Mission field value
// and a boolean to check if the value has been set.
func (o *BankProfileResponse) GetMissionOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Mission, true
}
// SetMission sets field value
func (o *BankProfileResponse) SetMission(v string) {
o.Mission = v
}
// GetBackground returns the Background field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankProfileResponse) GetBackground() string {
if o == nil || IsNil(o.Background.Get()) {
var ret string
return ret
}
return *o.Background.Get()
}
// GetBackgroundOk returns a tuple with the Background field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankProfileResponse) GetBackgroundOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Background.Get(), o.Background.IsSet()
}
// HasBackground returns a boolean if a field has been set.
func (o *BankProfileResponse) HasBackground() bool {
if o != nil && o.Background.IsSet() {
return true
}
return false
}
// SetBackground gets a reference to the given NullableString and assigns it to the Background field.
func (o *BankProfileResponse) SetBackground(v string) {
o.Background.Set(&v)
}
// SetBackgroundNil sets the value for Background to be an explicit nil
func (o *BankProfileResponse) SetBackgroundNil() {
o.Background.Set(nil)
}
// UnsetBackground ensures that no value is present for Background, not even an explicit nil
func (o *BankProfileResponse) UnsetBackground() {
o.Background.Unset()
}
func (o BankProfileResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankProfileResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["bank_id"] = o.BankId
toSerialize["name"] = o.Name
toSerialize["disposition"] = o.Disposition
toSerialize["mission"] = o.Mission
if o.Background.IsSet() {
toSerialize["background"] = o.Background.Get()
}
return toSerialize, nil
}
func (o *BankProfileResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"bank_id",
"name",
"disposition",
"mission",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankProfileResponse := _BankProfileResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankProfileResponse)
if err != nil {
return err
}
*o = BankProfileResponse(varBankProfileResponse)
return err
}
type NullableBankProfileResponse struct {
value *BankProfileResponse
isSet bool
}
func (v NullableBankProfileResponse) Get() *BankProfileResponse {
return v.value
}
func (v *NullableBankProfileResponse) Set(val *BankProfileResponse) {
v.value = val
v.isSet = true
}
func (v NullableBankProfileResponse) IsSet() bool {
return v.isSet
}
func (v *NullableBankProfileResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankProfileResponse(val *BankProfileResponse) *NullableBankProfileResponse {
return &NullableBankProfileResponse{value: val, isSet: true}
}
func (v NullableBankProfileResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankProfileResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,538 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the BankStatsResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &BankStatsResponse{}
// BankStatsResponse Response model for bank statistics endpoint.
type BankStatsResponse struct {
BankId string `json:"bank_id"`
TotalNodes int32 `json:"total_nodes"`
TotalLinks int32 `json:"total_links"`
TotalDocuments int32 `json:"total_documents"`
NodesByFactType map[string]int32 `json:"nodes_by_fact_type"`
LinksByLinkType map[string]int32 `json:"links_by_link_type"`
LinksByFactType map[string]int32 `json:"links_by_fact_type"`
LinksBreakdown map[string]map[string]int32 `json:"links_breakdown"`
PendingOperations int32 `json:"pending_operations"`
FailedOperations int32 `json:"failed_operations"`
LastConsolidatedAt NullableString `json:"last_consolidated_at,omitempty"`
// Number of memories not yet processed into observations
PendingConsolidation *int32 `json:"pending_consolidation,omitempty"`
// Total number of observations
TotalObservations *int32 `json:"total_observations,omitempty"`
}
type _BankStatsResponse BankStatsResponse
// NewBankStatsResponse instantiates a new BankStatsResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBankStatsResponse(bankId string, totalNodes int32, totalLinks int32, totalDocuments int32, nodesByFactType map[string]int32, linksByLinkType map[string]int32, linksByFactType map[string]int32, linksBreakdown map[string]map[string]int32, pendingOperations int32, failedOperations int32) *BankStatsResponse {
this := BankStatsResponse{}
this.BankId = bankId
this.TotalNodes = totalNodes
this.TotalLinks = totalLinks
this.TotalDocuments = totalDocuments
this.NodesByFactType = nodesByFactType
this.LinksByLinkType = linksByLinkType
this.LinksByFactType = linksByFactType
this.LinksBreakdown = linksBreakdown
this.PendingOperations = pendingOperations
this.FailedOperations = failedOperations
var pendingConsolidation int32 = 0
this.PendingConsolidation = &pendingConsolidation
var totalObservations int32 = 0
this.TotalObservations = &totalObservations
return &this
}
// NewBankStatsResponseWithDefaults instantiates a new BankStatsResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBankStatsResponseWithDefaults() *BankStatsResponse {
this := BankStatsResponse{}
var pendingConsolidation int32 = 0
this.PendingConsolidation = &pendingConsolidation
var totalObservations int32 = 0
this.TotalObservations = &totalObservations
return &this
}
// GetBankId returns the BankId field value
func (o *BankStatsResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *BankStatsResponse) SetBankId(v string) {
o.BankId = v
}
// GetTotalNodes returns the TotalNodes field value
func (o *BankStatsResponse) GetTotalNodes() int32 {
if o == nil {
var ret int32
return ret
}
return o.TotalNodes
}
// GetTotalNodesOk returns a tuple with the TotalNodes field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetTotalNodesOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.TotalNodes, true
}
// SetTotalNodes sets field value
func (o *BankStatsResponse) SetTotalNodes(v int32) {
o.TotalNodes = v
}
// GetTotalLinks returns the TotalLinks field value
func (o *BankStatsResponse) GetTotalLinks() int32 {
if o == nil {
var ret int32
return ret
}
return o.TotalLinks
}
// GetTotalLinksOk returns a tuple with the TotalLinks field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetTotalLinksOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.TotalLinks, true
}
// SetTotalLinks sets field value
func (o *BankStatsResponse) SetTotalLinks(v int32) {
o.TotalLinks = v
}
// GetTotalDocuments returns the TotalDocuments field value
func (o *BankStatsResponse) GetTotalDocuments() int32 {
if o == nil {
var ret int32
return ret
}
return o.TotalDocuments
}
// GetTotalDocumentsOk returns a tuple with the TotalDocuments field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetTotalDocumentsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.TotalDocuments, true
}
// SetTotalDocuments sets field value
func (o *BankStatsResponse) SetTotalDocuments(v int32) {
o.TotalDocuments = v
}
// GetNodesByFactType returns the NodesByFactType field value
func (o *BankStatsResponse) GetNodesByFactType() map[string]int32 {
if o == nil {
var ret map[string]int32
return ret
}
return o.NodesByFactType
}
// GetNodesByFactTypeOk returns a tuple with the NodesByFactType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetNodesByFactTypeOk() (map[string]int32, bool) {
if o == nil {
return map[string]int32{}, false
}
return o.NodesByFactType, true
}
// SetNodesByFactType sets field value
func (o *BankStatsResponse) SetNodesByFactType(v map[string]int32) {
o.NodesByFactType = v
}
// GetLinksByLinkType returns the LinksByLinkType field value
func (o *BankStatsResponse) GetLinksByLinkType() map[string]int32 {
if o == nil {
var ret map[string]int32
return ret
}
return o.LinksByLinkType
}
// GetLinksByLinkTypeOk returns a tuple with the LinksByLinkType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksByLinkTypeOk() (map[string]int32, bool) {
if o == nil {
return map[string]int32{}, false
}
return o.LinksByLinkType, true
}
// SetLinksByLinkType sets field value
func (o *BankStatsResponse) SetLinksByLinkType(v map[string]int32) {
o.LinksByLinkType = v
}
// GetLinksByFactType returns the LinksByFactType field value
func (o *BankStatsResponse) GetLinksByFactType() map[string]int32 {
if o == nil {
var ret map[string]int32
return ret
}
return o.LinksByFactType
}
// GetLinksByFactTypeOk returns a tuple with the LinksByFactType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksByFactTypeOk() (map[string]int32, bool) {
if o == nil {
return map[string]int32{}, false
}
return o.LinksByFactType, true
}
// SetLinksByFactType sets field value
func (o *BankStatsResponse) SetLinksByFactType(v map[string]int32) {
o.LinksByFactType = v
}
// GetLinksBreakdown returns the LinksBreakdown field value
func (o *BankStatsResponse) GetLinksBreakdown() map[string]map[string]int32 {
if o == nil {
var ret map[string]map[string]int32
return ret
}
return o.LinksBreakdown
}
// GetLinksBreakdownOk returns a tuple with the LinksBreakdown field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksBreakdownOk() (map[string]map[string]int32, bool) {
if o == nil {
return map[string]map[string]int32{}, false
}
return o.LinksBreakdown, true
}
// SetLinksBreakdown sets field value
func (o *BankStatsResponse) SetLinksBreakdown(v map[string]map[string]int32) {
o.LinksBreakdown = v
}
// GetPendingOperations returns the PendingOperations field value
func (o *BankStatsResponse) GetPendingOperations() int32 {
if o == nil {
var ret int32
return ret
}
return o.PendingOperations
}
// GetPendingOperationsOk returns a tuple with the PendingOperations field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetPendingOperationsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.PendingOperations, true
}
// SetPendingOperations sets field value
func (o *BankStatsResponse) SetPendingOperations(v int32) {
o.PendingOperations = v
}
// GetFailedOperations returns the FailedOperations field value
func (o *BankStatsResponse) GetFailedOperations() int32 {
if o == nil {
var ret int32
return ret
}
return o.FailedOperations
}
// GetFailedOperationsOk returns a tuple with the FailedOperations field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetFailedOperationsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.FailedOperations, true
}
// SetFailedOperations sets field value
func (o *BankStatsResponse) SetFailedOperations(v int32) {
o.FailedOperations = v
}
// GetLastConsolidatedAt returns the LastConsolidatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankStatsResponse) GetLastConsolidatedAt() string {
if o == nil || IsNil(o.LastConsolidatedAt.Get()) {
var ret string
return ret
}
return *o.LastConsolidatedAt.Get()
}
// GetLastConsolidatedAtOk returns a tuple with the LastConsolidatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *BankStatsResponse) GetLastConsolidatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastConsolidatedAt.Get(), o.LastConsolidatedAt.IsSet()
}
// HasLastConsolidatedAt returns a boolean if a field has been set.
func (o *BankStatsResponse) HasLastConsolidatedAt() bool {
if o != nil && o.LastConsolidatedAt.IsSet() {
return true
}
return false
}
// SetLastConsolidatedAt gets a reference to the given NullableString and assigns it to the LastConsolidatedAt field.
func (o *BankStatsResponse) SetLastConsolidatedAt(v string) {
o.LastConsolidatedAt.Set(&v)
}
// SetLastConsolidatedAtNil sets the value for LastConsolidatedAt to be an explicit nil
func (o *BankStatsResponse) SetLastConsolidatedAtNil() {
o.LastConsolidatedAt.Set(nil)
}
// UnsetLastConsolidatedAt ensures that no value is present for LastConsolidatedAt, not even an explicit nil
func (o *BankStatsResponse) UnsetLastConsolidatedAt() {
o.LastConsolidatedAt.Unset()
}
// GetPendingConsolidation returns the PendingConsolidation field value if set, zero value otherwise.
func (o *BankStatsResponse) GetPendingConsolidation() int32 {
if o == nil || IsNil(o.PendingConsolidation) {
var ret int32
return ret
}
return *o.PendingConsolidation
}
// GetPendingConsolidationOk returns a tuple with the PendingConsolidation field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetPendingConsolidationOk() (*int32, bool) {
if o == nil || IsNil(o.PendingConsolidation) {
return nil, false
}
return o.PendingConsolidation, true
}
// HasPendingConsolidation returns a boolean if a field has been set.
func (o *BankStatsResponse) HasPendingConsolidation() bool {
if o != nil && !IsNil(o.PendingConsolidation) {
return true
}
return false
}
// SetPendingConsolidation gets a reference to the given int32 and assigns it to the PendingConsolidation field.
func (o *BankStatsResponse) SetPendingConsolidation(v int32) {
o.PendingConsolidation = &v
}
// GetTotalObservations returns the TotalObservations field value if set, zero value otherwise.
func (o *BankStatsResponse) GetTotalObservations() int32 {
if o == nil || IsNil(o.TotalObservations) {
var ret int32
return ret
}
return *o.TotalObservations
}
// GetTotalObservationsOk returns a tuple with the TotalObservations field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetTotalObservationsOk() (*int32, bool) {
if o == nil || IsNil(o.TotalObservations) {
return nil, false
}
return o.TotalObservations, true
}
// HasTotalObservations returns a boolean if a field has been set.
func (o *BankStatsResponse) HasTotalObservations() bool {
if o != nil && !IsNil(o.TotalObservations) {
return true
}
return false
}
// SetTotalObservations gets a reference to the given int32 and assigns it to the TotalObservations field.
func (o *BankStatsResponse) SetTotalObservations(v int32) {
o.TotalObservations = &v
}
func (o BankStatsResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o BankStatsResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["bank_id"] = o.BankId
toSerialize["total_nodes"] = o.TotalNodes
toSerialize["total_links"] = o.TotalLinks
toSerialize["total_documents"] = o.TotalDocuments
toSerialize["nodes_by_fact_type"] = o.NodesByFactType
toSerialize["links_by_link_type"] = o.LinksByLinkType
toSerialize["links_by_fact_type"] = o.LinksByFactType
toSerialize["links_breakdown"] = o.LinksBreakdown
toSerialize["pending_operations"] = o.PendingOperations
toSerialize["failed_operations"] = o.FailedOperations
if o.LastConsolidatedAt.IsSet() {
toSerialize["last_consolidated_at"] = o.LastConsolidatedAt.Get()
}
if !IsNil(o.PendingConsolidation) {
toSerialize["pending_consolidation"] = o.PendingConsolidation
}
if !IsNil(o.TotalObservations) {
toSerialize["total_observations"] = o.TotalObservations
}
return toSerialize, nil
}
func (o *BankStatsResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"bank_id",
"total_nodes",
"total_links",
"total_documents",
"nodes_by_fact_type",
"links_by_link_type",
"links_by_fact_type",
"links_breakdown",
"pending_operations",
"failed_operations",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varBankStatsResponse := _BankStatsResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varBankStatsResponse)
if err != nil {
return err
}
*o = BankStatsResponse(varBankStatsResponse)
return err
}
type NullableBankStatsResponse struct {
value *BankStatsResponse
isSet bool
}
func (v NullableBankStatsResponse) Get() *BankStatsResponse {
return v.value
}
func (v *NullableBankStatsResponse) Set(val *BankStatsResponse) {
v.value = val
v.isSet = true
}
func (v NullableBankStatsResponse) IsSet() bool {
return v.isSet
}
func (v *NullableBankStatsResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBankStatsResponse(val *BankStatsResponse) *NullableBankStatsResponse {
return &NullableBankStatsResponse{value: val, isSet: true}
}
func (v NullableBankStatsResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBankStatsResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
-113
View File
@@ -1,113 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"fmt"
)
// Budget Budget levels for recall/reflect operations.
type Budget string
// List of Budget
const (
LOW Budget = "low"
MID Budget = "mid"
HIGH Budget = "high"
)
// All allowed values of Budget enum
var AllowedBudgetEnumValues = []Budget{
"low",
"mid",
"high",
}
func (v *Budget) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
enumTypeValue := Budget(value)
for _, existing := range AllowedBudgetEnumValues {
if existing == enumTypeValue {
*v = enumTypeValue
return nil
}
}
return fmt.Errorf("%+v is not a valid Budget", value)
}
// NewBudgetFromValue returns a pointer to a valid Budget
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewBudgetFromValue(v string) (*Budget, error) {
ev := Budget(v)
if ev.IsValid() {
return &ev, nil
} else {
return nil, fmt.Errorf("invalid value '%v' for Budget: valid values are %v", v, AllowedBudgetEnumValues)
}
}
// IsValid return true if the value is valid for the enum, false otherwise
func (v Budget) IsValid() bool {
for _, existing := range AllowedBudgetEnumValues {
if existing == v {
return true
}
}
return false
}
// Ptr returns reference to Budget value
func (v Budget) Ptr() *Budget {
return &v
}
type NullableBudget struct {
value *Budget
isSet bool
}
func (v NullableBudget) Get() *Budget {
return v.value
}
func (v *NullableBudget) Set(val *Budget) {
v.value = val
v.isSet = true
}
func (v NullableBudget) IsSet() bool {
return v.isSet
}
func (v *NullableBudget) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBudget(val *Budget) *NullableBudget {
return &NullableBudget{value: val, isSet: true}
}
func (v NullableBudget) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBudget) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,214 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the CancelOperationResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CancelOperationResponse{}
// CancelOperationResponse Response model for cancel operation endpoint.
type CancelOperationResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
OperationId string `json:"operation_id"`
}
type _CancelOperationResponse CancelOperationResponse
// NewCancelOperationResponse instantiates a new CancelOperationResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCancelOperationResponse(success bool, message string, operationId string) *CancelOperationResponse {
this := CancelOperationResponse{}
this.Success = success
this.Message = message
this.OperationId = operationId
return &this
}
// NewCancelOperationResponseWithDefaults instantiates a new CancelOperationResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCancelOperationResponseWithDefaults() *CancelOperationResponse {
this := CancelOperationResponse{}
return &this
}
// GetSuccess returns the Success field value
func (o *CancelOperationResponse) GetSuccess() bool {
if o == nil {
var ret bool
return ret
}
return o.Success
}
// GetSuccessOk returns a tuple with the Success field value
// and a boolean to check if the value has been set.
func (o *CancelOperationResponse) GetSuccessOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Success, true
}
// SetSuccess sets field value
func (o *CancelOperationResponse) SetSuccess(v bool) {
o.Success = v
}
// GetMessage returns the Message field value
func (o *CancelOperationResponse) GetMessage() string {
if o == nil {
var ret string
return ret
}
return o.Message
}
// GetMessageOk returns a tuple with the Message field value
// and a boolean to check if the value has been set.
func (o *CancelOperationResponse) GetMessageOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Message, true
}
// SetMessage sets field value
func (o *CancelOperationResponse) SetMessage(v string) {
o.Message = v
}
// GetOperationId returns the OperationId field value
func (o *CancelOperationResponse) GetOperationId() string {
if o == nil {
var ret string
return ret
}
return o.OperationId
}
// GetOperationIdOk returns a tuple with the OperationId field value
// and a boolean to check if the value has been set.
func (o *CancelOperationResponse) GetOperationIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OperationId, true
}
// SetOperationId sets field value
func (o *CancelOperationResponse) SetOperationId(v string) {
o.OperationId = v
}
func (o CancelOperationResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CancelOperationResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["success"] = o.Success
toSerialize["message"] = o.Message
toSerialize["operation_id"] = o.OperationId
return toSerialize, nil
}
func (o *CancelOperationResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"success",
"message",
"operation_id",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varCancelOperationResponse := _CancelOperationResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCancelOperationResponse)
if err != nil {
return err
}
*o = CancelOperationResponse(varCancelOperationResponse)
return err
}
type NullableCancelOperationResponse struct {
value *CancelOperationResponse
isSet bool
}
func (v NullableCancelOperationResponse) Get() *CancelOperationResponse {
return v.value
}
func (v *NullableCancelOperationResponse) Set(val *CancelOperationResponse) {
v.value = val
v.isSet = true
}
func (v NullableCancelOperationResponse) IsSet() bool {
return v.isSet
}
func (v *NullableCancelOperationResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCancelOperationResponse(val *CancelOperationResponse) *NullableCancelOperationResponse {
return &NullableCancelOperationResponse{value: val, isSet: true}
}
func (v NullableCancelOperationResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCancelOperationResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,324 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the ChildOperationStatus type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ChildOperationStatus{}
// ChildOperationStatus Status of a child operation (for batch operations).
type ChildOperationStatus struct {
OperationId string `json:"operation_id"`
Status string `json:"status"`
SubBatchIndex NullableInt32 `json:"sub_batch_index,omitempty"`
ItemsCount NullableInt32 `json:"items_count,omitempty"`
ErrorMessage NullableString `json:"error_message,omitempty"`
}
type _ChildOperationStatus ChildOperationStatus
// NewChildOperationStatus instantiates a new ChildOperationStatus object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewChildOperationStatus(operationId string, status string) *ChildOperationStatus {
this := ChildOperationStatus{}
this.OperationId = operationId
this.Status = status
return &this
}
// NewChildOperationStatusWithDefaults instantiates a new ChildOperationStatus object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewChildOperationStatusWithDefaults() *ChildOperationStatus {
this := ChildOperationStatus{}
return &this
}
// GetOperationId returns the OperationId field value
func (o *ChildOperationStatus) GetOperationId() string {
if o == nil {
var ret string
return ret
}
return o.OperationId
}
// GetOperationIdOk returns a tuple with the OperationId field value
// and a boolean to check if the value has been set.
func (o *ChildOperationStatus) GetOperationIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OperationId, true
}
// SetOperationId sets field value
func (o *ChildOperationStatus) SetOperationId(v string) {
o.OperationId = v
}
// GetStatus returns the Status field value
func (o *ChildOperationStatus) GetStatus() string {
if o == nil {
var ret string
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *ChildOperationStatus) GetStatusOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *ChildOperationStatus) SetStatus(v string) {
o.Status = v
}
// GetSubBatchIndex returns the SubBatchIndex field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *ChildOperationStatus) GetSubBatchIndex() int32 {
if o == nil || IsNil(o.SubBatchIndex.Get()) {
var ret int32
return ret
}
return *o.SubBatchIndex.Get()
}
// GetSubBatchIndexOk returns a tuple with the SubBatchIndex field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ChildOperationStatus) GetSubBatchIndexOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.SubBatchIndex.Get(), o.SubBatchIndex.IsSet()
}
// HasSubBatchIndex returns a boolean if a field has been set.
func (o *ChildOperationStatus) HasSubBatchIndex() bool {
if o != nil && o.SubBatchIndex.IsSet() {
return true
}
return false
}
// SetSubBatchIndex gets a reference to the given NullableInt32 and assigns it to the SubBatchIndex field.
func (o *ChildOperationStatus) SetSubBatchIndex(v int32) {
o.SubBatchIndex.Set(&v)
}
// SetSubBatchIndexNil sets the value for SubBatchIndex to be an explicit nil
func (o *ChildOperationStatus) SetSubBatchIndexNil() {
o.SubBatchIndex.Set(nil)
}
// UnsetSubBatchIndex ensures that no value is present for SubBatchIndex, not even an explicit nil
func (o *ChildOperationStatus) UnsetSubBatchIndex() {
o.SubBatchIndex.Unset()
}
// GetItemsCount returns the ItemsCount field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *ChildOperationStatus) GetItemsCount() int32 {
if o == nil || IsNil(o.ItemsCount.Get()) {
var ret int32
return ret
}
return *o.ItemsCount.Get()
}
// GetItemsCountOk returns a tuple with the ItemsCount field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ChildOperationStatus) GetItemsCountOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.ItemsCount.Get(), o.ItemsCount.IsSet()
}
// HasItemsCount returns a boolean if a field has been set.
func (o *ChildOperationStatus) HasItemsCount() bool {
if o != nil && o.ItemsCount.IsSet() {
return true
}
return false
}
// SetItemsCount gets a reference to the given NullableInt32 and assigns it to the ItemsCount field.
func (o *ChildOperationStatus) SetItemsCount(v int32) {
o.ItemsCount.Set(&v)
}
// SetItemsCountNil sets the value for ItemsCount to be an explicit nil
func (o *ChildOperationStatus) SetItemsCountNil() {
o.ItemsCount.Set(nil)
}
// UnsetItemsCount ensures that no value is present for ItemsCount, not even an explicit nil
func (o *ChildOperationStatus) UnsetItemsCount() {
o.ItemsCount.Unset()
}
// GetErrorMessage returns the ErrorMessage field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *ChildOperationStatus) GetErrorMessage() string {
if o == nil || IsNil(o.ErrorMessage.Get()) {
var ret string
return ret
}
return *o.ErrorMessage.Get()
}
// GetErrorMessageOk returns a tuple with the ErrorMessage field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ChildOperationStatus) GetErrorMessageOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.ErrorMessage.Get(), o.ErrorMessage.IsSet()
}
// HasErrorMessage returns a boolean if a field has been set.
func (o *ChildOperationStatus) HasErrorMessage() bool {
if o != nil && o.ErrorMessage.IsSet() {
return true
}
return false
}
// SetErrorMessage gets a reference to the given NullableString and assigns it to the ErrorMessage field.
func (o *ChildOperationStatus) SetErrorMessage(v string) {
o.ErrorMessage.Set(&v)
}
// SetErrorMessageNil sets the value for ErrorMessage to be an explicit nil
func (o *ChildOperationStatus) SetErrorMessageNil() {
o.ErrorMessage.Set(nil)
}
// UnsetErrorMessage ensures that no value is present for ErrorMessage, not even an explicit nil
func (o *ChildOperationStatus) UnsetErrorMessage() {
o.ErrorMessage.Unset()
}
func (o ChildOperationStatus) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ChildOperationStatus) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["operation_id"] = o.OperationId
toSerialize["status"] = o.Status
if o.SubBatchIndex.IsSet() {
toSerialize["sub_batch_index"] = o.SubBatchIndex.Get()
}
if o.ItemsCount.IsSet() {
toSerialize["items_count"] = o.ItemsCount.Get()
}
if o.ErrorMessage.IsSet() {
toSerialize["error_message"] = o.ErrorMessage.Get()
}
return toSerialize, nil
}
func (o *ChildOperationStatus) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"operation_id",
"status",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varChildOperationStatus := _ChildOperationStatus{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varChildOperationStatus)
if err != nil {
return err
}
*o = ChildOperationStatus(varChildOperationStatus)
return err
}
type NullableChildOperationStatus struct {
value *ChildOperationStatus
isSet bool
}
func (v NullableChildOperationStatus) Get() *ChildOperationStatus {
return v.value
}
func (v *NullableChildOperationStatus) Set(val *ChildOperationStatus) {
v.value = val
v.isSet = true
}
func (v NullableChildOperationStatus) IsSet() bool {
return v.isSet
}
func (v *NullableChildOperationStatus) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableChildOperationStatus(val *ChildOperationStatus) *NullableChildOperationStatus {
return &NullableChildOperationStatus{value: val, isSet: true}
}
func (v NullableChildOperationStatus) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableChildOperationStatus) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
-255
View File
@@ -1,255 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the ChunkData type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ChunkData{}
// ChunkData Chunk data for a single chunk.
type ChunkData struct {
Id string `json:"id"`
Text string `json:"text"`
ChunkIndex int32 `json:"chunk_index"`
// Whether the chunk text was truncated due to token limits
Truncated *bool `json:"truncated,omitempty"`
}
type _ChunkData ChunkData
// NewChunkData instantiates a new ChunkData object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewChunkData(id string, text string, chunkIndex int32) *ChunkData {
this := ChunkData{}
this.Id = id
this.Text = text
this.ChunkIndex = chunkIndex
var truncated bool = false
this.Truncated = &truncated
return &this
}
// NewChunkDataWithDefaults instantiates a new ChunkData object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewChunkDataWithDefaults() *ChunkData {
this := ChunkData{}
var truncated bool = false
this.Truncated = &truncated
return &this
}
// GetId returns the Id field value
func (o *ChunkData) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *ChunkData) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *ChunkData) SetId(v string) {
o.Id = v
}
// GetText returns the Text field value
func (o *ChunkData) GetText() string {
if o == nil {
var ret string
return ret
}
return o.Text
}
// GetTextOk returns a tuple with the Text field value
// and a boolean to check if the value has been set.
func (o *ChunkData) GetTextOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Text, true
}
// SetText sets field value
func (o *ChunkData) SetText(v string) {
o.Text = v
}
// GetChunkIndex returns the ChunkIndex field value
func (o *ChunkData) GetChunkIndex() int32 {
if o == nil {
var ret int32
return ret
}
return o.ChunkIndex
}
// GetChunkIndexOk returns a tuple with the ChunkIndex field value
// and a boolean to check if the value has been set.
func (o *ChunkData) GetChunkIndexOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.ChunkIndex, true
}
// SetChunkIndex sets field value
func (o *ChunkData) SetChunkIndex(v int32) {
o.ChunkIndex = v
}
// GetTruncated returns the Truncated field value if set, zero value otherwise.
func (o *ChunkData) GetTruncated() bool {
if o == nil || IsNil(o.Truncated) {
var ret bool
return ret
}
return *o.Truncated
}
// GetTruncatedOk returns a tuple with the Truncated field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ChunkData) GetTruncatedOk() (*bool, bool) {
if o == nil || IsNil(o.Truncated) {
return nil, false
}
return o.Truncated, true
}
// HasTruncated returns a boolean if a field has been set.
func (o *ChunkData) HasTruncated() bool {
if o != nil && !IsNil(o.Truncated) {
return true
}
return false
}
// SetTruncated gets a reference to the given bool and assigns it to the Truncated field.
func (o *ChunkData) SetTruncated(v bool) {
o.Truncated = &v
}
func (o ChunkData) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ChunkData) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["text"] = o.Text
toSerialize["chunk_index"] = o.ChunkIndex
if !IsNil(o.Truncated) {
toSerialize["truncated"] = o.Truncated
}
return toSerialize, nil
}
func (o *ChunkData) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"text",
"chunk_index",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varChunkData := _ChunkData{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varChunkData)
if err != nil {
return err
}
*o = ChunkData(varChunkData)
return err
}
type NullableChunkData struct {
value *ChunkData
isSet bool
}
func (v NullableChunkData) Get() *ChunkData {
return v.value
}
func (v *NullableChunkData) Set(val *ChunkData) {
v.value = val
v.isSet = true
}
func (v NullableChunkData) IsSet() bool {
return v.isSet
}
func (v *NullableChunkData) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableChunkData(val *ChunkData) *NullableChunkData {
return &NullableChunkData{value: val, isSet: true}
}
func (v NullableChunkData) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableChunkData) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,131 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
)
// checks if the ChunkIncludeOptions type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ChunkIncludeOptions{}
// ChunkIncludeOptions Options for including chunks in recall results.
type ChunkIncludeOptions struct {
// Maximum tokens for chunks (chunks may be truncated)
MaxTokens *int32 `json:"max_tokens,omitempty"`
}
// NewChunkIncludeOptions instantiates a new ChunkIncludeOptions object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewChunkIncludeOptions() *ChunkIncludeOptions {
this := ChunkIncludeOptions{}
var maxTokens int32 = 8192
this.MaxTokens = &maxTokens
return &this
}
// NewChunkIncludeOptionsWithDefaults instantiates a new ChunkIncludeOptions object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewChunkIncludeOptionsWithDefaults() *ChunkIncludeOptions {
this := ChunkIncludeOptions{}
var maxTokens int32 = 8192
this.MaxTokens = &maxTokens
return &this
}
// GetMaxTokens returns the MaxTokens field value if set, zero value otherwise.
func (o *ChunkIncludeOptions) GetMaxTokens() int32 {
if o == nil || IsNil(o.MaxTokens) {
var ret int32
return ret
}
return *o.MaxTokens
}
// GetMaxTokensOk returns a tuple with the MaxTokens field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ChunkIncludeOptions) GetMaxTokensOk() (*int32, bool) {
if o == nil || IsNil(o.MaxTokens) {
return nil, false
}
return o.MaxTokens, true
}
// HasMaxTokens returns a boolean if a field has been set.
func (o *ChunkIncludeOptions) HasMaxTokens() bool {
if o != nil && !IsNil(o.MaxTokens) {
return true
}
return false
}
// SetMaxTokens gets a reference to the given int32 and assigns it to the MaxTokens field.
func (o *ChunkIncludeOptions) SetMaxTokens(v int32) {
o.MaxTokens = &v
}
func (o ChunkIncludeOptions) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ChunkIncludeOptions) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.MaxTokens) {
toSerialize["max_tokens"] = o.MaxTokens
}
return toSerialize, nil
}
type NullableChunkIncludeOptions struct {
value *ChunkIncludeOptions
isSet bool
}
func (v NullableChunkIncludeOptions) Get() *ChunkIncludeOptions {
return v.value
}
func (v *NullableChunkIncludeOptions) Set(val *ChunkIncludeOptions) {
v.value = val
v.isSet = true
}
func (v NullableChunkIncludeOptions) IsSet() bool {
return v.isSet
}
func (v *NullableChunkIncludeOptions) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableChunkIncludeOptions(val *ChunkIncludeOptions) *NullableChunkIncludeOptions {
return &NullableChunkIncludeOptions{value: val, isSet: true}
}
func (v NullableChunkIncludeOptions) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableChunkIncludeOptions) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,298 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the ChunkResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ChunkResponse{}
// ChunkResponse Response model for get chunk endpoint.
type ChunkResponse struct {
ChunkId string `json:"chunk_id"`
DocumentId string `json:"document_id"`
BankId string `json:"bank_id"`
ChunkIndex int32 `json:"chunk_index"`
ChunkText string `json:"chunk_text"`
CreatedAt string `json:"created_at"`
}
type _ChunkResponse ChunkResponse
// NewChunkResponse instantiates a new ChunkResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewChunkResponse(chunkId string, documentId string, bankId string, chunkIndex int32, chunkText string, createdAt string) *ChunkResponse {
this := ChunkResponse{}
this.ChunkId = chunkId
this.DocumentId = documentId
this.BankId = bankId
this.ChunkIndex = chunkIndex
this.ChunkText = chunkText
this.CreatedAt = createdAt
return &this
}
// NewChunkResponseWithDefaults instantiates a new ChunkResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewChunkResponseWithDefaults() *ChunkResponse {
this := ChunkResponse{}
return &this
}
// GetChunkId returns the ChunkId field value
func (o *ChunkResponse) GetChunkId() string {
if o == nil {
var ret string
return ret
}
return o.ChunkId
}
// GetChunkIdOk returns a tuple with the ChunkId field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetChunkIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.ChunkId, true
}
// SetChunkId sets field value
func (o *ChunkResponse) SetChunkId(v string) {
o.ChunkId = v
}
// GetDocumentId returns the DocumentId field value
func (o *ChunkResponse) GetDocumentId() string {
if o == nil {
var ret string
return ret
}
return o.DocumentId
}
// GetDocumentIdOk returns a tuple with the DocumentId field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetDocumentIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.DocumentId, true
}
// SetDocumentId sets field value
func (o *ChunkResponse) SetDocumentId(v string) {
o.DocumentId = v
}
// GetBankId returns the BankId field value
func (o *ChunkResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *ChunkResponse) SetBankId(v string) {
o.BankId = v
}
// GetChunkIndex returns the ChunkIndex field value
func (o *ChunkResponse) GetChunkIndex() int32 {
if o == nil {
var ret int32
return ret
}
return o.ChunkIndex
}
// GetChunkIndexOk returns a tuple with the ChunkIndex field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetChunkIndexOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.ChunkIndex, true
}
// SetChunkIndex sets field value
func (o *ChunkResponse) SetChunkIndex(v int32) {
o.ChunkIndex = v
}
// GetChunkText returns the ChunkText field value
func (o *ChunkResponse) GetChunkText() string {
if o == nil {
var ret string
return ret
}
return o.ChunkText
}
// GetChunkTextOk returns a tuple with the ChunkText field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetChunkTextOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.ChunkText, true
}
// SetChunkText sets field value
func (o *ChunkResponse) SetChunkText(v string) {
o.ChunkText = v
}
// GetCreatedAt returns the CreatedAt field value
func (o *ChunkResponse) GetCreatedAt() string {
if o == nil {
var ret string
return ret
}
return o.CreatedAt
}
// GetCreatedAtOk returns a tuple with the CreatedAt field value
// and a boolean to check if the value has been set.
func (o *ChunkResponse) GetCreatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CreatedAt, true
}
// SetCreatedAt sets field value
func (o *ChunkResponse) SetCreatedAt(v string) {
o.CreatedAt = v
}
func (o ChunkResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ChunkResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["chunk_id"] = o.ChunkId
toSerialize["document_id"] = o.DocumentId
toSerialize["bank_id"] = o.BankId
toSerialize["chunk_index"] = o.ChunkIndex
toSerialize["chunk_text"] = o.ChunkText
toSerialize["created_at"] = o.CreatedAt
return toSerialize, nil
}
func (o *ChunkResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"chunk_id",
"document_id",
"bank_id",
"chunk_index",
"chunk_text",
"created_at",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varChunkResponse := _ChunkResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varChunkResponse)
if err != nil {
return err
}
*o = ChunkResponse(varChunkResponse)
return err
}
type NullableChunkResponse struct {
value *ChunkResponse
isSet bool
}
func (v NullableChunkResponse) Get() *ChunkResponse {
return v.value
}
func (v *NullableChunkResponse) Set(val *ChunkResponse) {
v.value = val
v.isSet = true
}
func (v NullableChunkResponse) IsSet() bool {
return v.isSet
}
func (v *NullableChunkResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableChunkResponse(val *ChunkResponse) *NullableChunkResponse {
return &NullableChunkResponse{value: val, isSet: true}
}
func (v NullableChunkResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableChunkResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,200 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the ConsolidationResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ConsolidationResponse{}
// ConsolidationResponse Response model for consolidation trigger endpoint.
type ConsolidationResponse struct {
// ID of the async consolidation operation
OperationId string `json:"operation_id"`
// True if an existing pending task was reused
Deduplicated *bool `json:"deduplicated,omitempty"`
}
type _ConsolidationResponse ConsolidationResponse
// NewConsolidationResponse instantiates a new ConsolidationResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewConsolidationResponse(operationId string) *ConsolidationResponse {
this := ConsolidationResponse{}
this.OperationId = operationId
var deduplicated bool = false
this.Deduplicated = &deduplicated
return &this
}
// NewConsolidationResponseWithDefaults instantiates a new ConsolidationResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewConsolidationResponseWithDefaults() *ConsolidationResponse {
this := ConsolidationResponse{}
var deduplicated bool = false
this.Deduplicated = &deduplicated
return &this
}
// GetOperationId returns the OperationId field value
func (o *ConsolidationResponse) GetOperationId() string {
if o == nil {
var ret string
return ret
}
return o.OperationId
}
// GetOperationIdOk returns a tuple with the OperationId field value
// and a boolean to check if the value has been set.
func (o *ConsolidationResponse) GetOperationIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OperationId, true
}
// SetOperationId sets field value
func (o *ConsolidationResponse) SetOperationId(v string) {
o.OperationId = v
}
// GetDeduplicated returns the Deduplicated field value if set, zero value otherwise.
func (o *ConsolidationResponse) GetDeduplicated() bool {
if o == nil || IsNil(o.Deduplicated) {
var ret bool
return ret
}
return *o.Deduplicated
}
// GetDeduplicatedOk returns a tuple with the Deduplicated field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ConsolidationResponse) GetDeduplicatedOk() (*bool, bool) {
if o == nil || IsNil(o.Deduplicated) {
return nil, false
}
return o.Deduplicated, true
}
// HasDeduplicated returns a boolean if a field has been set.
func (o *ConsolidationResponse) HasDeduplicated() bool {
if o != nil && !IsNil(o.Deduplicated) {
return true
}
return false
}
// SetDeduplicated gets a reference to the given bool and assigns it to the Deduplicated field.
func (o *ConsolidationResponse) SetDeduplicated(v bool) {
o.Deduplicated = &v
}
func (o ConsolidationResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ConsolidationResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["operation_id"] = o.OperationId
if !IsNil(o.Deduplicated) {
toSerialize["deduplicated"] = o.Deduplicated
}
return toSerialize, nil
}
func (o *ConsolidationResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"operation_id",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varConsolidationResponse := _ConsolidationResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varConsolidationResponse)
if err != nil {
return err
}
*o = ConsolidationResponse(varConsolidationResponse)
return err
}
type NullableConsolidationResponse struct {
value *ConsolidationResponse
isSet bool
}
func (v NullableConsolidationResponse) Get() *ConsolidationResponse {
return v.value
}
func (v *NullableConsolidationResponse) Set(val *ConsolidationResponse) {
v.value = val
v.isSet = true
}
func (v NullableConsolidationResponse) IsSet() bool {
return v.isSet
}
func (v *NullableConsolidationResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableConsolidationResponse(val *ConsolidationResponse) *NullableConsolidationResponse {
return &NullableConsolidationResponse{value: val, isSet: true}
}
func (v NullableConsolidationResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableConsolidationResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,274 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
)
// checks if the CreateBankRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateBankRequest{}
// CreateBankRequest Request model for creating/updating a bank.
type CreateBankRequest struct {
Name NullableString `json:"name,omitempty"`
Disposition NullableDispositionTraits `json:"disposition,omitempty"`
Mission NullableString `json:"mission,omitempty"`
Background NullableString `json:"background,omitempty"`
}
// NewCreateBankRequest instantiates a new CreateBankRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreateBankRequest() *CreateBankRequest {
this := CreateBankRequest{}
return &this
}
// NewCreateBankRequestWithDefaults instantiates a new CreateBankRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreateBankRequestWithDefaults() *CreateBankRequest {
this := CreateBankRequest{}
return &this
}
// GetName returns the Name field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateBankRequest) GetName() string {
if o == nil || IsNil(o.Name.Get()) {
var ret string
return ret
}
return *o.Name.Get()
}
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateBankRequest) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Name.Get(), o.Name.IsSet()
}
// HasName returns a boolean if a field has been set.
func (o *CreateBankRequest) HasName() bool {
if o != nil && o.Name.IsSet() {
return true
}
return false
}
// SetName gets a reference to the given NullableString and assigns it to the Name field.
func (o *CreateBankRequest) SetName(v string) {
o.Name.Set(&v)
}
// SetNameNil sets the value for Name to be an explicit nil
func (o *CreateBankRequest) SetNameNil() {
o.Name.Set(nil)
}
// UnsetName ensures that no value is present for Name, not even an explicit nil
func (o *CreateBankRequest) UnsetName() {
o.Name.Unset()
}
// GetDisposition returns the Disposition field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateBankRequest) GetDisposition() DispositionTraits {
if o == nil || IsNil(o.Disposition.Get()) {
var ret DispositionTraits
return ret
}
return *o.Disposition.Get()
}
// GetDispositionOk returns a tuple with the Disposition field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateBankRequest) GetDispositionOk() (*DispositionTraits, bool) {
if o == nil {
return nil, false
}
return o.Disposition.Get(), o.Disposition.IsSet()
}
// HasDisposition returns a boolean if a field has been set.
func (o *CreateBankRequest) HasDisposition() bool {
if o != nil && o.Disposition.IsSet() {
return true
}
return false
}
// SetDisposition gets a reference to the given NullableDispositionTraits and assigns it to the Disposition field.
func (o *CreateBankRequest) SetDisposition(v DispositionTraits) {
o.Disposition.Set(&v)
}
// SetDispositionNil sets the value for Disposition to be an explicit nil
func (o *CreateBankRequest) SetDispositionNil() {
o.Disposition.Set(nil)
}
// UnsetDisposition ensures that no value is present for Disposition, not even an explicit nil
func (o *CreateBankRequest) UnsetDisposition() {
o.Disposition.Unset()
}
// GetMission returns the Mission field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateBankRequest) GetMission() string {
if o == nil || IsNil(o.Mission.Get()) {
var ret string
return ret
}
return *o.Mission.Get()
}
// GetMissionOk returns a tuple with the Mission field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateBankRequest) GetMissionOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Mission.Get(), o.Mission.IsSet()
}
// HasMission returns a boolean if a field has been set.
func (o *CreateBankRequest) HasMission() bool {
if o != nil && o.Mission.IsSet() {
return true
}
return false
}
// SetMission gets a reference to the given NullableString and assigns it to the Mission field.
func (o *CreateBankRequest) SetMission(v string) {
o.Mission.Set(&v)
}
// SetMissionNil sets the value for Mission to be an explicit nil
func (o *CreateBankRequest) SetMissionNil() {
o.Mission.Set(nil)
}
// UnsetMission ensures that no value is present for Mission, not even an explicit nil
func (o *CreateBankRequest) UnsetMission() {
o.Mission.Unset()
}
// GetBackground returns the Background field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateBankRequest) GetBackground() string {
if o == nil || IsNil(o.Background.Get()) {
var ret string
return ret
}
return *o.Background.Get()
}
// GetBackgroundOk returns a tuple with the Background field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateBankRequest) GetBackgroundOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Background.Get(), o.Background.IsSet()
}
// HasBackground returns a boolean if a field has been set.
func (o *CreateBankRequest) HasBackground() bool {
if o != nil && o.Background.IsSet() {
return true
}
return false
}
// SetBackground gets a reference to the given NullableString and assigns it to the Background field.
func (o *CreateBankRequest) SetBackground(v string) {
o.Background.Set(&v)
}
// SetBackgroundNil sets the value for Background to be an explicit nil
func (o *CreateBankRequest) SetBackgroundNil() {
o.Background.Set(nil)
}
// UnsetBackground ensures that no value is present for Background, not even an explicit nil
func (o *CreateBankRequest) UnsetBackground() {
o.Background.Unset()
}
func (o CreateBankRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreateBankRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.Name.IsSet() {
toSerialize["name"] = o.Name.Get()
}
if o.Disposition.IsSet() {
toSerialize["disposition"] = o.Disposition.Get()
}
if o.Mission.IsSet() {
toSerialize["mission"] = o.Mission.Get()
}
if o.Background.IsSet() {
toSerialize["background"] = o.Background.Get()
}
return toSerialize, nil
}
type NullableCreateBankRequest struct {
value *CreateBankRequest
isSet bool
}
func (v NullableCreateBankRequest) Get() *CreateBankRequest {
return v.value
}
func (v *NullableCreateBankRequest) Set(val *CreateBankRequest) {
v.value = val
v.isSet = true
}
func (v NullableCreateBankRequest) IsSet() bool {
return v.isSet
}
func (v *NullableCreateBankRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreateBankRequest(val *CreateBankRequest) *NullableCreateBankRequest {
return &NullableCreateBankRequest{value: val, isSet: true}
}
func (v NullableCreateBankRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreateBankRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,307 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the CreateDirectiveRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateDirectiveRequest{}
// CreateDirectiveRequest Request model for creating a directive.
type CreateDirectiveRequest struct {
// Human-readable name for the directive
Name string `json:"name"`
// The directive text to inject into prompts
Content string `json:"content"`
// Higher priority directives are injected first
Priority *int32 `json:"priority,omitempty"`
// Whether this directive is active
IsActive *bool `json:"is_active,omitempty"`
// Tags for filtering
Tags []string `json:"tags,omitempty"`
}
type _CreateDirectiveRequest CreateDirectiveRequest
// NewCreateDirectiveRequest instantiates a new CreateDirectiveRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreateDirectiveRequest(name string, content string) *CreateDirectiveRequest {
this := CreateDirectiveRequest{}
this.Name = name
this.Content = content
var priority int32 = 0
this.Priority = &priority
var isActive bool = true
this.IsActive = &isActive
return &this
}
// NewCreateDirectiveRequestWithDefaults instantiates a new CreateDirectiveRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreateDirectiveRequestWithDefaults() *CreateDirectiveRequest {
this := CreateDirectiveRequest{}
var priority int32 = 0
this.Priority = &priority
var isActive bool = true
this.IsActive = &isActive
return &this
}
// GetName returns the Name field value
func (o *CreateDirectiveRequest) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *CreateDirectiveRequest) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *CreateDirectiveRequest) SetName(v string) {
o.Name = v
}
// GetContent returns the Content field value
func (o *CreateDirectiveRequest) GetContent() string {
if o == nil {
var ret string
return ret
}
return o.Content
}
// GetContentOk returns a tuple with the Content field value
// and a boolean to check if the value has been set.
func (o *CreateDirectiveRequest) GetContentOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Content, true
}
// SetContent sets field value
func (o *CreateDirectiveRequest) SetContent(v string) {
o.Content = v
}
// GetPriority returns the Priority field value if set, zero value otherwise.
func (o *CreateDirectiveRequest) GetPriority() int32 {
if o == nil || IsNil(o.Priority) {
var ret int32
return ret
}
return *o.Priority
}
// GetPriorityOk returns a tuple with the Priority field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateDirectiveRequest) GetPriorityOk() (*int32, bool) {
if o == nil || IsNil(o.Priority) {
return nil, false
}
return o.Priority, true
}
// HasPriority returns a boolean if a field has been set.
func (o *CreateDirectiveRequest) HasPriority() bool {
if o != nil && !IsNil(o.Priority) {
return true
}
return false
}
// SetPriority gets a reference to the given int32 and assigns it to the Priority field.
func (o *CreateDirectiveRequest) SetPriority(v int32) {
o.Priority = &v
}
// GetIsActive returns the IsActive field value if set, zero value otherwise.
func (o *CreateDirectiveRequest) GetIsActive() bool {
if o == nil || IsNil(o.IsActive) {
var ret bool
return ret
}
return *o.IsActive
}
// GetIsActiveOk returns a tuple with the IsActive field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateDirectiveRequest) GetIsActiveOk() (*bool, bool) {
if o == nil || IsNil(o.IsActive) {
return nil, false
}
return o.IsActive, true
}
// HasIsActive returns a boolean if a field has been set.
func (o *CreateDirectiveRequest) HasIsActive() bool {
if o != nil && !IsNil(o.IsActive) {
return true
}
return false
}
// SetIsActive gets a reference to the given bool and assigns it to the IsActive field.
func (o *CreateDirectiveRequest) SetIsActive(v bool) {
o.IsActive = &v
}
// GetTags returns the Tags field value if set, zero value otherwise.
func (o *CreateDirectiveRequest) GetTags() []string {
if o == nil || IsNil(o.Tags) {
var ret []string
return ret
}
return o.Tags
}
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateDirectiveRequest) GetTagsOk() ([]string, bool) {
if o == nil || IsNil(o.Tags) {
return nil, false
}
return o.Tags, true
}
// HasTags returns a boolean if a field has been set.
func (o *CreateDirectiveRequest) HasTags() bool {
if o != nil && !IsNil(o.Tags) {
return true
}
return false
}
// SetTags gets a reference to the given []string and assigns it to the Tags field.
func (o *CreateDirectiveRequest) SetTags(v []string) {
o.Tags = v
}
func (o CreateDirectiveRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreateDirectiveRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["name"] = o.Name
toSerialize["content"] = o.Content
if !IsNil(o.Priority) {
toSerialize["priority"] = o.Priority
}
if !IsNil(o.IsActive) {
toSerialize["is_active"] = o.IsActive
}
if !IsNil(o.Tags) {
toSerialize["tags"] = o.Tags
}
return toSerialize, nil
}
func (o *CreateDirectiveRequest) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"name",
"content",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varCreateDirectiveRequest := _CreateDirectiveRequest{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCreateDirectiveRequest)
if err != nil {
return err
}
*o = CreateDirectiveRequest(varCreateDirectiveRequest)
return err
}
type NullableCreateDirectiveRequest struct {
value *CreateDirectiveRequest
isSet bool
}
func (v NullableCreateDirectiveRequest) Get() *CreateDirectiveRequest {
return v.value
}
func (v *NullableCreateDirectiveRequest) Set(val *CreateDirectiveRequest) {
v.value = val
v.isSet = true
}
func (v NullableCreateDirectiveRequest) IsSet() bool {
return v.isSet
}
func (v *NullableCreateDirectiveRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreateDirectiveRequest(val *CreateDirectiveRequest) *NullableCreateDirectiveRequest {
return &NullableCreateDirectiveRequest{value: val, isSet: true}
}
func (v NullableCreateDirectiveRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreateDirectiveRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,349 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the CreateMentalModelRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateMentalModelRequest{}
// CreateMentalModelRequest Request model for creating a mental model.
type CreateMentalModelRequest struct {
Id NullableString `json:"id,omitempty"`
// Human-readable name for the mental model
Name string `json:"name"`
// The query to run to generate content
SourceQuery string `json:"source_query"`
// Tags for scoped visibility
Tags []string `json:"tags,omitempty"`
// Maximum tokens for generated content
MaxTokens *int32 `json:"max_tokens,omitempty"`
// Trigger settings
Trigger *MentalModelTrigger `json:"trigger,omitempty"`
}
type _CreateMentalModelRequest CreateMentalModelRequest
// NewCreateMentalModelRequest instantiates a new CreateMentalModelRequest object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreateMentalModelRequest(name string, sourceQuery string) *CreateMentalModelRequest {
this := CreateMentalModelRequest{}
this.Name = name
this.SourceQuery = sourceQuery
var maxTokens int32 = 2048
this.MaxTokens = &maxTokens
return &this
}
// NewCreateMentalModelRequestWithDefaults instantiates a new CreateMentalModelRequest object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreateMentalModelRequestWithDefaults() *CreateMentalModelRequest {
this := CreateMentalModelRequest{}
var maxTokens int32 = 2048
this.MaxTokens = &maxTokens
return &this
}
// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateMentalModelRequest) GetId() string {
if o == nil || IsNil(o.Id.Get()) {
var ret string
return ret
}
return *o.Id.Get()
}
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateMentalModelRequest) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Id.Get(), o.Id.IsSet()
}
// HasId returns a boolean if a field has been set.
func (o *CreateMentalModelRequest) HasId() bool {
if o != nil && o.Id.IsSet() {
return true
}
return false
}
// SetId gets a reference to the given NullableString and assigns it to the Id field.
func (o *CreateMentalModelRequest) SetId(v string) {
o.Id.Set(&v)
}
// SetIdNil sets the value for Id to be an explicit nil
func (o *CreateMentalModelRequest) SetIdNil() {
o.Id.Set(nil)
}
// UnsetId ensures that no value is present for Id, not even an explicit nil
func (o *CreateMentalModelRequest) UnsetId() {
o.Id.Unset()
}
// GetName returns the Name field value
func (o *CreateMentalModelRequest) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *CreateMentalModelRequest) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *CreateMentalModelRequest) SetName(v string) {
o.Name = v
}
// GetSourceQuery returns the SourceQuery field value
func (o *CreateMentalModelRequest) GetSourceQuery() string {
if o == nil {
var ret string
return ret
}
return o.SourceQuery
}
// GetSourceQueryOk returns a tuple with the SourceQuery field value
// and a boolean to check if the value has been set.
func (o *CreateMentalModelRequest) GetSourceQueryOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.SourceQuery, true
}
// SetSourceQuery sets field value
func (o *CreateMentalModelRequest) SetSourceQuery(v string) {
o.SourceQuery = v
}
// GetTags returns the Tags field value if set, zero value otherwise.
func (o *CreateMentalModelRequest) GetTags() []string {
if o == nil || IsNil(o.Tags) {
var ret []string
return ret
}
return o.Tags
}
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateMentalModelRequest) GetTagsOk() ([]string, bool) {
if o == nil || IsNil(o.Tags) {
return nil, false
}
return o.Tags, true
}
// HasTags returns a boolean if a field has been set.
func (o *CreateMentalModelRequest) HasTags() bool {
if o != nil && !IsNil(o.Tags) {
return true
}
return false
}
// SetTags gets a reference to the given []string and assigns it to the Tags field.
func (o *CreateMentalModelRequest) SetTags(v []string) {
o.Tags = v
}
// GetMaxTokens returns the MaxTokens field value if set, zero value otherwise.
func (o *CreateMentalModelRequest) GetMaxTokens() int32 {
if o == nil || IsNil(o.MaxTokens) {
var ret int32
return ret
}
return *o.MaxTokens
}
// GetMaxTokensOk returns a tuple with the MaxTokens field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateMentalModelRequest) GetMaxTokensOk() (*int32, bool) {
if o == nil || IsNil(o.MaxTokens) {
return nil, false
}
return o.MaxTokens, true
}
// HasMaxTokens returns a boolean if a field has been set.
func (o *CreateMentalModelRequest) HasMaxTokens() bool {
if o != nil && !IsNil(o.MaxTokens) {
return true
}
return false
}
// SetMaxTokens gets a reference to the given int32 and assigns it to the MaxTokens field.
func (o *CreateMentalModelRequest) SetMaxTokens(v int32) {
o.MaxTokens = &v
}
// GetTrigger returns the Trigger field value if set, zero value otherwise.
func (o *CreateMentalModelRequest) GetTrigger() MentalModelTrigger {
if o == nil || IsNil(o.Trigger) {
var ret MentalModelTrigger
return ret
}
return *o.Trigger
}
// GetTriggerOk returns a tuple with the Trigger field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateMentalModelRequest) GetTriggerOk() (*MentalModelTrigger, bool) {
if o == nil || IsNil(o.Trigger) {
return nil, false
}
return o.Trigger, true
}
// HasTrigger returns a boolean if a field has been set.
func (o *CreateMentalModelRequest) HasTrigger() bool {
if o != nil && !IsNil(o.Trigger) {
return true
}
return false
}
// SetTrigger gets a reference to the given MentalModelTrigger and assigns it to the Trigger field.
func (o *CreateMentalModelRequest) SetTrigger(v MentalModelTrigger) {
o.Trigger = &v
}
func (o CreateMentalModelRequest) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreateMentalModelRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.Id.IsSet() {
toSerialize["id"] = o.Id.Get()
}
toSerialize["name"] = o.Name
toSerialize["source_query"] = o.SourceQuery
if !IsNil(o.Tags) {
toSerialize["tags"] = o.Tags
}
if !IsNil(o.MaxTokens) {
toSerialize["max_tokens"] = o.MaxTokens
}
if !IsNil(o.Trigger) {
toSerialize["trigger"] = o.Trigger
}
return toSerialize, nil
}
func (o *CreateMentalModelRequest) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"name",
"source_query",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varCreateMentalModelRequest := _CreateMentalModelRequest{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCreateMentalModelRequest)
if err != nil {
return err
}
*o = CreateMentalModelRequest(varCreateMentalModelRequest)
return err
}
type NullableCreateMentalModelRequest struct {
value *CreateMentalModelRequest
isSet bool
}
func (v NullableCreateMentalModelRequest) Get() *CreateMentalModelRequest {
return v.value
}
func (v *NullableCreateMentalModelRequest) Set(val *CreateMentalModelRequest) {
v.value = val
v.isSet = true
}
func (v NullableCreateMentalModelRequest) IsSet() bool {
return v.isSet
}
func (v *NullableCreateMentalModelRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreateMentalModelRequest(val *CreateMentalModelRequest) *NullableCreateMentalModelRequest {
return &NullableCreateMentalModelRequest{value: val, isSet: true}
}
func (v NullableCreateMentalModelRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreateMentalModelRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,205 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the CreateMentalModelResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateMentalModelResponse{}
// CreateMentalModelResponse Response model for mental model creation.
type CreateMentalModelResponse struct {
MentalModelId NullableString `json:"mental_model_id,omitempty"`
// Operation ID to track refresh progress
OperationId string `json:"operation_id"`
}
type _CreateMentalModelResponse CreateMentalModelResponse
// NewCreateMentalModelResponse instantiates a new CreateMentalModelResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreateMentalModelResponse(operationId string) *CreateMentalModelResponse {
this := CreateMentalModelResponse{}
this.OperationId = operationId
return &this
}
// NewCreateMentalModelResponseWithDefaults instantiates a new CreateMentalModelResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreateMentalModelResponseWithDefaults() *CreateMentalModelResponse {
this := CreateMentalModelResponse{}
return &this
}
// GetMentalModelId returns the MentalModelId field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *CreateMentalModelResponse) GetMentalModelId() string {
if o == nil || IsNil(o.MentalModelId.Get()) {
var ret string
return ret
}
return *o.MentalModelId.Get()
}
// GetMentalModelIdOk returns a tuple with the MentalModelId field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *CreateMentalModelResponse) GetMentalModelIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.MentalModelId.Get(), o.MentalModelId.IsSet()
}
// HasMentalModelId returns a boolean if a field has been set.
func (o *CreateMentalModelResponse) HasMentalModelId() bool {
if o != nil && o.MentalModelId.IsSet() {
return true
}
return false
}
// SetMentalModelId gets a reference to the given NullableString and assigns it to the MentalModelId field.
func (o *CreateMentalModelResponse) SetMentalModelId(v string) {
o.MentalModelId.Set(&v)
}
// SetMentalModelIdNil sets the value for MentalModelId to be an explicit nil
func (o *CreateMentalModelResponse) SetMentalModelIdNil() {
o.MentalModelId.Set(nil)
}
// UnsetMentalModelId ensures that no value is present for MentalModelId, not even an explicit nil
func (o *CreateMentalModelResponse) UnsetMentalModelId() {
o.MentalModelId.Unset()
}
// GetOperationId returns the OperationId field value
func (o *CreateMentalModelResponse) GetOperationId() string {
if o == nil {
var ret string
return ret
}
return o.OperationId
}
// GetOperationIdOk returns a tuple with the OperationId field value
// and a boolean to check if the value has been set.
func (o *CreateMentalModelResponse) GetOperationIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OperationId, true
}
// SetOperationId sets field value
func (o *CreateMentalModelResponse) SetOperationId(v string) {
o.OperationId = v
}
func (o CreateMentalModelResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreateMentalModelResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.MentalModelId.IsSet() {
toSerialize["mental_model_id"] = o.MentalModelId.Get()
}
toSerialize["operation_id"] = o.OperationId
return toSerialize, nil
}
func (o *CreateMentalModelResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"operation_id",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varCreateMentalModelResponse := _CreateMentalModelResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCreateMentalModelResponse)
if err != nil {
return err
}
*o = CreateMentalModelResponse(varCreateMentalModelResponse)
return err
}
type NullableCreateMentalModelResponse struct {
value *CreateMentalModelResponse
isSet bool
}
func (v NullableCreateMentalModelResponse) Get() *CreateMentalModelResponse {
return v.value
}
func (v *NullableCreateMentalModelResponse) Set(val *CreateMentalModelResponse) {
v.value = val
v.isSet = true
}
func (v NullableCreateMentalModelResponse) IsSet() bool {
return v.isSet
}
func (v *NullableCreateMentalModelResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreateMentalModelResponse(val *CreateMentalModelResponse) *NullableCreateMentalModelResponse {
return &NullableCreateMentalModelResponse{value: val, isSet: true}
}
func (v NullableCreateMentalModelResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreateMentalModelResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,242 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DeleteDocumentResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DeleteDocumentResponse{}
// DeleteDocumentResponse Response model for delete document endpoint.
type DeleteDocumentResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
DocumentId string `json:"document_id"`
MemoryUnitsDeleted int32 `json:"memory_units_deleted"`
}
type _DeleteDocumentResponse DeleteDocumentResponse
// NewDeleteDocumentResponse instantiates a new DeleteDocumentResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDeleteDocumentResponse(success bool, message string, documentId string, memoryUnitsDeleted int32) *DeleteDocumentResponse {
this := DeleteDocumentResponse{}
this.Success = success
this.Message = message
this.DocumentId = documentId
this.MemoryUnitsDeleted = memoryUnitsDeleted
return &this
}
// NewDeleteDocumentResponseWithDefaults instantiates a new DeleteDocumentResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDeleteDocumentResponseWithDefaults() *DeleteDocumentResponse {
this := DeleteDocumentResponse{}
return &this
}
// GetSuccess returns the Success field value
func (o *DeleteDocumentResponse) GetSuccess() bool {
if o == nil {
var ret bool
return ret
}
return o.Success
}
// GetSuccessOk returns a tuple with the Success field value
// and a boolean to check if the value has been set.
func (o *DeleteDocumentResponse) GetSuccessOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Success, true
}
// SetSuccess sets field value
func (o *DeleteDocumentResponse) SetSuccess(v bool) {
o.Success = v
}
// GetMessage returns the Message field value
func (o *DeleteDocumentResponse) GetMessage() string {
if o == nil {
var ret string
return ret
}
return o.Message
}
// GetMessageOk returns a tuple with the Message field value
// and a boolean to check if the value has been set.
func (o *DeleteDocumentResponse) GetMessageOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Message, true
}
// SetMessage sets field value
func (o *DeleteDocumentResponse) SetMessage(v string) {
o.Message = v
}
// GetDocumentId returns the DocumentId field value
func (o *DeleteDocumentResponse) GetDocumentId() string {
if o == nil {
var ret string
return ret
}
return o.DocumentId
}
// GetDocumentIdOk returns a tuple with the DocumentId field value
// and a boolean to check if the value has been set.
func (o *DeleteDocumentResponse) GetDocumentIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.DocumentId, true
}
// SetDocumentId sets field value
func (o *DeleteDocumentResponse) SetDocumentId(v string) {
o.DocumentId = v
}
// GetMemoryUnitsDeleted returns the MemoryUnitsDeleted field value
func (o *DeleteDocumentResponse) GetMemoryUnitsDeleted() int32 {
if o == nil {
var ret int32
return ret
}
return o.MemoryUnitsDeleted
}
// GetMemoryUnitsDeletedOk returns a tuple with the MemoryUnitsDeleted field value
// and a boolean to check if the value has been set.
func (o *DeleteDocumentResponse) GetMemoryUnitsDeletedOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.MemoryUnitsDeleted, true
}
// SetMemoryUnitsDeleted sets field value
func (o *DeleteDocumentResponse) SetMemoryUnitsDeleted(v int32) {
o.MemoryUnitsDeleted = v
}
func (o DeleteDocumentResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DeleteDocumentResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["success"] = o.Success
toSerialize["message"] = o.Message
toSerialize["document_id"] = o.DocumentId
toSerialize["memory_units_deleted"] = o.MemoryUnitsDeleted
return toSerialize, nil
}
func (o *DeleteDocumentResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"success",
"message",
"document_id",
"memory_units_deleted",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDeleteDocumentResponse := _DeleteDocumentResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDeleteDocumentResponse)
if err != nil {
return err
}
*o = DeleteDocumentResponse(varDeleteDocumentResponse)
return err
}
type NullableDeleteDocumentResponse struct {
value *DeleteDocumentResponse
isSet bool
}
func (v NullableDeleteDocumentResponse) Get() *DeleteDocumentResponse {
return v.value
}
func (v *NullableDeleteDocumentResponse) Set(val *DeleteDocumentResponse) {
v.value = val
v.isSet = true
}
func (v NullableDeleteDocumentResponse) IsSet() bool {
return v.isSet
}
func (v *NullableDeleteDocumentResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDeleteDocumentResponse(val *DeleteDocumentResponse) *NullableDeleteDocumentResponse {
return &NullableDeleteDocumentResponse{value: val, isSet: true}
}
func (v NullableDeleteDocumentResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDeleteDocumentResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,250 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DeleteResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DeleteResponse{}
// DeleteResponse Response model for delete operations.
type DeleteResponse struct {
Success bool `json:"success"`
Message NullableString `json:"message,omitempty"`
DeletedCount NullableInt32 `json:"deleted_count,omitempty"`
}
type _DeleteResponse DeleteResponse
// NewDeleteResponse instantiates a new DeleteResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDeleteResponse(success bool) *DeleteResponse {
this := DeleteResponse{}
this.Success = success
return &this
}
// NewDeleteResponseWithDefaults instantiates a new DeleteResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDeleteResponseWithDefaults() *DeleteResponse {
this := DeleteResponse{}
return &this
}
// GetSuccess returns the Success field value
func (o *DeleteResponse) GetSuccess() bool {
if o == nil {
var ret bool
return ret
}
return o.Success
}
// GetSuccessOk returns a tuple with the Success field value
// and a boolean to check if the value has been set.
func (o *DeleteResponse) GetSuccessOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Success, true
}
// SetSuccess sets field value
func (o *DeleteResponse) SetSuccess(v bool) {
o.Success = v
}
// GetMessage returns the Message field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *DeleteResponse) GetMessage() string {
if o == nil || IsNil(o.Message.Get()) {
var ret string
return ret
}
return *o.Message.Get()
}
// GetMessageOk returns a tuple with the Message field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *DeleteResponse) GetMessageOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Message.Get(), o.Message.IsSet()
}
// HasMessage returns a boolean if a field has been set.
func (o *DeleteResponse) HasMessage() bool {
if o != nil && o.Message.IsSet() {
return true
}
return false
}
// SetMessage gets a reference to the given NullableString and assigns it to the Message field.
func (o *DeleteResponse) SetMessage(v string) {
o.Message.Set(&v)
}
// SetMessageNil sets the value for Message to be an explicit nil
func (o *DeleteResponse) SetMessageNil() {
o.Message.Set(nil)
}
// UnsetMessage ensures that no value is present for Message, not even an explicit nil
func (o *DeleteResponse) UnsetMessage() {
o.Message.Unset()
}
// GetDeletedCount returns the DeletedCount field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *DeleteResponse) GetDeletedCount() int32 {
if o == nil || IsNil(o.DeletedCount.Get()) {
var ret int32
return ret
}
return *o.DeletedCount.Get()
}
// GetDeletedCountOk returns a tuple with the DeletedCount field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *DeleteResponse) GetDeletedCountOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.DeletedCount.Get(), o.DeletedCount.IsSet()
}
// HasDeletedCount returns a boolean if a field has been set.
func (o *DeleteResponse) HasDeletedCount() bool {
if o != nil && o.DeletedCount.IsSet() {
return true
}
return false
}
// SetDeletedCount gets a reference to the given NullableInt32 and assigns it to the DeletedCount field.
func (o *DeleteResponse) SetDeletedCount(v int32) {
o.DeletedCount.Set(&v)
}
// SetDeletedCountNil sets the value for DeletedCount to be an explicit nil
func (o *DeleteResponse) SetDeletedCountNil() {
o.DeletedCount.Set(nil)
}
// UnsetDeletedCount ensures that no value is present for DeletedCount, not even an explicit nil
func (o *DeleteResponse) UnsetDeletedCount() {
o.DeletedCount.Unset()
}
func (o DeleteResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DeleteResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["success"] = o.Success
if o.Message.IsSet() {
toSerialize["message"] = o.Message.Get()
}
if o.DeletedCount.IsSet() {
toSerialize["deleted_count"] = o.DeletedCount.Get()
}
return toSerialize, nil
}
func (o *DeleteResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"success",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDeleteResponse := _DeleteResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDeleteResponse)
if err != nil {
return err
}
*o = DeleteResponse(varDeleteResponse)
return err
}
type NullableDeleteResponse struct {
value *DeleteResponse
isSet bool
}
func (v NullableDeleteResponse) Get() *DeleteResponse {
return v.value
}
func (v *NullableDeleteResponse) Set(val *DeleteResponse) {
v.value = val
v.isSet = true
}
func (v NullableDeleteResponse) IsSet() bool {
return v.isSet
}
func (v *NullableDeleteResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDeleteResponse(val *DeleteResponse) *NullableDeleteResponse {
return &NullableDeleteResponse{value: val, isSet: true}
}
func (v NullableDeleteResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDeleteResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,158 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DirectiveListResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DirectiveListResponse{}
// DirectiveListResponse Response model for listing directives.
type DirectiveListResponse struct {
Items []DirectiveResponse `json:"items"`
}
type _DirectiveListResponse DirectiveListResponse
// NewDirectiveListResponse instantiates a new DirectiveListResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDirectiveListResponse(items []DirectiveResponse) *DirectiveListResponse {
this := DirectiveListResponse{}
this.Items = items
return &this
}
// NewDirectiveListResponseWithDefaults instantiates a new DirectiveListResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDirectiveListResponseWithDefaults() *DirectiveListResponse {
this := DirectiveListResponse{}
return &this
}
// GetItems returns the Items field value
func (o *DirectiveListResponse) GetItems() []DirectiveResponse {
if o == nil {
var ret []DirectiveResponse
return ret
}
return o.Items
}
// GetItemsOk returns a tuple with the Items field value
// and a boolean to check if the value has been set.
func (o *DirectiveListResponse) GetItemsOk() ([]DirectiveResponse, bool) {
if o == nil {
return nil, false
}
return o.Items, true
}
// SetItems sets field value
func (o *DirectiveListResponse) SetItems(v []DirectiveResponse) {
o.Items = v
}
func (o DirectiveListResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DirectiveListResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["items"] = o.Items
return toSerialize, nil
}
func (o *DirectiveListResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"items",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDirectiveListResponse := _DirectiveListResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDirectiveListResponse)
if err != nil {
return err
}
*o = DirectiveListResponse(varDirectiveListResponse)
return err
}
type NullableDirectiveListResponse struct {
value *DirectiveListResponse
isSet bool
}
func (v NullableDirectiveListResponse) Get() *DirectiveListResponse {
return v.value
}
func (v *NullableDirectiveListResponse) Set(val *DirectiveListResponse) {
v.value = val
v.isSet = true
}
func (v NullableDirectiveListResponse) IsSet() bool {
return v.isSet
}
func (v *NullableDirectiveListResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDirectiveListResponse(val *DirectiveListResponse) *NullableDirectiveListResponse {
return &NullableDirectiveListResponse{value: val, isSet: true}
}
func (v NullableDirectiveListResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDirectiveListResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,450 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DirectiveResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DirectiveResponse{}
// DirectiveResponse Response model for a directive.
type DirectiveResponse struct {
Id string `json:"id"`
BankId string `json:"bank_id"`
Name string `json:"name"`
Content string `json:"content"`
Priority *int32 `json:"priority,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt NullableString `json:"created_at,omitempty"`
UpdatedAt NullableString `json:"updated_at,omitempty"`
}
type _DirectiveResponse DirectiveResponse
// NewDirectiveResponse instantiates a new DirectiveResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDirectiveResponse(id string, bankId string, name string, content string) *DirectiveResponse {
this := DirectiveResponse{}
this.Id = id
this.BankId = bankId
this.Name = name
this.Content = content
var priority int32 = 0
this.Priority = &priority
var isActive bool = true
this.IsActive = &isActive
return &this
}
// NewDirectiveResponseWithDefaults instantiates a new DirectiveResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDirectiveResponseWithDefaults() *DirectiveResponse {
this := DirectiveResponse{}
var priority int32 = 0
this.Priority = &priority
var isActive bool = true
this.IsActive = &isActive
return &this
}
// GetId returns the Id field value
func (o *DirectiveResponse) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *DirectiveResponse) SetId(v string) {
o.Id = v
}
// GetBankId returns the BankId field value
func (o *DirectiveResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *DirectiveResponse) SetBankId(v string) {
o.BankId = v
}
// GetName returns the Name field value
func (o *DirectiveResponse) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *DirectiveResponse) SetName(v string) {
o.Name = v
}
// GetContent returns the Content field value
func (o *DirectiveResponse) GetContent() string {
if o == nil {
var ret string
return ret
}
return o.Content
}
// GetContentOk returns a tuple with the Content field value
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetContentOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Content, true
}
// SetContent sets field value
func (o *DirectiveResponse) SetContent(v string) {
o.Content = v
}
// GetPriority returns the Priority field value if set, zero value otherwise.
func (o *DirectiveResponse) GetPriority() int32 {
if o == nil || IsNil(o.Priority) {
var ret int32
return ret
}
return *o.Priority
}
// GetPriorityOk returns a tuple with the Priority field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetPriorityOk() (*int32, bool) {
if o == nil || IsNil(o.Priority) {
return nil, false
}
return o.Priority, true
}
// HasPriority returns a boolean if a field has been set.
func (o *DirectiveResponse) HasPriority() bool {
if o != nil && !IsNil(o.Priority) {
return true
}
return false
}
// SetPriority gets a reference to the given int32 and assigns it to the Priority field.
func (o *DirectiveResponse) SetPriority(v int32) {
o.Priority = &v
}
// GetIsActive returns the IsActive field value if set, zero value otherwise.
func (o *DirectiveResponse) GetIsActive() bool {
if o == nil || IsNil(o.IsActive) {
var ret bool
return ret
}
return *o.IsActive
}
// GetIsActiveOk returns a tuple with the IsActive field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetIsActiveOk() (*bool, bool) {
if o == nil || IsNil(o.IsActive) {
return nil, false
}
return o.IsActive, true
}
// HasIsActive returns a boolean if a field has been set.
func (o *DirectiveResponse) HasIsActive() bool {
if o != nil && !IsNil(o.IsActive) {
return true
}
return false
}
// SetIsActive gets a reference to the given bool and assigns it to the IsActive field.
func (o *DirectiveResponse) SetIsActive(v bool) {
o.IsActive = &v
}
// GetTags returns the Tags field value if set, zero value otherwise.
func (o *DirectiveResponse) GetTags() []string {
if o == nil || IsNil(o.Tags) {
var ret []string
return ret
}
return o.Tags
}
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DirectiveResponse) GetTagsOk() ([]string, bool) {
if o == nil || IsNil(o.Tags) {
return nil, false
}
return o.Tags, true
}
// HasTags returns a boolean if a field has been set.
func (o *DirectiveResponse) HasTags() bool {
if o != nil && !IsNil(o.Tags) {
return true
}
return false
}
// SetTags gets a reference to the given []string and assigns it to the Tags field.
func (o *DirectiveResponse) SetTags(v []string) {
o.Tags = v
}
// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *DirectiveResponse) GetCreatedAt() string {
if o == nil || IsNil(o.CreatedAt.Get()) {
var ret string
return ret
}
return *o.CreatedAt.Get()
}
// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *DirectiveResponse) GetCreatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.CreatedAt.Get(), o.CreatedAt.IsSet()
}
// HasCreatedAt returns a boolean if a field has been set.
func (o *DirectiveResponse) HasCreatedAt() bool {
if o != nil && o.CreatedAt.IsSet() {
return true
}
return false
}
// SetCreatedAt gets a reference to the given NullableString and assigns it to the CreatedAt field.
func (o *DirectiveResponse) SetCreatedAt(v string) {
o.CreatedAt.Set(&v)
}
// SetCreatedAtNil sets the value for CreatedAt to be an explicit nil
func (o *DirectiveResponse) SetCreatedAtNil() {
o.CreatedAt.Set(nil)
}
// UnsetCreatedAt ensures that no value is present for CreatedAt, not even an explicit nil
func (o *DirectiveResponse) UnsetCreatedAt() {
o.CreatedAt.Unset()
}
// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *DirectiveResponse) GetUpdatedAt() string {
if o == nil || IsNil(o.UpdatedAt.Get()) {
var ret string
return ret
}
return *o.UpdatedAt.Get()
}
// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *DirectiveResponse) GetUpdatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.UpdatedAt.Get(), o.UpdatedAt.IsSet()
}
// HasUpdatedAt returns a boolean if a field has been set.
func (o *DirectiveResponse) HasUpdatedAt() bool {
if o != nil && o.UpdatedAt.IsSet() {
return true
}
return false
}
// SetUpdatedAt gets a reference to the given NullableString and assigns it to the UpdatedAt field.
func (o *DirectiveResponse) SetUpdatedAt(v string) {
o.UpdatedAt.Set(&v)
}
// SetUpdatedAtNil sets the value for UpdatedAt to be an explicit nil
func (o *DirectiveResponse) SetUpdatedAtNil() {
o.UpdatedAt.Set(nil)
}
// UnsetUpdatedAt ensures that no value is present for UpdatedAt, not even an explicit nil
func (o *DirectiveResponse) UnsetUpdatedAt() {
o.UpdatedAt.Unset()
}
func (o DirectiveResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DirectiveResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["bank_id"] = o.BankId
toSerialize["name"] = o.Name
toSerialize["content"] = o.Content
if !IsNil(o.Priority) {
toSerialize["priority"] = o.Priority
}
if !IsNil(o.IsActive) {
toSerialize["is_active"] = o.IsActive
}
if !IsNil(o.Tags) {
toSerialize["tags"] = o.Tags
}
if o.CreatedAt.IsSet() {
toSerialize["created_at"] = o.CreatedAt.Get()
}
if o.UpdatedAt.IsSet() {
toSerialize["updated_at"] = o.UpdatedAt.Get()
}
return toSerialize, nil
}
func (o *DirectiveResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"bank_id",
"name",
"content",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDirectiveResponse := _DirectiveResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDirectiveResponse)
if err != nil {
return err
}
*o = DirectiveResponse(varDirectiveResponse)
return err
}
type NullableDirectiveResponse struct {
value *DirectiveResponse
isSet bool
}
func (v NullableDirectiveResponse) Get() *DirectiveResponse {
return v.value
}
func (v *NullableDirectiveResponse) Set(val *DirectiveResponse) {
v.value = val
v.isSet = true
}
func (v NullableDirectiveResponse) IsSet() bool {
return v.isSet
}
func (v *NullableDirectiveResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDirectiveResponse(val *DirectiveResponse) *NullableDirectiveResponse {
return &NullableDirectiveResponse{value: val, isSet: true}
}
func (v NullableDirectiveResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDirectiveResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,217 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DispositionTraits type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DispositionTraits{}
// DispositionTraits Disposition traits that influence how memories are formed and interpreted.
type DispositionTraits struct {
// How skeptical vs trusting (1=trusting, 5=skeptical)
Skepticism int32 `json:"skepticism"`
// How literally to interpret information (1=flexible, 5=literal)
Literalism int32 `json:"literalism"`
// How much to consider emotional context (1=detached, 5=empathetic)
Empathy int32 `json:"empathy"`
}
type _DispositionTraits DispositionTraits
// NewDispositionTraits instantiates a new DispositionTraits object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDispositionTraits(skepticism int32, literalism int32, empathy int32) *DispositionTraits {
this := DispositionTraits{}
this.Skepticism = skepticism
this.Literalism = literalism
this.Empathy = empathy
return &this
}
// NewDispositionTraitsWithDefaults instantiates a new DispositionTraits object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDispositionTraitsWithDefaults() *DispositionTraits {
this := DispositionTraits{}
return &this
}
// GetSkepticism returns the Skepticism field value
func (o *DispositionTraits) GetSkepticism() int32 {
if o == nil {
var ret int32
return ret
}
return o.Skepticism
}
// GetSkepticismOk returns a tuple with the Skepticism field value
// and a boolean to check if the value has been set.
func (o *DispositionTraits) GetSkepticismOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Skepticism, true
}
// SetSkepticism sets field value
func (o *DispositionTraits) SetSkepticism(v int32) {
o.Skepticism = v
}
// GetLiteralism returns the Literalism field value
func (o *DispositionTraits) GetLiteralism() int32 {
if o == nil {
var ret int32
return ret
}
return o.Literalism
}
// GetLiteralismOk returns a tuple with the Literalism field value
// and a boolean to check if the value has been set.
func (o *DispositionTraits) GetLiteralismOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Literalism, true
}
// SetLiteralism sets field value
func (o *DispositionTraits) SetLiteralism(v int32) {
o.Literalism = v
}
// GetEmpathy returns the Empathy field value
func (o *DispositionTraits) GetEmpathy() int32 {
if o == nil {
var ret int32
return ret
}
return o.Empathy
}
// GetEmpathyOk returns a tuple with the Empathy field value
// and a boolean to check if the value has been set.
func (o *DispositionTraits) GetEmpathyOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Empathy, true
}
// SetEmpathy sets field value
func (o *DispositionTraits) SetEmpathy(v int32) {
o.Empathy = v
}
func (o DispositionTraits) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DispositionTraits) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["skepticism"] = o.Skepticism
toSerialize["literalism"] = o.Literalism
toSerialize["empathy"] = o.Empathy
return toSerialize, nil
}
func (o *DispositionTraits) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"skepticism",
"literalism",
"empathy",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDispositionTraits := _DispositionTraits{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDispositionTraits)
if err != nil {
return err
}
*o = DispositionTraits(varDispositionTraits)
return err
}
type NullableDispositionTraits struct {
value *DispositionTraits
isSet bool
}
func (v NullableDispositionTraits) Get() *DispositionTraits {
return v.value
}
func (v *NullableDispositionTraits) Set(val *DispositionTraits) {
v.value = val
v.isSet = true
}
func (v NullableDispositionTraits) IsSet() bool {
return v.isSet
}
func (v *NullableDispositionTraits) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDispositionTraits(val *DispositionTraits) *NullableDispositionTraits {
return &NullableDispositionTraits{value: val, isSet: true}
}
func (v NullableDispositionTraits) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDispositionTraits) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,365 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the DocumentResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &DocumentResponse{}
// DocumentResponse Response model for get document endpoint.
type DocumentResponse struct {
Id string `json:"id"`
BankId string `json:"bank_id"`
OriginalText string `json:"original_text"`
ContentHash NullableString `json:"content_hash"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
MemoryUnitCount int32 `json:"memory_unit_count"`
// Tags associated with this document
Tags []string `json:"tags,omitempty"`
}
type _DocumentResponse DocumentResponse
// NewDocumentResponse instantiates a new DocumentResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewDocumentResponse(id string, bankId string, originalText string, contentHash NullableString, createdAt string, updatedAt string, memoryUnitCount int32) *DocumentResponse {
this := DocumentResponse{}
this.Id = id
this.BankId = bankId
this.OriginalText = originalText
this.ContentHash = contentHash
this.CreatedAt = createdAt
this.UpdatedAt = updatedAt
this.MemoryUnitCount = memoryUnitCount
return &this
}
// NewDocumentResponseWithDefaults instantiates a new DocumentResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewDocumentResponseWithDefaults() *DocumentResponse {
this := DocumentResponse{}
return &this
}
// GetId returns the Id field value
func (o *DocumentResponse) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *DocumentResponse) SetId(v string) {
o.Id = v
}
// GetBankId returns the BankId field value
func (o *DocumentResponse) GetBankId() string {
if o == nil {
var ret string
return ret
}
return o.BankId
}
// GetBankIdOk returns a tuple with the BankId field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetBankIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.BankId, true
}
// SetBankId sets field value
func (o *DocumentResponse) SetBankId(v string) {
o.BankId = v
}
// GetOriginalText returns the OriginalText field value
func (o *DocumentResponse) GetOriginalText() string {
if o == nil {
var ret string
return ret
}
return o.OriginalText
}
// GetOriginalTextOk returns a tuple with the OriginalText field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetOriginalTextOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.OriginalText, true
}
// SetOriginalText sets field value
func (o *DocumentResponse) SetOriginalText(v string) {
o.OriginalText = v
}
// GetContentHash returns the ContentHash field value
// If the value is explicit nil, the zero value for string will be returned
func (o *DocumentResponse) GetContentHash() string {
if o == nil || o.ContentHash.Get() == nil {
var ret string
return ret
}
return *o.ContentHash.Get()
}
// GetContentHashOk returns a tuple with the ContentHash field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *DocumentResponse) GetContentHashOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.ContentHash.Get(), o.ContentHash.IsSet()
}
// SetContentHash sets field value
func (o *DocumentResponse) SetContentHash(v string) {
o.ContentHash.Set(&v)
}
// GetCreatedAt returns the CreatedAt field value
func (o *DocumentResponse) GetCreatedAt() string {
if o == nil {
var ret string
return ret
}
return o.CreatedAt
}
// GetCreatedAtOk returns a tuple with the CreatedAt field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetCreatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CreatedAt, true
}
// SetCreatedAt sets field value
func (o *DocumentResponse) SetCreatedAt(v string) {
o.CreatedAt = v
}
// GetUpdatedAt returns the UpdatedAt field value
func (o *DocumentResponse) GetUpdatedAt() string {
if o == nil {
var ret string
return ret
}
return o.UpdatedAt
}
// GetUpdatedAtOk returns a tuple with the UpdatedAt field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetUpdatedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.UpdatedAt, true
}
// SetUpdatedAt sets field value
func (o *DocumentResponse) SetUpdatedAt(v string) {
o.UpdatedAt = v
}
// GetMemoryUnitCount returns the MemoryUnitCount field value
func (o *DocumentResponse) GetMemoryUnitCount() int32 {
if o == nil {
var ret int32
return ret
}
return o.MemoryUnitCount
}
// GetMemoryUnitCountOk returns a tuple with the MemoryUnitCount field value
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetMemoryUnitCountOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.MemoryUnitCount, true
}
// SetMemoryUnitCount sets field value
func (o *DocumentResponse) SetMemoryUnitCount(v int32) {
o.MemoryUnitCount = v
}
// GetTags returns the Tags field value if set, zero value otherwise.
func (o *DocumentResponse) GetTags() []string {
if o == nil || IsNil(o.Tags) {
var ret []string
return ret
}
return o.Tags
}
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DocumentResponse) GetTagsOk() ([]string, bool) {
if o == nil || IsNil(o.Tags) {
return nil, false
}
return o.Tags, true
}
// HasTags returns a boolean if a field has been set.
func (o *DocumentResponse) HasTags() bool {
if o != nil && !IsNil(o.Tags) {
return true
}
return false
}
// SetTags gets a reference to the given []string and assigns it to the Tags field.
func (o *DocumentResponse) SetTags(v []string) {
o.Tags = v
}
func (o DocumentResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o DocumentResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["bank_id"] = o.BankId
toSerialize["original_text"] = o.OriginalText
toSerialize["content_hash"] = o.ContentHash.Get()
toSerialize["created_at"] = o.CreatedAt
toSerialize["updated_at"] = o.UpdatedAt
toSerialize["memory_unit_count"] = o.MemoryUnitCount
if !IsNil(o.Tags) {
toSerialize["tags"] = o.Tags
}
return toSerialize, nil
}
func (o *DocumentResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"bank_id",
"original_text",
"content_hash",
"created_at",
"updated_at",
"memory_unit_count",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varDocumentResponse := _DocumentResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varDocumentResponse)
if err != nil {
return err
}
*o = DocumentResponse(varDocumentResponse)
return err
}
type NullableDocumentResponse struct {
value *DocumentResponse
isSet bool
}
func (v NullableDocumentResponse) Get() *DocumentResponse {
return v.value
}
func (v *NullableDocumentResponse) Set(val *DocumentResponse) {
v.value = val
v.isSet = true
}
func (v NullableDocumentResponse) IsSet() bool {
return v.isSet
}
func (v *NullableDocumentResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableDocumentResponse(val *DocumentResponse) *NullableDocumentResponse {
return &NullableDocumentResponse{value: val, isSet: true}
}
func (v NullableDocumentResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableDocumentResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,371 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityDetailResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityDetailResponse{}
// EntityDetailResponse Response model for entity detail endpoint.
type EntityDetailResponse struct {
Id string `json:"id"`
CanonicalName string `json:"canonical_name"`
MentionCount int32 `json:"mention_count"`
FirstSeen NullableString `json:"first_seen,omitempty"`
LastSeen NullableString `json:"last_seen,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Observations []EntityObservationResponse `json:"observations"`
}
type _EntityDetailResponse EntityDetailResponse
// NewEntityDetailResponse instantiates a new EntityDetailResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityDetailResponse(id string, canonicalName string, mentionCount int32, observations []EntityObservationResponse) *EntityDetailResponse {
this := EntityDetailResponse{}
this.Id = id
this.CanonicalName = canonicalName
this.MentionCount = mentionCount
this.Observations = observations
return &this
}
// NewEntityDetailResponseWithDefaults instantiates a new EntityDetailResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityDetailResponseWithDefaults() *EntityDetailResponse {
this := EntityDetailResponse{}
return &this
}
// GetId returns the Id field value
func (o *EntityDetailResponse) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *EntityDetailResponse) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *EntityDetailResponse) SetId(v string) {
o.Id = v
}
// GetCanonicalName returns the CanonicalName field value
func (o *EntityDetailResponse) GetCanonicalName() string {
if o == nil {
var ret string
return ret
}
return o.CanonicalName
}
// GetCanonicalNameOk returns a tuple with the CanonicalName field value
// and a boolean to check if the value has been set.
func (o *EntityDetailResponse) GetCanonicalNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CanonicalName, true
}
// SetCanonicalName sets field value
func (o *EntityDetailResponse) SetCanonicalName(v string) {
o.CanonicalName = v
}
// GetMentionCount returns the MentionCount field value
func (o *EntityDetailResponse) GetMentionCount() int32 {
if o == nil {
var ret int32
return ret
}
return o.MentionCount
}
// GetMentionCountOk returns a tuple with the MentionCount field value
// and a boolean to check if the value has been set.
func (o *EntityDetailResponse) GetMentionCountOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.MentionCount, true
}
// SetMentionCount sets field value
func (o *EntityDetailResponse) SetMentionCount(v int32) {
o.MentionCount = v
}
// GetFirstSeen returns the FirstSeen field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityDetailResponse) GetFirstSeen() string {
if o == nil || IsNil(o.FirstSeen.Get()) {
var ret string
return ret
}
return *o.FirstSeen.Get()
}
// GetFirstSeenOk returns a tuple with the FirstSeen field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityDetailResponse) GetFirstSeenOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.FirstSeen.Get(), o.FirstSeen.IsSet()
}
// HasFirstSeen returns a boolean if a field has been set.
func (o *EntityDetailResponse) HasFirstSeen() bool {
if o != nil && o.FirstSeen.IsSet() {
return true
}
return false
}
// SetFirstSeen gets a reference to the given NullableString and assigns it to the FirstSeen field.
func (o *EntityDetailResponse) SetFirstSeen(v string) {
o.FirstSeen.Set(&v)
}
// SetFirstSeenNil sets the value for FirstSeen to be an explicit nil
func (o *EntityDetailResponse) SetFirstSeenNil() {
o.FirstSeen.Set(nil)
}
// UnsetFirstSeen ensures that no value is present for FirstSeen, not even an explicit nil
func (o *EntityDetailResponse) UnsetFirstSeen() {
o.FirstSeen.Unset()
}
// GetLastSeen returns the LastSeen field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityDetailResponse) GetLastSeen() string {
if o == nil || IsNil(o.LastSeen.Get()) {
var ret string
return ret
}
return *o.LastSeen.Get()
}
// GetLastSeenOk returns a tuple with the LastSeen field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityDetailResponse) GetLastSeenOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastSeen.Get(), o.LastSeen.IsSet()
}
// HasLastSeen returns a boolean if a field has been set.
func (o *EntityDetailResponse) HasLastSeen() bool {
if o != nil && o.LastSeen.IsSet() {
return true
}
return false
}
// SetLastSeen gets a reference to the given NullableString and assigns it to the LastSeen field.
func (o *EntityDetailResponse) SetLastSeen(v string) {
o.LastSeen.Set(&v)
}
// SetLastSeenNil sets the value for LastSeen to be an explicit nil
func (o *EntityDetailResponse) SetLastSeenNil() {
o.LastSeen.Set(nil)
}
// UnsetLastSeen ensures that no value is present for LastSeen, not even an explicit nil
func (o *EntityDetailResponse) UnsetLastSeen() {
o.LastSeen.Unset()
}
// GetMetadata returns the Metadata field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityDetailResponse) GetMetadata() map[string]interface{} {
if o == nil {
var ret map[string]interface{}
return ret
}
return o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityDetailResponse) GetMetadataOk() (map[string]interface{}, bool) {
if o == nil || IsNil(o.Metadata) {
return map[string]interface{}{}, false
}
return o.Metadata, true
}
// HasMetadata returns a boolean if a field has been set.
func (o *EntityDetailResponse) HasMetadata() bool {
if o != nil && !IsNil(o.Metadata) {
return true
}
return false
}
// SetMetadata gets a reference to the given map[string]interface{} and assigns it to the Metadata field.
func (o *EntityDetailResponse) SetMetadata(v map[string]interface{}) {
o.Metadata = v
}
// GetObservations returns the Observations field value
func (o *EntityDetailResponse) GetObservations() []EntityObservationResponse {
if o == nil {
var ret []EntityObservationResponse
return ret
}
return o.Observations
}
// GetObservationsOk returns a tuple with the Observations field value
// and a boolean to check if the value has been set.
func (o *EntityDetailResponse) GetObservationsOk() ([]EntityObservationResponse, bool) {
if o == nil {
return nil, false
}
return o.Observations, true
}
// SetObservations sets field value
func (o *EntityDetailResponse) SetObservations(v []EntityObservationResponse) {
o.Observations = v
}
func (o EntityDetailResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityDetailResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["canonical_name"] = o.CanonicalName
toSerialize["mention_count"] = o.MentionCount
if o.FirstSeen.IsSet() {
toSerialize["first_seen"] = o.FirstSeen.Get()
}
if o.LastSeen.IsSet() {
toSerialize["last_seen"] = o.LastSeen.Get()
}
if o.Metadata != nil {
toSerialize["metadata"] = o.Metadata
}
toSerialize["observations"] = o.Observations
return toSerialize, nil
}
func (o *EntityDetailResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"canonical_name",
"mention_count",
"observations",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityDetailResponse := _EntityDetailResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityDetailResponse)
if err != nil {
return err
}
*o = EntityDetailResponse(varEntityDetailResponse)
return err
}
type NullableEntityDetailResponse struct {
value *EntityDetailResponse
isSet bool
}
func (v NullableEntityDetailResponse) Get() *EntityDetailResponse {
return v.value
}
func (v *NullableEntityDetailResponse) Set(val *EntityDetailResponse) {
v.value = val
v.isSet = true
}
func (v NullableEntityDetailResponse) IsSet() bool {
return v.isSet
}
func (v *NullableEntityDetailResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityDetailResponse(val *EntityDetailResponse) *NullableEntityDetailResponse {
return &NullableEntityDetailResponse{value: val, isSet: true}
}
func (v NullableEntityDetailResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityDetailResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,131 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
)
// checks if the EntityIncludeOptions type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityIncludeOptions{}
// EntityIncludeOptions Options for including entity observations in recall results.
type EntityIncludeOptions struct {
// Maximum tokens for entity observations
MaxTokens *int32 `json:"max_tokens,omitempty"`
}
// NewEntityIncludeOptions instantiates a new EntityIncludeOptions object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityIncludeOptions() *EntityIncludeOptions {
this := EntityIncludeOptions{}
var maxTokens int32 = 500
this.MaxTokens = &maxTokens
return &this
}
// NewEntityIncludeOptionsWithDefaults instantiates a new EntityIncludeOptions object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityIncludeOptionsWithDefaults() *EntityIncludeOptions {
this := EntityIncludeOptions{}
var maxTokens int32 = 500
this.MaxTokens = &maxTokens
return &this
}
// GetMaxTokens returns the MaxTokens field value if set, zero value otherwise.
func (o *EntityIncludeOptions) GetMaxTokens() int32 {
if o == nil || IsNil(o.MaxTokens) {
var ret int32
return ret
}
return *o.MaxTokens
}
// GetMaxTokensOk returns a tuple with the MaxTokens field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *EntityIncludeOptions) GetMaxTokensOk() (*int32, bool) {
if o == nil || IsNil(o.MaxTokens) {
return nil, false
}
return o.MaxTokens, true
}
// HasMaxTokens returns a boolean if a field has been set.
func (o *EntityIncludeOptions) HasMaxTokens() bool {
if o != nil && !IsNil(o.MaxTokens) {
return true
}
return false
}
// SetMaxTokens gets a reference to the given int32 and assigns it to the MaxTokens field.
func (o *EntityIncludeOptions) SetMaxTokens(v int32) {
o.MaxTokens = &v
}
func (o EntityIncludeOptions) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityIncludeOptions) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.MaxTokens) {
toSerialize["max_tokens"] = o.MaxTokens
}
return toSerialize, nil
}
type NullableEntityIncludeOptions struct {
value *EntityIncludeOptions
isSet bool
}
func (v NullableEntityIncludeOptions) Get() *EntityIncludeOptions {
return v.value
}
func (v *NullableEntityIncludeOptions) Set(val *EntityIncludeOptions) {
v.value = val
v.isSet = true
}
func (v NullableEntityIncludeOptions) IsSet() bool {
return v.isSet
}
func (v *NullableEntityIncludeOptions) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityIncludeOptions(val *EntityIncludeOptions) *NullableEntityIncludeOptions {
return &NullableEntityIncludeOptions{value: val, isSet: true}
}
func (v NullableEntityIncludeOptions) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityIncludeOptions) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
-205
View File
@@ -1,205 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityInput type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityInput{}
// EntityInput Entity to associate with retained content.
type EntityInput struct {
// The entity name/text
Text string `json:"text"`
Type NullableString `json:"type,omitempty"`
}
type _EntityInput EntityInput
// NewEntityInput instantiates a new EntityInput object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityInput(text string) *EntityInput {
this := EntityInput{}
this.Text = text
return &this
}
// NewEntityInputWithDefaults instantiates a new EntityInput object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityInputWithDefaults() *EntityInput {
this := EntityInput{}
return &this
}
// GetText returns the Text field value
func (o *EntityInput) GetText() string {
if o == nil {
var ret string
return ret
}
return o.Text
}
// GetTextOk returns a tuple with the Text field value
// and a boolean to check if the value has been set.
func (o *EntityInput) GetTextOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Text, true
}
// SetText sets field value
func (o *EntityInput) SetText(v string) {
o.Text = v
}
// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityInput) GetType() string {
if o == nil || IsNil(o.Type.Get()) {
var ret string
return ret
}
return *o.Type.Get()
}
// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityInput) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Type.Get(), o.Type.IsSet()
}
// HasType returns a boolean if a field has been set.
func (o *EntityInput) HasType() bool {
if o != nil && o.Type.IsSet() {
return true
}
return false
}
// SetType gets a reference to the given NullableString and assigns it to the Type field.
func (o *EntityInput) SetType(v string) {
o.Type.Set(&v)
}
// SetTypeNil sets the value for Type to be an explicit nil
func (o *EntityInput) SetTypeNil() {
o.Type.Set(nil)
}
// UnsetType ensures that no value is present for Type, not even an explicit nil
func (o *EntityInput) UnsetType() {
o.Type.Unset()
}
func (o EntityInput) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityInput) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["text"] = o.Text
if o.Type.IsSet() {
toSerialize["type"] = o.Type.Get()
}
return toSerialize, nil
}
func (o *EntityInput) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"text",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityInput := _EntityInput{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityInput)
if err != nil {
return err
}
*o = EntityInput(varEntityInput)
return err
}
type NullableEntityInput struct {
value *EntityInput
isSet bool
}
func (v NullableEntityInput) Get() *EntityInput {
return v.value
}
func (v *NullableEntityInput) Set(val *EntityInput) {
v.value = val
v.isSet = true
}
func (v NullableEntityInput) IsSet() bool {
return v.isSet
}
func (v *NullableEntityInput) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityInput(val *EntityInput) *NullableEntityInput {
return &NullableEntityInput{value: val, isSet: true}
}
func (v NullableEntityInput) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityInput) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,343 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityListItem type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityListItem{}
// EntityListItem Entity list item with summary.
type EntityListItem struct {
Id string `json:"id"`
CanonicalName string `json:"canonical_name"`
MentionCount int32 `json:"mention_count"`
FirstSeen NullableString `json:"first_seen,omitempty"`
LastSeen NullableString `json:"last_seen,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type _EntityListItem EntityListItem
// NewEntityListItem instantiates a new EntityListItem object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityListItem(id string, canonicalName string, mentionCount int32) *EntityListItem {
this := EntityListItem{}
this.Id = id
this.CanonicalName = canonicalName
this.MentionCount = mentionCount
return &this
}
// NewEntityListItemWithDefaults instantiates a new EntityListItem object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityListItemWithDefaults() *EntityListItem {
this := EntityListItem{}
return &this
}
// GetId returns the Id field value
func (o *EntityListItem) GetId() string {
if o == nil {
var ret string
return ret
}
return o.Id
}
// GetIdOk returns a tuple with the Id field value
// and a boolean to check if the value has been set.
func (o *EntityListItem) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *EntityListItem) SetId(v string) {
o.Id = v
}
// GetCanonicalName returns the CanonicalName field value
func (o *EntityListItem) GetCanonicalName() string {
if o == nil {
var ret string
return ret
}
return o.CanonicalName
}
// GetCanonicalNameOk returns a tuple with the CanonicalName field value
// and a boolean to check if the value has been set.
func (o *EntityListItem) GetCanonicalNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CanonicalName, true
}
// SetCanonicalName sets field value
func (o *EntityListItem) SetCanonicalName(v string) {
o.CanonicalName = v
}
// GetMentionCount returns the MentionCount field value
func (o *EntityListItem) GetMentionCount() int32 {
if o == nil {
var ret int32
return ret
}
return o.MentionCount
}
// GetMentionCountOk returns a tuple with the MentionCount field value
// and a boolean to check if the value has been set.
func (o *EntityListItem) GetMentionCountOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.MentionCount, true
}
// SetMentionCount sets field value
func (o *EntityListItem) SetMentionCount(v int32) {
o.MentionCount = v
}
// GetFirstSeen returns the FirstSeen field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityListItem) GetFirstSeen() string {
if o == nil || IsNil(o.FirstSeen.Get()) {
var ret string
return ret
}
return *o.FirstSeen.Get()
}
// GetFirstSeenOk returns a tuple with the FirstSeen field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityListItem) GetFirstSeenOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.FirstSeen.Get(), o.FirstSeen.IsSet()
}
// HasFirstSeen returns a boolean if a field has been set.
func (o *EntityListItem) HasFirstSeen() bool {
if o != nil && o.FirstSeen.IsSet() {
return true
}
return false
}
// SetFirstSeen gets a reference to the given NullableString and assigns it to the FirstSeen field.
func (o *EntityListItem) SetFirstSeen(v string) {
o.FirstSeen.Set(&v)
}
// SetFirstSeenNil sets the value for FirstSeen to be an explicit nil
func (o *EntityListItem) SetFirstSeenNil() {
o.FirstSeen.Set(nil)
}
// UnsetFirstSeen ensures that no value is present for FirstSeen, not even an explicit nil
func (o *EntityListItem) UnsetFirstSeen() {
o.FirstSeen.Unset()
}
// GetLastSeen returns the LastSeen field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityListItem) GetLastSeen() string {
if o == nil || IsNil(o.LastSeen.Get()) {
var ret string
return ret
}
return *o.LastSeen.Get()
}
// GetLastSeenOk returns a tuple with the LastSeen field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityListItem) GetLastSeenOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.LastSeen.Get(), o.LastSeen.IsSet()
}
// HasLastSeen returns a boolean if a field has been set.
func (o *EntityListItem) HasLastSeen() bool {
if o != nil && o.LastSeen.IsSet() {
return true
}
return false
}
// SetLastSeen gets a reference to the given NullableString and assigns it to the LastSeen field.
func (o *EntityListItem) SetLastSeen(v string) {
o.LastSeen.Set(&v)
}
// SetLastSeenNil sets the value for LastSeen to be an explicit nil
func (o *EntityListItem) SetLastSeenNil() {
o.LastSeen.Set(nil)
}
// UnsetLastSeen ensures that no value is present for LastSeen, not even an explicit nil
func (o *EntityListItem) UnsetLastSeen() {
o.LastSeen.Unset()
}
// GetMetadata returns the Metadata field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityListItem) GetMetadata() map[string]interface{} {
if o == nil {
var ret map[string]interface{}
return ret
}
return o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityListItem) GetMetadataOk() (map[string]interface{}, bool) {
if o == nil || IsNil(o.Metadata) {
return map[string]interface{}{}, false
}
return o.Metadata, true
}
// HasMetadata returns a boolean if a field has been set.
func (o *EntityListItem) HasMetadata() bool {
if o != nil && !IsNil(o.Metadata) {
return true
}
return false
}
// SetMetadata gets a reference to the given map[string]interface{} and assigns it to the Metadata field.
func (o *EntityListItem) SetMetadata(v map[string]interface{}) {
o.Metadata = v
}
func (o EntityListItem) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityListItem) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["id"] = o.Id
toSerialize["canonical_name"] = o.CanonicalName
toSerialize["mention_count"] = o.MentionCount
if o.FirstSeen.IsSet() {
toSerialize["first_seen"] = o.FirstSeen.Get()
}
if o.LastSeen.IsSet() {
toSerialize["last_seen"] = o.LastSeen.Get()
}
if o.Metadata != nil {
toSerialize["metadata"] = o.Metadata
}
return toSerialize, nil
}
func (o *EntityListItem) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"id",
"canonical_name",
"mention_count",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityListItem := _EntityListItem{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityListItem)
if err != nil {
return err
}
*o = EntityListItem(varEntityListItem)
return err
}
type NullableEntityListItem struct {
value *EntityListItem
isSet bool
}
func (v NullableEntityListItem) Get() *EntityListItem {
return v.value
}
func (v *NullableEntityListItem) Set(val *EntityListItem) {
v.value = val
v.isSet = true
}
func (v NullableEntityListItem) IsSet() bool {
return v.isSet
}
func (v *NullableEntityListItem) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityListItem(val *EntityListItem) *NullableEntityListItem {
return &NullableEntityListItem{value: val, isSet: true}
}
func (v NullableEntityListItem) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityListItem) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,242 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityListResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityListResponse{}
// EntityListResponse Response model for entity list endpoint.
type EntityListResponse struct {
Items []EntityListItem `json:"items"`
Total int32 `json:"total"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type _EntityListResponse EntityListResponse
// NewEntityListResponse instantiates a new EntityListResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityListResponse(items []EntityListItem, total int32, limit int32, offset int32) *EntityListResponse {
this := EntityListResponse{}
this.Items = items
this.Total = total
this.Limit = limit
this.Offset = offset
return &this
}
// NewEntityListResponseWithDefaults instantiates a new EntityListResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityListResponseWithDefaults() *EntityListResponse {
this := EntityListResponse{}
return &this
}
// GetItems returns the Items field value
func (o *EntityListResponse) GetItems() []EntityListItem {
if o == nil {
var ret []EntityListItem
return ret
}
return o.Items
}
// GetItemsOk returns a tuple with the Items field value
// and a boolean to check if the value has been set.
func (o *EntityListResponse) GetItemsOk() ([]EntityListItem, bool) {
if o == nil {
return nil, false
}
return o.Items, true
}
// SetItems sets field value
func (o *EntityListResponse) SetItems(v []EntityListItem) {
o.Items = v
}
// GetTotal returns the Total field value
func (o *EntityListResponse) GetTotal() int32 {
if o == nil {
var ret int32
return ret
}
return o.Total
}
// GetTotalOk returns a tuple with the Total field value
// and a boolean to check if the value has been set.
func (o *EntityListResponse) GetTotalOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Total, true
}
// SetTotal sets field value
func (o *EntityListResponse) SetTotal(v int32) {
o.Total = v
}
// GetLimit returns the Limit field value
func (o *EntityListResponse) GetLimit() int32 {
if o == nil {
var ret int32
return ret
}
return o.Limit
}
// GetLimitOk returns a tuple with the Limit field value
// and a boolean to check if the value has been set.
func (o *EntityListResponse) GetLimitOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Limit, true
}
// SetLimit sets field value
func (o *EntityListResponse) SetLimit(v int32) {
o.Limit = v
}
// GetOffset returns the Offset field value
func (o *EntityListResponse) GetOffset() int32 {
if o == nil {
var ret int32
return ret
}
return o.Offset
}
// GetOffsetOk returns a tuple with the Offset field value
// and a boolean to check if the value has been set.
func (o *EntityListResponse) GetOffsetOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Offset, true
}
// SetOffset sets field value
func (o *EntityListResponse) SetOffset(v int32) {
o.Offset = v
}
func (o EntityListResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityListResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["items"] = o.Items
toSerialize["total"] = o.Total
toSerialize["limit"] = o.Limit
toSerialize["offset"] = o.Offset
return toSerialize, nil
}
func (o *EntityListResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"items",
"total",
"limit",
"offset",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityListResponse := _EntityListResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityListResponse)
if err != nil {
return err
}
*o = EntityListResponse(varEntityListResponse)
return err
}
type NullableEntityListResponse struct {
value *EntityListResponse
isSet bool
}
func (v NullableEntityListResponse) Get() *EntityListResponse {
return v.value
}
func (v *NullableEntityListResponse) Set(val *EntityListResponse) {
v.value = val
v.isSet = true
}
func (v NullableEntityListResponse) IsSet() bool {
return v.isSet
}
func (v *NullableEntityListResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityListResponse(val *EntityListResponse) *NullableEntityListResponse {
return &NullableEntityListResponse{value: val, isSet: true}
}
func (v NullableEntityListResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityListResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,204 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityObservationResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityObservationResponse{}
// EntityObservationResponse An observation about an entity.
type EntityObservationResponse struct {
Text string `json:"text"`
MentionedAt NullableString `json:"mentioned_at,omitempty"`
}
type _EntityObservationResponse EntityObservationResponse
// NewEntityObservationResponse instantiates a new EntityObservationResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityObservationResponse(text string) *EntityObservationResponse {
this := EntityObservationResponse{}
this.Text = text
return &this
}
// NewEntityObservationResponseWithDefaults instantiates a new EntityObservationResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityObservationResponseWithDefaults() *EntityObservationResponse {
this := EntityObservationResponse{}
return &this
}
// GetText returns the Text field value
func (o *EntityObservationResponse) GetText() string {
if o == nil {
var ret string
return ret
}
return o.Text
}
// GetTextOk returns a tuple with the Text field value
// and a boolean to check if the value has been set.
func (o *EntityObservationResponse) GetTextOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Text, true
}
// SetText sets field value
func (o *EntityObservationResponse) SetText(v string) {
o.Text = v
}
// GetMentionedAt returns the MentionedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *EntityObservationResponse) GetMentionedAt() string {
if o == nil || IsNil(o.MentionedAt.Get()) {
var ret string
return ret
}
return *o.MentionedAt.Get()
}
// GetMentionedAtOk returns a tuple with the MentionedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *EntityObservationResponse) GetMentionedAtOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.MentionedAt.Get(), o.MentionedAt.IsSet()
}
// HasMentionedAt returns a boolean if a field has been set.
func (o *EntityObservationResponse) HasMentionedAt() bool {
if o != nil && o.MentionedAt.IsSet() {
return true
}
return false
}
// SetMentionedAt gets a reference to the given NullableString and assigns it to the MentionedAt field.
func (o *EntityObservationResponse) SetMentionedAt(v string) {
o.MentionedAt.Set(&v)
}
// SetMentionedAtNil sets the value for MentionedAt to be an explicit nil
func (o *EntityObservationResponse) SetMentionedAtNil() {
o.MentionedAt.Set(nil)
}
// UnsetMentionedAt ensures that no value is present for MentionedAt, not even an explicit nil
func (o *EntityObservationResponse) UnsetMentionedAt() {
o.MentionedAt.Unset()
}
func (o EntityObservationResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityObservationResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["text"] = o.Text
if o.MentionedAt.IsSet() {
toSerialize["mentioned_at"] = o.MentionedAt.Get()
}
return toSerialize, nil
}
func (o *EntityObservationResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"text",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityObservationResponse := _EntityObservationResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityObservationResponse)
if err != nil {
return err
}
*o = EntityObservationResponse(varEntityObservationResponse)
return err
}
type NullableEntityObservationResponse struct {
value *EntityObservationResponse
isSet bool
}
func (v NullableEntityObservationResponse) Get() *EntityObservationResponse {
return v.value
}
func (v *NullableEntityObservationResponse) Set(val *EntityObservationResponse) {
v.value = val
v.isSet = true
}
func (v NullableEntityObservationResponse) IsSet() bool {
return v.isSet
}
func (v *NullableEntityObservationResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityObservationResponse(val *EntityObservationResponse) *NullableEntityObservationResponse {
return &NullableEntityObservationResponse{value: val, isSet: true}
}
func (v NullableEntityObservationResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityObservationResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,214 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the EntityStateResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &EntityStateResponse{}
// EntityStateResponse Current mental model of an entity.
type EntityStateResponse struct {
EntityId string `json:"entity_id"`
CanonicalName string `json:"canonical_name"`
Observations []EntityObservationResponse `json:"observations"`
}
type _EntityStateResponse EntityStateResponse
// NewEntityStateResponse instantiates a new EntityStateResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewEntityStateResponse(entityId string, canonicalName string, observations []EntityObservationResponse) *EntityStateResponse {
this := EntityStateResponse{}
this.EntityId = entityId
this.CanonicalName = canonicalName
this.Observations = observations
return &this
}
// NewEntityStateResponseWithDefaults instantiates a new EntityStateResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewEntityStateResponseWithDefaults() *EntityStateResponse {
this := EntityStateResponse{}
return &this
}
// GetEntityId returns the EntityId field value
func (o *EntityStateResponse) GetEntityId() string {
if o == nil {
var ret string
return ret
}
return o.EntityId
}
// GetEntityIdOk returns a tuple with the EntityId field value
// and a boolean to check if the value has been set.
func (o *EntityStateResponse) GetEntityIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.EntityId, true
}
// SetEntityId sets field value
func (o *EntityStateResponse) SetEntityId(v string) {
o.EntityId = v
}
// GetCanonicalName returns the CanonicalName field value
func (o *EntityStateResponse) GetCanonicalName() string {
if o == nil {
var ret string
return ret
}
return o.CanonicalName
}
// GetCanonicalNameOk returns a tuple with the CanonicalName field value
// and a boolean to check if the value has been set.
func (o *EntityStateResponse) GetCanonicalNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CanonicalName, true
}
// SetCanonicalName sets field value
func (o *EntityStateResponse) SetCanonicalName(v string) {
o.CanonicalName = v
}
// GetObservations returns the Observations field value
func (o *EntityStateResponse) GetObservations() []EntityObservationResponse {
if o == nil {
var ret []EntityObservationResponse
return ret
}
return o.Observations
}
// GetObservationsOk returns a tuple with the Observations field value
// and a boolean to check if the value has been set.
func (o *EntityStateResponse) GetObservationsOk() ([]EntityObservationResponse, bool) {
if o == nil {
return nil, false
}
return o.Observations, true
}
// SetObservations sets field value
func (o *EntityStateResponse) SetObservations(v []EntityObservationResponse) {
o.Observations = v
}
func (o EntityStateResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o EntityStateResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["entity_id"] = o.EntityId
toSerialize["canonical_name"] = o.CanonicalName
toSerialize["observations"] = o.Observations
return toSerialize, nil
}
func (o *EntityStateResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"entity_id",
"canonical_name",
"observations",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varEntityStateResponse := _EntityStateResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varEntityStateResponse)
if err != nil {
return err
}
*o = EntityStateResponse(varEntityStateResponse)
return err
}
type NullableEntityStateResponse struct {
value *EntityStateResponse
isSet bool
}
func (v NullableEntityStateResponse) Get() *EntityStateResponse {
return v.value
}
func (v *NullableEntityStateResponse) Set(val *EntityStateResponse) {
v.value = val
v.isSet = true
}
func (v NullableEntityStateResponse) IsSet() bool {
return v.isSet
}
func (v *NullableEntityStateResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntityStateResponse(val *EntityStateResponse) *NullableEntityStateResponse {
return &NullableEntityStateResponse{value: val, isSet: true}
}
func (v NullableEntityStateResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntityStateResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
-275
View File
@@ -1,275 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the FeaturesInfo type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &FeaturesInfo{}
// FeaturesInfo Feature flags indicating which capabilities are enabled.
type FeaturesInfo struct {
// Whether observations (auto-consolidation) are enabled
Observations bool `json:"observations"`
// Whether MCP (Model Context Protocol) server is enabled
Mcp bool `json:"mcp"`
// Whether the background worker is enabled
Worker bool `json:"worker"`
// Whether per-bank configuration API is enabled
BankConfigApi bool `json:"bank_config_api"`
// Whether file upload/conversion API is enabled
FileUploadApi bool `json:"file_upload_api"`
}
type _FeaturesInfo FeaturesInfo
// NewFeaturesInfo instantiates a new FeaturesInfo object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewFeaturesInfo(observations bool, mcp bool, worker bool, bankConfigApi bool, fileUploadApi bool) *FeaturesInfo {
this := FeaturesInfo{}
this.Observations = observations
this.Mcp = mcp
this.Worker = worker
this.BankConfigApi = bankConfigApi
this.FileUploadApi = fileUploadApi
return &this
}
// NewFeaturesInfoWithDefaults instantiates a new FeaturesInfo object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewFeaturesInfoWithDefaults() *FeaturesInfo {
this := FeaturesInfo{}
return &this
}
// GetObservations returns the Observations field value
func (o *FeaturesInfo) GetObservations() bool {
if o == nil {
var ret bool
return ret
}
return o.Observations
}
// GetObservationsOk returns a tuple with the Observations field value
// and a boolean to check if the value has been set.
func (o *FeaturesInfo) GetObservationsOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Observations, true
}
// SetObservations sets field value
func (o *FeaturesInfo) SetObservations(v bool) {
o.Observations = v
}
// GetMcp returns the Mcp field value
func (o *FeaturesInfo) GetMcp() bool {
if o == nil {
var ret bool
return ret
}
return o.Mcp
}
// GetMcpOk returns a tuple with the Mcp field value
// and a boolean to check if the value has been set.
func (o *FeaturesInfo) GetMcpOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Mcp, true
}
// SetMcp sets field value
func (o *FeaturesInfo) SetMcp(v bool) {
o.Mcp = v
}
// GetWorker returns the Worker field value
func (o *FeaturesInfo) GetWorker() bool {
if o == nil {
var ret bool
return ret
}
return o.Worker
}
// GetWorkerOk returns a tuple with the Worker field value
// and a boolean to check if the value has been set.
func (o *FeaturesInfo) GetWorkerOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Worker, true
}
// SetWorker sets field value
func (o *FeaturesInfo) SetWorker(v bool) {
o.Worker = v
}
// GetBankConfigApi returns the BankConfigApi field value
func (o *FeaturesInfo) GetBankConfigApi() bool {
if o == nil {
var ret bool
return ret
}
return o.BankConfigApi
}
// GetBankConfigApiOk returns a tuple with the BankConfigApi field value
// and a boolean to check if the value has been set.
func (o *FeaturesInfo) GetBankConfigApiOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.BankConfigApi, true
}
// SetBankConfigApi sets field value
func (o *FeaturesInfo) SetBankConfigApi(v bool) {
o.BankConfigApi = v
}
// GetFileUploadApi returns the FileUploadApi field value
func (o *FeaturesInfo) GetFileUploadApi() bool {
if o == nil {
var ret bool
return ret
}
return o.FileUploadApi
}
// GetFileUploadApiOk returns a tuple with the FileUploadApi field value
// and a boolean to check if the value has been set.
func (o *FeaturesInfo) GetFileUploadApiOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.FileUploadApi, true
}
// SetFileUploadApi sets field value
func (o *FeaturesInfo) SetFileUploadApi(v bool) {
o.FileUploadApi = v
}
func (o FeaturesInfo) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o FeaturesInfo) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["observations"] = o.Observations
toSerialize["mcp"] = o.Mcp
toSerialize["worker"] = o.Worker
toSerialize["bank_config_api"] = o.BankConfigApi
toSerialize["file_upload_api"] = o.FileUploadApi
return toSerialize, nil
}
func (o *FeaturesInfo) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"observations",
"mcp",
"worker",
"bank_config_api",
"file_upload_api",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varFeaturesInfo := _FeaturesInfo{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varFeaturesInfo)
if err != nil {
return err
}
*o = FeaturesInfo(varFeaturesInfo)
return err
}
type NullableFeaturesInfo struct {
value *FeaturesInfo
isSet bool
}
func (v NullableFeaturesInfo) Get() *FeaturesInfo {
return v.value
}
func (v *NullableFeaturesInfo) Set(val *FeaturesInfo) {
v.value = val
v.isSet = true
}
func (v NullableFeaturesInfo) IsSet() bool {
return v.isSet
}
func (v *NullableFeaturesInfo) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableFeaturesInfo(val *FeaturesInfo) *NullableFeaturesInfo {
return &NullableFeaturesInfo{value: val, isSet: true}
}
func (v NullableFeaturesInfo) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableFeaturesInfo) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,159 +0,0 @@
/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the FileRetainResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &FileRetainResponse{}
// FileRetainResponse Response model for file upload endpoint.
type FileRetainResponse struct {
// Operation IDs for tracking file conversion operations. Use GET /v1/default/banks/{bank_id}/operations to list operations.
OperationIds []string `json:"operation_ids"`
}
type _FileRetainResponse FileRetainResponse
// NewFileRetainResponse instantiates a new FileRetainResponse object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewFileRetainResponse(operationIds []string) *FileRetainResponse {
this := FileRetainResponse{}
this.OperationIds = operationIds
return &this
}
// NewFileRetainResponseWithDefaults instantiates a new FileRetainResponse object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewFileRetainResponseWithDefaults() *FileRetainResponse {
this := FileRetainResponse{}
return &this
}
// GetOperationIds returns the OperationIds field value
func (o *FileRetainResponse) GetOperationIds() []string {
if o == nil {
var ret []string
return ret
}
return o.OperationIds
}
// GetOperationIdsOk returns a tuple with the OperationIds field value
// and a boolean to check if the value has been set.
func (o *FileRetainResponse) GetOperationIdsOk() ([]string, bool) {
if o == nil {
return nil, false
}
return o.OperationIds, true
}
// SetOperationIds sets field value
func (o *FileRetainResponse) SetOperationIds(v []string) {
o.OperationIds = v
}
func (o FileRetainResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o FileRetainResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["operation_ids"] = o.OperationIds
return toSerialize, nil
}
func (o *FileRetainResponse) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"operation_ids",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varFileRetainResponse := _FileRetainResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varFileRetainResponse)
if err != nil {
return err
}
*o = FileRetainResponse(varFileRetainResponse)
return err
}
type NullableFileRetainResponse struct {
value *FileRetainResponse
isSet bool
}
func (v NullableFileRetainResponse) Get() *FileRetainResponse {
return v.value
}
func (v *NullableFileRetainResponse) Set(val *FileRetainResponse) {
v.value = val
v.isSet = true
}
func (v NullableFileRetainResponse) IsSet() bool {
return v.isSet
}
func (v *NullableFileRetainResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableFileRetainResponse(val *FileRetainResponse) *NullableFileRetainResponse {
return &NullableFileRetainResponse{value: val, isSet: true}
}
func (v NullableFileRetainResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableFileRetainResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}

Some files were not shown because too many files have changed in this diff Show More