Compare commits

..
3 Commits
Author SHA1 Message Date
Nicolò Boschi 7972fd3906 feat: support litellm-sdk for reranker endpoint 2026-02-12 14:43:35 +01:00
Nicolò Boschi 86b698460e chore: remove dead code 2026-02-12 14:21:53 +01:00
Nicolò Boschi 6f9cef674b chore: remove dead code 2026-02-12 14:21:26 +01:00
306 changed files with 786 additions and 41163 deletions
+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,32 +0,0 @@
# PostgreSQL with pgvector and pg_textsearch extensions
# Note: pg_textsearch requires PostgreSQL 17+
FROM postgres:17
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
postgresql-server-dev-17 \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install pgvector
RUN cd /tmp && \
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
cd pgvector && \
make && \
make install
# Install pg_textsearch
RUN cd /tmp && \
git clone https://github.com/timescale/pg_textsearch.git && \
cd pg_textsearch && \
make && \
make install
# Clean up source files and build dependencies
RUN rm -rf /tmp/pgvector /tmp/pg_textsearch && \
apt-get purge -y --auto-remove build-essential git postgresql-server-dev-17
# Ensure extensions are preloaded
RUN echo "shared_preload_libraries = 'pg_textsearch'" >> /usr/share/postgresql/postgresql.conf.sample
@@ -1,91 +0,0 @@
name: hindsight
# Docker Compose file for Hindsight with PostgreSQL and Timescale pg_textsearch
# docker compose -f docker/docker-compose/pg_textsearch/docker-compose.yaml down && sleep 2 && docker compose -f docker/docker-compose/pg_textsearch/docker-compose.yaml up -d
# 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)
services:
db:
# Use custom PostgreSQL image with pgvector and pg_textsearch extensions
build:
context: .
dockerfile: Dockerfile
container_name: hindsight-db
restart: always
# Expose PostgreSQL port
ports:
- "5437:5432"
environment:
POSTGRES_USER: ${HINDSIGHT_DB_USER:-hindsight_user}
POSTGRES_PASSWORD: ${HINDSIGHT_DB_PASSWORD:-hindsight_password}
POSTGRES_DB: ${HINDSIGHT_DB_NAME:-hindsight_db}
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- hindsight-net
pg-textsearch-init:
build:
context: .
dockerfile: Dockerfile
depends_on:
- db
environment:
- PGPASSWORD=${HINDSIGHT_DB_PASSWORD:-hindsight_password}
command: >
bash -c "
echo 'Waiting for PostgreSQL to be ready...';
until pg_isready -h hindsight-db -p 5432 -U hindsight_user; do
echo 'PostgreSQL is unavailable - sleeping';
sleep 2;
done;
echo 'PostgreSQL is ready - creating hindsight_db database';
psql -h hindsight-db -p 5432 -U hindsight_user -c 'CREATE DATABASE hindsight_db;' 2>/dev/null || echo 'Database already exists';
echo 'Creating extensions in hindsight_db database';
psql -h hindsight-db -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS vector CASCADE;';
psql -h hindsight-db -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS pg_textsearch CASCADE;';
echo 'Database and extensions created successfully';
"
restart: "no"
networks:
- hindsight-net
hindsight:
image: ghcr.io/vectorize-io/hindsight:${HINDSIGHT_VERSION:-latest}
container_name: hindsight-app
ports:
- "8888:8888"
- "9999:9999"
environment:
# LLM Configuration
HINDSIGHT_API_LLM_PROVIDER: ${HINDSIGHT_API_LLM_PROVIDER:-openai}
HINDSIGHT_API_LLM_API_KEY: ${OPENAI_API_KEY:-your-api-key}
# Database Configuration
HINDSIGHT_API_DATABASE_URL: postgresql://${HINDSIGHT_DB_USER:-hindsight_user}:${HINDSIGHT_DB_PASSWORD:-hindsight_password}@db:5432/${HINDSIGHT_DB_NAME:-hindsight_db}
# Vector and Text Search Extensions
HINDSIGHT_API_VECTOR_EXTENSION: pgvector
HINDSIGHT_API_TEXT_SEARCH_EXTENSION: pg_textsearch
depends_on:
- db
networks:
- hindsight-net
networks:
hindsight-net:
driver: bridge
volumes:
pg_data:
@@ -1,16 +0,0 @@
# Git
.git
.gitignore
.gitattributes
# Docker
docker-compose.yaml
.dockerignore
# Documentation
README.md
*.md
# Environment
.env
.env.example
@@ -1,25 +0,0 @@
# PostgreSQL Configuration
HINDSIGHT_DB_USER=hindsight_user
HINDSIGHT_DB_PASSWORD=change-me-to-secure-password
HINDSIGHT_DB_NAME=hindsight_db
# Hindsight Version
HINDSIGHT_VERSION=latest
# LLM Configuration
HINDSIGHT_API_LLM_PROVIDER=openai
OPENAI_API_KEY=your-openai-api-key-here
# Alternative LLM providers (uncomment and configure as needed):
# HINDSIGHT_API_LLM_PROVIDER=anthropic
# ANTHROPIC_API_KEY=your-anthropic-api-key
# HINDSIGHT_API_LLM_PROVIDER=gemini
# GEMINI_API_KEY=your-gemini-api-key
# HINDSIGHT_API_LLM_PROVIDER=groq
# GROQ_API_KEY=your-groq-api-key
# Vector and Text Search (already configured in docker-compose.yaml)
# HINDSIGHT_API_VECTOR_EXTENSION=pgvectorscale
# HINDSIGHT_API_TEXT_SEARCH_EXTENSION=pg_textsearch
@@ -1,55 +0,0 @@
# PostgreSQL with pgvector, pgvectorscale, and pg_textsearch extensions
# All three extensions from Timescale/pgvector for high-performance vector and text search
# Note: Requires PostgreSQL 16+
FROM postgres:17
# Install build dependencies and Rust toolchain
RUN apt-get update && apt-get install -y \
build-essential \
git \
postgresql-server-dev-17 \
libpq-dev \
cmake \
curl \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Rust toolchain (required for pgvectorscale)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install pgvector (required by pgvectorscale)
RUN cd /tmp && \
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
cd pgvector && \
make && \
make install && \
rm -rf /tmp/pgvector
# Install cargo-pgrx (PostgreSQL extension framework for Rust)
RUN cargo install cargo-pgrx --version 0.12.5 --locked && \
cargo pgrx init --pg17 /usr/bin/pg_config
# Install pgvectorscale (DiskANN index support)
RUN cd /tmp && \
git clone --branch 0.5.1 https://github.com/timescale/pgvectorscale.git && \
cd pgvectorscale/pgvectorscale && \
cargo pgrx install --release && \
rm -rf /tmp/pgvectorscale
# Install pg_textsearch (BM25 text search)
RUN cd /tmp && \
git clone https://github.com/timescale/pg_textsearch.git && \
cd pg_textsearch && \
make && \
make install && \
rm -rf /tmp/pg_textsearch
# Clean up build dependencies (keep runtime dependencies)
RUN apt-get purge -y --auto-remove git cmake curl && \
rm -rf /root/.cargo/registry /root/.cargo/git
# Ensure extensions are preloaded (pg_textsearch requires preloading)
RUN echo "shared_preload_libraries = 'pg_textsearch'" >> /usr/share/postgresql/postgresql.conf.sample
-101
View File
@@ -1,101 +0,0 @@
# Hindsight with Timescale Extensions
This Docker Compose setup provides a complete Hindsight deployment with **Timescale extensions**:
- **pgvectorscale** - DiskANN algorithm for disk-based scalable vector search
- **pg_textsearch** - High-performance BM25 text search
Both extensions are from [Timescale](https://github.com/timescale) and provide production-grade performance.
## Prerequisites
- Docker and Docker Compose installed
- OpenAI API key (or another LLM provider)
## Quick Start
```bash
# Set environment variables
export HINDSIGHT_DB_PASSWORD="your-secure-password"
export OPENAI_API_KEY="your-openai-api-key"
# Build and start
docker compose -f docker/docker-compose/timescale/docker-compose.yaml up -d --build
# Check logs
docker compose -f docker/docker-compose/timescale/docker-compose.yaml logs -f
```
**Access:**
- API: http://localhost:8888
- Control Plane: http://localhost:9999
## Stop and Clean Up
```bash
# Stop services
docker compose -f docker/docker-compose/timescale/docker-compose.yaml down
# Remove volumes (deletes all data)
docker compose -f docker/docker-compose/timescale/docker-compose.yaml down -v
```
## Configuration
### Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `HINDSIGHT_DB_PASSWORD` | PostgreSQL password | `hindsight_password` |
| `HINDSIGHT_DB_USER` | PostgreSQL username | `hindsight_user` |
| `HINDSIGHT_DB_NAME` | Database name | `hindsight_db` |
| `HINDSIGHT_VERSION` | Hindsight Docker image version | `latest` |
| `OPENAI_API_KEY` | OpenAI API key | (required) |
| `HINDSIGHT_API_LLM_PROVIDER` | LLM provider | `openai` |
### Why Timescale Extensions?
**pgvectorscale (DiskANN):**
- 28x lower p95 latency vs dedicated vector databases
- 16x higher query throughput at 99% recall
- 60-75% cost reduction (disk is cheaper than RAM)
- Best for large datasets (10M+ vectors)
**pg_textsearch (BM25):**
- High-performance keyword retrieval
- Native BM25 ranking algorithm
- Optimized for full-text search
## Troubleshooting
### Extensions not installed
Check if extensions are available:
```bash
docker exec -it hindsight-db-timescale psql -U hindsight_user -d hindsight_db -c "\dx"
```
You should see:
- `vector` (pgvector)
- `vectorscale` (pgvectorscale/DiskANN)
- `pg_textsearch` (BM25 search)
### Build fails
If the Docker build fails during pgvectorscale compilation:
1. Ensure you have sufficient memory (recommended: 4GB+)
2. Check Docker build logs for Rust compilation errors
3. Try building with more resources: `docker compose build --no-cache --memory 4g`
### Port conflicts
If port 5438 is already in use, modify the `ports` section in docker-compose.yaml.
## Learn More
- [pgvectorscale GitHub](https://github.com/timescale/pgvectorscale)
- [pg_textsearch GitHub](https://github.com/timescale/pg_textsearch)
- [HNSW vs DiskANN](https://www.tigerdata.com/learn/hnsw-vs-diskann)
- [Hindsight Documentation](https://hindsight.dev)
@@ -1,108 +0,0 @@
name: hindsight
# Docker Compose file for Hindsight with Timescale extensions
# - pgvectorscale: DiskANN vector search (disk-based, scalable)
# - pg_textsearch: BM25 text search (high-performance keyword retrieval)
#
# Quick start:
# docker compose -f docker/docker-compose/timescale/docker-compose.yaml up -d --build
#
# Required environment variables:
# - HINDSIGHT_DB_PASSWORD: Password for the PostgreSQL user
# - OPENAI_API_KEY (or configure another LLM provider)
#
# 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)
services:
db:
# Custom PostgreSQL image with Timescale extensions (pgvectorscale + pg_textsearch)
build:
context: .
dockerfile: Dockerfile
container_name: hindsight-db-timescale
restart: always
# Expose PostgreSQL port (using 5438 to avoid conflicts with other setups)
ports:
- "5438:5432"
environment:
POSTGRES_USER: ${HINDSIGHT_DB_USER:-hindsight_user}
POSTGRES_PASSWORD: ${HINDSIGHT_DB_PASSWORD:-hindsight_password}
POSTGRES_DB: ${HINDSIGHT_DB_NAME:-hindsight_db}
volumes:
- pg_data:/var/lib/postgresql/data
networks:
- hindsight-net
# Health check to ensure database is ready
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hindsight_user"]
interval: 5s
timeout: 5s
retries: 5
timescale-init:
build:
context: .
dockerfile: Dockerfile
depends_on:
db:
condition: service_healthy
environment:
- PGPASSWORD=${HINDSIGHT_DB_PASSWORD:-hindsight_password}
command: >
bash -c "
echo 'PostgreSQL is ready - creating hindsight_db database';
psql -h hindsight-db-timescale -p 5432 -U hindsight_user -c 'CREATE DATABASE hindsight_db;' 2>/dev/null || echo 'Database already exists';
echo 'Installing Timescale extensions...';
echo '1/3: Installing pgvector (required by pgvectorscale)...';
psql -h hindsight-db-timescale -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS vector CASCADE;';
echo '2/3: Installing pgvectorscale (DiskANN vector search)...';
psql -h hindsight-db-timescale -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE;';
echo '3/3: Installing pg_textsearch (BM25 text search)...';
psql -h hindsight-db-timescale -p 5432 -U hindsight_user -d hindsight_db -c 'CREATE EXTENSION IF NOT EXISTS pg_textsearch CASCADE;';
echo '';
echo '✅ Timescale extensions installed successfully';
echo '';
echo 'Installed extensions:';
psql -h hindsight-db-timescale -p 5432 -U hindsight_user -d hindsight_db -c \"\\dx\" | grep -E '(vector|vectorscale|pg_textsearch)';
"
restart: "no"
networks:
- hindsight-net
hindsight:
image: ghcr.io/vectorize-io/hindsight:${HINDSIGHT_VERSION:-latest}
container_name: hindsight-app-timescale
ports:
- "8888:8888"
- "9999:9999"
environment:
# LLM Configuration
HINDSIGHT_API_LLM_PROVIDER: ${HINDSIGHT_API_LLM_PROVIDER:-openai}
HINDSIGHT_API_LLM_API_KEY: ${OPENAI_API_KEY:-your-api-key}
# Database Configuration
HINDSIGHT_API_DATABASE_URL: postgresql://${HINDSIGHT_DB_USER:-hindsight_user}:${HINDSIGHT_DB_PASSWORD:-hindsight_password}@db:5432/${HINDSIGHT_DB_NAME:-hindsight_db}
# Timescale Extensions
# pgvectorscale: DiskANN algorithm for disk-based scalable vector search
HINDSIGHT_API_VECTOR_EXTENSION: pgvectorscale
# pg_textsearch: High-performance BM25 text search
HINDSIGHT_API_TEXT_SEARCH_EXTENSION: pg_textsearch
depends_on:
db:
condition: service_healthy
timescale-init:
condition: service_completed_successfully
networks:
- hindsight-net
networks:
hindsight-net:
driver: bridge
volumes:
pg_data:
+2 -2
View File
@@ -2,8 +2,8 @@ apiVersion: v2
name: hindsight
description: Hindsight helm chart
type: application
version: 0.4.11
appVersion: "0.4.11"
version: 0.4.10
appVersion: "0.4.10"
keywords:
- ai
- memory
+1 -1
View File
@@ -46,4 +46,4 @@ __all__ = [
"RemoteTEICrossEncoder",
"LLMConfig",
]
__version__ = "0.4.11"
__version__ = "0.4.10"
@@ -24,27 +24,14 @@ depends_on: str | Sequence[str] | None = None
def _detect_vector_extension() -> str:
"""
Detect or validate vector extension: 'pgvector', 'vchord', or 'pgvectorscale'.
Detect or validate vector extension: 'vchord' or 'pgvector'.
Respects HINDSIGHT_API_VECTOR_EXTENSION env var if set.
"""
conn = op.get_bind()
vector_extension = os.getenv("HINDSIGHT_API_VECTOR_EXTENSION", "pgvector").lower()
# Validate configured extension is installed
if vector_extension == "pgvectorscale":
# pgvectorscale requires pgvector
pgvector_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vector'")).scalar()
if not pgvector_check:
raise RuntimeError(
"pgvectorscale requires pgvector. Install with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
return "pgvectorscale"
elif vector_extension == "vchord":
if vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
raise RuntimeError(
@@ -59,14 +46,12 @@ def _detect_vector_extension() -> str:
)
return "pgvector"
else:
raise ValueError(
f"Invalid HINDSIGHT_API_VECTOR_EXTENSION: {vector_extension}. Must be 'pgvector', 'vchord', or 'pgvectorscale'"
)
raise ValueError(f"Invalid HINDSIGHT_API_VECTOR_EXTENSION: {vector_extension}. Must be 'pgvector' or 'vchord'")
def _detect_text_search_extension() -> str:
"""
Detect or validate text search extension: 'native', 'vchord', or 'pg_textsearch'.
Detect or validate text search extension: 'native' or 'vchord'.
Respects HINDSIGHT_API_TEXT_SEARCH_EXTENSION env var.
Creates the extension if needed.
"""
@@ -84,23 +69,11 @@ def _detect_text_search_extension() -> str:
# Extension truly doesn't exist - re-raise the error
raise
return "vchord"
elif text_search_extension == "pg_textsearch":
# Create pg_textsearch extension if not exists
try:
op.execute("CREATE EXTENSION IF NOT EXISTS pg_textsearch CASCADE")
except Exception:
# Extension might already exist or user lacks permissions - verify it exists
conn = op.get_bind()
result = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'pg_textsearch'")).fetchone()
if not result:
# Extension truly doesn't exist - re-raise the error
raise
return "pg_textsearch"
elif text_search_extension == "native":
return "native"
else:
raise ValueError(
f"Invalid HINDSIGHT_API_TEXT_SEARCH_EXTENSION: {text_search_extension}. Must be 'native', 'vchord', or 'pg_textsearch'"
f"Invalid HINDSIGHT_API_TEXT_SEARCH_EXTENSION: {text_search_extension}. Must be 'native' or 'vchord'"
)
@@ -259,12 +232,6 @@ def upgrade() -> None:
ALTER TABLE memory_units
ADD COLUMN search_vector bm25_catalog.bm25vector
""")
elif text_search_ext == "pg_textsearch":
# Timescale pg_textsearch: dummy TEXT column for consistency (indexes operate on base columns directly)
op.execute("""
ALTER TABLE memory_units
ADD COLUMN search_vector TEXT
""")
else: # native
# Native PostgreSQL: tsvector with automatic generation
op.execute("""
@@ -304,14 +271,7 @@ def upgrade() -> None:
# Create vector index - conditional based on available extension
vector_ext = _detect_vector_extension()
if vector_ext == "pgvectorscale":
# Use DiskANN index for pgvectorscale (disk-based, scalable)
op.execute("""
CREATE INDEX idx_memory_units_embedding ON memory_units
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "vchord":
if vector_ext == "vchord":
# Use vchordrq index for vchord (supports high-dimensional embeddings)
op.execute("""
CREATE INDEX idx_memory_units_embedding ON memory_units
@@ -335,14 +295,6 @@ def upgrade() -> None:
CREATE INDEX idx_memory_units_text_search ON memory_units
USING bm25 (search_vector bm25_catalog.bm25_ops)
""")
elif text_search_ext == "pg_textsearch":
# Timescale pg_textsearch BM25 index on text column
# Note: pg_textsearch doesn't support expressions, so we index the main text column
op.execute("""
CREATE INDEX idx_memory_units_text_search ON memory_units
USING bm25(text)
WITH (text_config='english')
""")
else: # native
# Native PostgreSQL GIN index
op.execute("""
@@ -31,27 +31,14 @@ def _get_schema_prefix() -> str:
def _detect_vector_extension() -> str:
"""
Detect or validate vector extension: 'pgvector', 'vchord', or 'pgvectorscale'.
Detect or validate vector extension: 'vchord' or 'pgvector'.
Respects HINDSIGHT_API_VECTOR_EXTENSION env var if set.
"""
conn = op.get_bind()
vector_extension = os.getenv("HINDSIGHT_API_VECTOR_EXTENSION", "pgvector").lower()
# Validate configured extension is installed
if vector_extension == "pgvectorscale":
# pgvectorscale requires pgvector
pgvector_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vector'")).scalar()
if not pgvector_check:
raise RuntimeError(
"pgvectorscale requires pgvector. Install with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
return "pgvectorscale"
elif vector_extension == "vchord":
if vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
raise RuntimeError(
@@ -66,14 +53,12 @@ def _detect_vector_extension() -> str:
)
return "pgvector"
else:
raise ValueError(
f"Invalid HINDSIGHT_API_VECTOR_EXTENSION: {vector_extension}. Must be 'pgvector', 'vchord', or 'pgvectorscale'"
)
raise ValueError(f"Invalid HINDSIGHT_API_VECTOR_EXTENSION: {vector_extension}. Must be 'pgvector' or 'vchord'")
def _detect_text_search_extension() -> str:
"""
Detect or validate text search extension: 'native', 'vchord', or 'pg_textsearch'.
Detect or validate text search extension: 'native' or 'vchord'.
Respects HINDSIGHT_API_TEXT_SEARCH_EXTENSION env var.
Creates the extension if needed.
"""
@@ -91,23 +76,11 @@ def _detect_text_search_extension() -> str:
# Extension truly doesn't exist - re-raise the error
raise
return "vchord"
elif text_search_extension == "pg_textsearch":
# Create pg_textsearch extension if not exists
try:
op.execute("CREATE EXTENSION IF NOT EXISTS pg_textsearch CASCADE")
except Exception:
# Extension might already exist or user lacks permissions - verify it exists
conn = op.get_bind()
result = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'pg_textsearch'")).fetchone()
if not result:
# Extension truly doesn't exist - re-raise the error
raise
return "pg_textsearch"
elif text_search_extension == "native":
return "native"
else:
raise ValueError(
f"Invalid HINDSIGHT_API_TEXT_SEARCH_EXTENSION: {text_search_extension}. Must be 'native', 'vchord', or 'pg_textsearch'"
f"Invalid HINDSIGHT_API_TEXT_SEARCH_EXTENSION: {text_search_extension}. Must be 'native' or 'vchord'"
)
@@ -149,13 +122,7 @@ def upgrade() -> None:
op.execute(f"CREATE INDEX idx_learnings_bank_id ON {schema}learnings(bank_id)")
# Create vector index based on detected extension
if vector_ext == "pgvectorscale":
op.execute(f"""
CREATE INDEX idx_learnings_embedding ON {schema}learnings
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "vchord":
if vector_ext == "vchord":
op.execute(f"""
CREATE INDEX idx_learnings_embedding ON {schema}learnings
USING vchordrq (embedding vector_l2_ops)
@@ -179,15 +146,6 @@ def upgrade() -> None:
CREATE INDEX idx_learnings_text_search ON {schema}learnings
USING bm25 (search_vector bm25_catalog.bm25_ops)
""")
elif text_search_ext == "pg_textsearch":
# Timescale pg_textsearch: dummy TEXT column for consistency (indexes operate on base columns directly)
op.execute(f"""
ALTER TABLE {schema}learnings ADD COLUMN search_vector TEXT
""")
op.execute(f"""
CREATE INDEX idx_learnings_text_search ON {schema}learnings
USING bm25(text) WITH (text_config='english')
""")
else: # native
# Native PostgreSQL: tsvector with automatic generation
op.execute(f"""
@@ -222,13 +180,7 @@ def upgrade() -> None:
op.execute(f"CREATE INDEX idx_pinned_reflections_bank_id ON {schema}pinned_reflections(bank_id)")
# Create vector index based on detected extension
if vector_ext == "pgvectorscale":
op.execute(f"""
CREATE INDEX idx_pinned_reflections_embedding ON {schema}pinned_reflections
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
elif vector_ext == "vchord":
if vector_ext == "vchord":
op.execute(f"""
CREATE INDEX idx_pinned_reflections_embedding ON {schema}pinned_reflections
USING vchordrq (embedding vector_l2_ops)
@@ -252,16 +204,6 @@ def upgrade() -> None:
CREATE INDEX idx_pinned_reflections_text_search ON {schema}pinned_reflections
USING bm25 (search_vector bm25_catalog.bm25_ops)
""")
elif text_search_ext == "pg_textsearch":
# Timescale pg_textsearch: dummy TEXT column for consistency (indexes operate on base columns directly)
op.execute(f"""
ALTER TABLE {schema}pinned_reflections ADD COLUMN search_vector TEXT
""")
op.execute(f"""
CREATE INDEX idx_pinned_reflections_text_search ON {schema}pinned_reflections
USING bm25(content)
WITH (text_config='english')
""")
else: # native
# Native PostgreSQL: tsvector with automatic generation
op.execute(f"""
@@ -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")
-32
View File
@@ -1357,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."""
@@ -1391,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):
@@ -3580,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(
-4
View File
@@ -86,8 +86,6 @@ def print_startup_info(
reranker_provider: str,
mcp_enabled: bool = False,
version: str | None = None,
vector_extension: str | None = None,
text_search_extension: str | None = None,
):
"""Print styled startup information."""
print(color_start("Starting Hindsight API..."))
@@ -98,8 +96,6 @@ def print_startup_info(
print(f" {dim('LLM:')} {color(f'{llm_provider} / {llm_model}', 0.6)}")
print(f" {dim('Embeddings:')} {color(embeddings_provider, 0.8)}")
print(f" {dim('Reranker:')} {color(reranker_provider, 1.0)}")
extensions = f"{vector_extension or 'default'} (vector) / {text_search_extension or 'default'} (text)"
print(f" {dim('Extensions:')} {color(extensions, 0.4)}")
if mcp_enabled:
print(f" {dim('MCP:')} {color_end('enabled at /mcp')}")
print()
+6 -58
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"
@@ -194,14 +189,6 @@ ENV_RERANKER_LITELLM_API_BASE = "HINDSIGHT_API_RERANKER_LITELLM_API_BASE"
ENV_RERANKER_LITELLM_API_KEY = "HINDSIGHT_API_RERANKER_LITELLM_API_KEY"
ENV_RERANKER_LITELLM_MODEL = "HINDSIGHT_API_RERANKER_LITELLM_MODEL"
# LiteLLM SDK configuration (direct API access, no proxy needed)
ENV_EMBEDDINGS_LITELLM_SDK_API_KEY = "HINDSIGHT_API_EMBEDDINGS_LITELLM_SDK_API_KEY"
ENV_EMBEDDINGS_LITELLM_SDK_MODEL = "HINDSIGHT_API_EMBEDDINGS_LITELLM_SDK_MODEL"
ENV_EMBEDDINGS_LITELLM_SDK_API_BASE = "HINDSIGHT_API_EMBEDDINGS_LITELLM_SDK_API_BASE"
ENV_RERANKER_LITELLM_SDK_API_KEY = "HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY"
ENV_RERANKER_LITELLM_SDK_MODEL = "HINDSIGHT_API_RERANKER_LITELLM_SDK_MODEL"
ENV_RERANKER_LITELLM_SDK_API_BASE = "HINDSIGHT_API_RERANKER_LITELLM_SDK_API_BASE"
# Deprecated: Legacy shared LiteLLM config (for backward compatibility)
ENV_LITELLM_API_BASE = "HINDSIGHT_API_LITELLM_API_BASE"
ENV_LITELLM_API_KEY = "HINDSIGHT_API_LITELLM_API_KEY"
@@ -255,9 +242,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"
# Observations settings (consolidated knowledge from facts)
ENV_ENABLE_OBSERVATIONS = "HINDSIGHT_API_ENABLE_OBSERVATIONS"
@@ -342,21 +326,17 @@ DEFAULT_RERANKER_FLASHRANK_CACHE_DIR = None # Use default cache directory
DEFAULT_EMBEDDINGS_COHERE_MODEL = "embed-english-v3.0"
DEFAULT_RERANKER_COHERE_MODEL = "rerank-english-v3.0"
# Vector extension (pgvector, vchord, or pgvectorscale)
DEFAULT_VECTOR_EXTENSION = "pgvector" # Options: "pgvector", "vchord", "pgvectorscale"
# Vector extension (pgvector vs vchord)
DEFAULT_VECTOR_EXTENSION = "pgvector" # Options: "pgvector", "vchord"
# Text search extension (native PostgreSQL, vchord BM25, or Timescale pg_textsearch)
DEFAULT_TEXT_SEARCH_EXTENSION = "native" # Options: "native", "vchord", "pg_textsearch"
# Text search extension (native PostgreSQL vs vchord BM25)
DEFAULT_TEXT_SEARCH_EXTENSION = "native" # Options: "native", "vchord"
# LiteLLM defaults
DEFAULT_LITELLM_API_BASE = "http://localhost:4000"
DEFAULT_EMBEDDINGS_LITELLM_MODEL = "text-embedding-3-small"
DEFAULT_RERANKER_LITELLM_MODEL = "cohere/rerank-english-v3.0"
# LiteLLM SDK defaults
DEFAULT_EMBEDDINGS_LITELLM_SDK_MODEL = "cohere/embed-english-v3.0"
DEFAULT_RERANKER_LITELLM_SDK_MODEL = "cohere/rerank-english-v3.0"
DEFAULT_HOST = "0.0.0.0"
DEFAULT_PORT = 8888
DEFAULT_BASE_PATH = "" # Empty string = root path
@@ -379,9 +359,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
# Observations defaults (consolidated knowledge from facts)
DEFAULT_ENABLE_OBSERVATIONS = True # Observations enabled by default
@@ -505,8 +482,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
@@ -557,9 +532,6 @@ class HindsightConfig:
embeddings_litellm_api_base: str
embeddings_litellm_api_key: str | None
embeddings_litellm_model: str
embeddings_litellm_sdk_api_key: str | None
embeddings_litellm_sdk_model: str
embeddings_litellm_sdk_api_base: str | None
# Reranker
reranker_provider: str
@@ -577,9 +549,6 @@ class HindsightConfig:
reranker_litellm_api_base: str
reranker_litellm_api_key: str | None
reranker_litellm_model: str
reranker_litellm_sdk_api_key: str | None
reranker_litellm_sdk_model: str
reranker_litellm_sdk_api_base: str | None
# Server
host: str
@@ -603,9 +572,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
# Observations settings (consolidated knowledge from facts)
enable_observations: bool
@@ -733,14 +699,14 @@ class HindsightConfig:
def validate(self) -> None:
"""Validate configuration values and raise errors for invalid combinations."""
# Validate vector_extension
valid_extensions = ("pgvector", "vchord", "pgvectorscale")
valid_extensions = ("pgvector", "vchord")
if self.vector_extension not in valid_extensions:
raise ValueError(
f"Invalid vector_extension: {self.vector_extension}. Must be one of: {', '.join(valid_extensions)}"
)
# Validate text_search_extension
valid_text_search = ("native", "vchord", "pg_textsearch")
valid_text_search = ("native", "vchord")
if self.text_search_extension not in valid_text_search:
raise ValueError(
f"Invalid text_search_extension: {self.text_search_extension}. Must be one of: {', '.join(valid_text_search)}"
@@ -783,8 +749,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),
@@ -883,12 +847,6 @@ class HindsightConfig:
or os.getenv(ENV_LITELLM_API_BASE, DEFAULT_LITELLM_API_BASE),
embeddings_litellm_api_key=os.getenv(ENV_EMBEDDINGS_LITELLM_API_KEY) or os.getenv(ENV_LITELLM_API_KEY),
embeddings_litellm_model=os.getenv(ENV_EMBEDDINGS_LITELLM_MODEL, DEFAULT_EMBEDDINGS_LITELLM_MODEL),
# LiteLLM SDK embeddings (direct API access)
embeddings_litellm_sdk_api_key=os.getenv(ENV_EMBEDDINGS_LITELLM_SDK_API_KEY),
embeddings_litellm_sdk_model=os.getenv(
ENV_EMBEDDINGS_LITELLM_SDK_MODEL, DEFAULT_EMBEDDINGS_LITELLM_SDK_MODEL
),
embeddings_litellm_sdk_api_base=os.getenv(ENV_EMBEDDINGS_LITELLM_SDK_API_BASE) or None,
# Reranker
reranker_provider=os.getenv(ENV_RERANKER_PROVIDER, DEFAULT_RERANKER_PROVIDER),
reranker_local_model=os.getenv(ENV_RERANKER_LOCAL_MODEL, DEFAULT_RERANKER_LOCAL_MODEL),
@@ -918,10 +876,6 @@ class HindsightConfig:
or os.getenv(ENV_LITELLM_API_BASE, DEFAULT_LITELLM_API_BASE),
reranker_litellm_api_key=os.getenv(ENV_RERANKER_LITELLM_API_KEY) or os.getenv(ENV_LITELLM_API_KEY),
reranker_litellm_model=os.getenv(ENV_RERANKER_LITELLM_MODEL, DEFAULT_RERANKER_LITELLM_MODEL),
# LiteLLM SDK reranker (direct API access)
reranker_litellm_sdk_api_key=os.getenv(ENV_RERANKER_LITELLM_SDK_API_KEY),
reranker_litellm_sdk_model=os.getenv(ENV_RERANKER_LITELLM_SDK_MODEL, DEFAULT_RERANKER_LITELLM_SDK_MODEL),
reranker_litellm_sdk_api_base=os.getenv(ENV_RERANKER_LITELLM_SDK_API_BASE) or None,
# Server
host=os.getenv(ENV_HOST, DEFAULT_HOST),
port=int(os.getenv(ENV_PORT, DEFAULT_PORT)),
@@ -957,12 +911,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))
),
# Observations settings (consolidated knowledge from facts)
enable_observations=os.getenv(ENV_ENABLE_OBSERVATIONS, str(DEFAULT_ENABLE_OBSERVATIONS)).lower() == "true",
consolidation_batch_size=int(
@@ -1030,9 +1030,8 @@ async def _create_observation_directly(
tokenize($3, 'llmlingua2')::bm25_catalog.bm25vector)
RETURNING id
"""
else: # native or pg_textsearch
else: # native
# Native PostgreSQL: search_vector is GENERATED ALWAYS, don't include it
# pg_textsearch: indexes operate on base columns directly, don't populate search_vector
query = f"""
INSERT INTO {fq_table("memory_units")} (
id, bank_id, text, fact_type, embedding, proof_count, source_memory_ids, history,
@@ -21,7 +21,6 @@ from ..config import (
DEFAULT_RERANKER_FLASHRANK_CACHE_DIR,
DEFAULT_RERANKER_FLASHRANK_MODEL,
DEFAULT_RERANKER_LITELLM_MODEL,
DEFAULT_RERANKER_LITELLM_SDK_MODEL,
DEFAULT_RERANKER_LOCAL_FORCE_CPU,
DEFAULT_RERANKER_LOCAL_MAX_CONCURRENT,
DEFAULT_RERANKER_LOCAL_MODEL,
@@ -33,7 +32,6 @@ from ..config import (
ENV_RERANKER_COHERE_MODEL,
ENV_RERANKER_FLASHRANK_CACHE_DIR,
ENV_RERANKER_FLASHRANK_MODEL,
ENV_RERANKER_LITELLM_SDK_API_KEY,
ENV_RERANKER_LOCAL_FORCE_CPU,
ENV_RERANKER_LOCAL_MAX_CONCURRENT,
ENV_RERANKER_LOCAL_MODEL,
@@ -830,126 +828,6 @@ class LiteLLMCrossEncoder(CrossEncoderModel):
return all_scores
class LiteLLMSDKCrossEncoder(CrossEncoderModel):
"""
LiteLLM SDK cross-encoder for direct API integration.
Supports reranking via LiteLLM SDK without requiring a proxy server.
Supported providers: Cohere, DeepInfra, Together AI, HuggingFace, Jina AI, Voyage AI, AWS Bedrock.
Example model names:
- cohere/rerank-english-v3.0
- deepinfra/Qwen3-reranker-8B
- together_ai/Salesforce/Llama-Rank-V1
- huggingface/BAAI/bge-reranker-v2-m3
"""
def __init__(
self,
api_key: str,
model: str = DEFAULT_RERANKER_LITELLM_SDK_MODEL,
api_base: str | None = None,
timeout: float = 60.0,
):
"""
Initialize LiteLLM SDK cross-encoder client.
Args:
api_key: API key for the reranking provider
model: Model name with provider prefix (e.g., "deepinfra/Qwen3-reranker-8B")
api_base: Custom base URL for API (optional)
timeout: Request timeout in seconds (default: 60.0)
"""
self.api_key = api_key
self.model = model
self.api_base = api_base
self.timeout = timeout
self._initialized = False
self._litellm = None # Will be set during initialization
@property
def provider_name(self) -> str:
return "litellm-sdk"
async def initialize(self) -> None:
"""Initialize the LiteLLM SDK client."""
if self._initialized:
return
try:
import litellm
self._litellm = litellm # Store reference
except ImportError:
raise ImportError("litellm is required for LiteLLMSDKCrossEncoder. Install it with: pip install litellm")
api_base_msg = f" at {self.api_base}" if self.api_base else ""
logger.info(f"Reranker: initializing LiteLLM SDK provider with model {self.model}{api_base_msg}")
self._initialized = True
logger.info("Reranker: LiteLLM SDK provider initialized")
async def predict(self, pairs: list[tuple[str, str]]) -> list[float]:
"""
Score query-document pairs using the LiteLLM SDK.
Args:
pairs: List of (query, document) tuples to score
Returns:
List of relevance scores
"""
if not self._initialized:
raise RuntimeError("Reranker not initialized. Call initialize() first.")
if not pairs:
return []
# Group pairs by query for efficient batching
# LiteLLM rerank expects one query with multiple documents
query_groups: dict[str, list[tuple[int, str]]] = {}
for idx, (query, text) in enumerate(pairs):
if query not in query_groups:
query_groups[query] = []
query_groups[query].append((idx, text))
all_scores = [0.0] * len(pairs)
for query, indexed_texts in query_groups.items():
texts = [text for _, text in indexed_texts]
indices = [idx for idx, _ in indexed_texts]
# Build kwargs for rerank call
rerank_kwargs = {
"model": self.model,
"query": query,
"documents": texts,
"api_key": self.api_key,
}
if self.api_base:
rerank_kwargs["api_base"] = self.api_base
response = await self._litellm.arerank(**rerank_kwargs)
# Map scores back to original positions
# Response format: RerankResponse with results list
# Each result is a TypedDict with "index" and "relevance_score"
if hasattr(response, "results") and response.results:
for result in response.results:
# Results are TypedDicts, use dict-style access
original_idx = result["index"]
score = result.get("relevance_score", result.get("score", 0.0))
all_scores[indices[original_idx]] = score
elif isinstance(response, list):
# Direct list of scores (unlikely but defensive)
for i, score in enumerate(response):
all_scores[indices[i]] = score
else:
logger.warning(f"Unexpected response format from LiteLLM rerank: {type(response)}")
return all_scores
def create_cross_encoder_from_env() -> CrossEncoderModel:
"""
Create a CrossEncoderModel instance based on configuration.
@@ -999,20 +877,9 @@ def create_cross_encoder_from_env() -> CrossEncoderModel:
api_key=config.reranker_litellm_api_key,
model=config.reranker_litellm_model,
)
elif provider == "litellm-sdk":
api_key = config.reranker_litellm_sdk_api_key
if not api_key:
raise ValueError(
f"{ENV_RERANKER_LITELLM_SDK_API_KEY} is required when {ENV_RERANKER_PROVIDER} is 'litellm-sdk'"
)
return LiteLLMSDKCrossEncoder(
api_key=api_key,
model=config.reranker_litellm_sdk_model,
api_base=config.reranker_litellm_sdk_api_base,
)
elif provider == "rrf":
return RRFPassthroughCrossEncoder()
else:
raise ValueError(
f"Unknown reranker provider: {provider}. Supported: 'local', 'tei', 'cohere', 'flashrank', 'litellm', 'litellm-sdk', 'rrf'"
f"Unknown reranker provider: {provider}. Supported: 'local', 'tei', 'cohere', 'flashrank', 'litellm', 'rrf'"
)
@@ -19,7 +19,6 @@ import httpx
from ..config import (
DEFAULT_EMBEDDINGS_COHERE_MODEL,
DEFAULT_EMBEDDINGS_LITELLM_MODEL,
DEFAULT_EMBEDDINGS_LITELLM_SDK_MODEL,
DEFAULT_EMBEDDINGS_LOCAL_FORCE_CPU,
DEFAULT_EMBEDDINGS_LOCAL_MODEL,
DEFAULT_EMBEDDINGS_LOCAL_TRUST_REMOTE_CODE,
@@ -27,7 +26,6 @@ from ..config import (
DEFAULT_EMBEDDINGS_PROVIDER,
DEFAULT_LITELLM_API_BASE,
ENV_EMBEDDINGS_COHERE_API_KEY,
ENV_EMBEDDINGS_LITELLM_SDK_API_KEY,
ENV_EMBEDDINGS_LOCAL_FORCE_CPU,
ENV_EMBEDDINGS_LOCAL_MODEL,
ENV_EMBEDDINGS_LOCAL_TRUST_REMOTE_CODE,
@@ -722,148 +720,6 @@ class LiteLLMEmbeddings(Embeddings):
return all_embeddings
class LiteLLMSDKEmbeddings(Embeddings):
"""
LiteLLM SDK embeddings for direct API integration.
Supports embeddings via LiteLLM SDK without requiring a proxy server.
Supported providers: Cohere, OpenAI, Azure OpenAI, HuggingFace, Voyage AI, Together AI, etc.
Example model names:
- cohere/embed-english-v3.0
- openai/text-embedding-3-small
- together_ai/togethercomputer/m2-bert-80M-8k-retrieval
- voyage/voyage-2
"""
def __init__(
self,
api_key: str,
model: str = DEFAULT_EMBEDDINGS_LITELLM_SDK_MODEL,
api_base: str | None = None,
batch_size: int = 100,
timeout: float = 60.0,
):
"""
Initialize LiteLLM SDK embeddings client.
Args:
api_key: API key for the embedding provider
model: Model name with provider prefix (e.g., "cohere/embed-english-v3.0")
api_base: Custom base URL for API (optional)
batch_size: Maximum batch size for embedding requests (default: 100)
timeout: Request timeout in seconds (default: 60.0)
"""
self.api_key = api_key
self.model = model
self.api_base = api_base
self.batch_size = batch_size
self.timeout = timeout
self._litellm = None # Will be set during initialization
self._dimension: int | None = None
@property
def provider_name(self) -> str:
return "litellm-sdk"
@property
def dimension(self) -> int:
if self._dimension is None:
raise RuntimeError("Embeddings not initialized. Call initialize() first.")
return self._dimension
async def initialize(self) -> None:
"""Initialize the LiteLLM SDK client and detect dimension."""
if self._litellm is not None:
return
try:
import litellm
self._litellm = litellm # Store reference
except ImportError:
raise ImportError("litellm is required for LiteLLMSDKEmbeddings. Install it with: pip install litellm")
api_base_msg = f" at {self.api_base}" if self.api_base else ""
logger.info(f"Embeddings: initializing LiteLLM SDK provider with model {self.model}{api_base_msg}")
# Do a test embedding to detect dimension
try:
# Build kwargs for embedding call
embed_kwargs = {
"model": self.model,
"input": ["test"],
"api_key": self.api_key,
}
if self.api_base:
embed_kwargs["api_base"] = self.api_base
# Use async embedding method (standard in litellm)
response = await self._litellm.aembedding(**embed_kwargs)
# Extract dimension from response
if response.data and len(response.data) > 0:
self._dimension = len(response.data[0]["embedding"])
else:
raise RuntimeError(f"Unable to detect embedding dimension for model {self.model}")
except Exception as e:
raise RuntimeError(f"Failed to initialize LiteLLM SDK embeddings: {e}")
logger.info(f"Embeddings: LiteLLM SDK provider initialized (model: {self.model}, dim: {self._dimension})")
def encode(self, texts: list[str]) -> list[list[float]]:
"""
Generate embeddings using the LiteLLM SDK.
Args:
texts: List of text strings to encode
Returns:
List of embedding vectors (one per input text)
"""
if self._litellm is None:
raise RuntimeError("Embeddings not initialized. Call initialize() first.")
if not texts:
return []
all_embeddings = []
# Process in batches
for i in range(0, len(texts), self.batch_size):
batch = texts[i : i + self.batch_size]
try:
# Build kwargs for embedding call
embed_kwargs = {
"model": self.model,
"input": batch,
"api_key": self.api_key,
}
if self.api_base:
embed_kwargs["api_base"] = self.api_base
# Use sync embedding (litellm doesn't have async in thread-safe way)
response = self._litellm.embedding(**embed_kwargs)
# Extract embeddings from response
# Sort by index to ensure correct order
batch_embeddings = sorted(response.data, key=lambda x: x.get("index", 0))
all_embeddings.extend([e["embedding"] for e in batch_embeddings])
except Exception as e:
import traceback
logger.error(
f"Error in LiteLLM embedding for batch starting at index {i}: {e}\n"
f"Traceback: {traceback.format_exc()}"
)
raise
return all_embeddings
def create_embeddings_from_env() -> Embeddings:
"""
Create an Embeddings instance based on configuration.
@@ -915,19 +771,7 @@ def create_embeddings_from_env() -> Embeddings:
api_key=config.embeddings_litellm_api_key,
model=config.embeddings_litellm_model,
)
elif provider == "litellm-sdk":
api_key = config.embeddings_litellm_sdk_api_key
if not api_key:
raise ValueError(
f"{ENV_EMBEDDINGS_LITELLM_SDK_API_KEY} is required when {ENV_EMBEDDINGS_PROVIDER} is 'litellm-sdk'"
)
return LiteLLMSDKEmbeddings(
api_key=api_key,
model=config.embeddings_litellm_sdk_model,
api_base=config.embeddings_litellm_sdk_api_base,
)
else:
raise ValueError(
f"Unknown embeddings provider: {provider}. "
f"Supported: 'local', 'tei', 'openai', 'cohere', 'litellm', 'litellm-sdk'"
f"Unknown embeddings provider: {provider}. Supported: 'local', 'tei', 'openai', 'cohere', 'litellm'"
)
@@ -48,7 +48,6 @@ class MemoryEngineInterface(ABC):
contents: list[dict[str, Any]],
*,
request_context: "RequestContext",
document_tags: list[str] | None = None,
) -> dict[str, Any]:
"""
Retain a batch of memory items.
@@ -56,9 +55,8 @@ class MemoryEngineInterface(ABC):
Args:
bank_id: The memory bank ID.
contents: List of content dicts with 'content', optional 'event_date',
'context', 'metadata', 'document_id', and per-item 'tags'.
'context', 'metadata', 'document_id'.
request_context: Request context for authentication.
document_tags: Optional tags applied to all items in the batch.
Returns:
Dict with processing results.
@@ -563,7 +561,6 @@ class MemoryEngineInterface(ABC):
contents: list[dict[str, Any]],
*,
request_context: "RequestContext",
document_tags: list[str] | None = None,
) -> dict[str, Any]:
"""
Submit a batch retain operation to run asynchronously.
@@ -572,7 +569,6 @@ class MemoryEngineInterface(ABC):
bank_id: The memory bank ID.
contents: List of content dicts to retain.
request_context: Request context for authentication.
document_tags: Optional tags applied to all items in the async batch.
Returns:
Dict with operation_id and items_count.
@@ -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,
@@ -18,20 +18,11 @@ import uuid
from datetime import UTC, datetime, timedelta
from typing import TYPE_CHECKING, Any
import tiktoken
from ..config import get_config
from ..metrics import get_metrics_collector
from ..tracing import create_operation_span
from ..utils import mask_network_location
from .db_budget import budgeted_operation
from .operation_metadata import (
BatchRetainChildMetadata,
BatchRetainParentMetadata,
ConsolidationMetadata,
RefreshMentalModelMetadata,
RetainMetadata,
)
# Context variable for current schema (async-safe, per-task isolation)
# Note: default is None, actual default comes from config via get_current_schema()
@@ -47,15 +38,6 @@ def get_current_schema() -> str:
return schema
# Initialize tiktoken encoder once at module level for efficiency
_tiktoken_encoder = tiktoken.get_encoding("cl100k_base") # GPT-4/GPT-3.5-turbo encoding
def count_tokens(text: str) -> int:
"""Count tokens in text using tiktoken (cl100k_base encoding for GPT-4/3.5)."""
return len(_tiktoken_encoder.encode(text))
def fq_table(table_name: str) -> str:
"""
Get fully-qualified table name with current schema.
@@ -548,7 +530,7 @@ class MemoryEngine(MemoryEngineInterface):
Handler for batch retain tasks.
Args:
task_dict: Dict with 'bank_id', 'contents', 'operation_id'
task_dict: Dict with 'bank_id', 'contents'
Raises:
ValueError: If bank_id is missing
@@ -558,11 +540,9 @@ class MemoryEngine(MemoryEngineInterface):
if not bank_id:
raise ValueError("bank_id is required for batch retain task")
contents = task_dict.get("contents", [])
document_tags = task_dict.get("document_tags")
operation_id = task_dict.get("operation_id") # For batch API crash recovery
logger.info(
f"[BATCH_RETAIN_TASK] Starting background batch retain for bank_id={bank_id}, {len(contents)} items, operation_id={operation_id}"
f"[BATCH_RETAIN_TASK] Starting background batch retain for bank_id={bank_id}, {len(contents)} items"
)
# Restore tenant_id/api_key_id from task payload so extensions
@@ -577,13 +557,7 @@ class MemoryEngine(MemoryEngineInterface):
tenant_id=task_dict.get("_tenant_id"),
api_key_id=task_dict.get("_api_key_id"),
)
await self.retain_batch_async(
bank_id=bank_id,
contents=contents,
document_tags=document_tags,
request_context=context,
operation_id=operation_id,
)
await self.retain_batch_async(bank_id=bank_id, contents=contents, request_context=context)
logger.info(f"[BATCH_RETAIN_TASK] Completed background batch retain for bank_id={bank_id}")
@@ -846,11 +820,7 @@ class MemoryEngine(MemoryEngineInterface):
logger.error(f"Failed to delete async operation record {operation_id}: {e}")
async def _mark_operation_failed(self, operation_id: str, error_message: str, error_traceback: str):
"""Helper to mark an operation as failed in the database.
Also checks if this is a child operation and updates the parent if all siblings are done.
Uses a single transaction to avoid race conditions when multiple children fail simultaneously.
"""
"""Helper to mark an operation as failed in the database."""
try:
pool = await self._get_pool()
# Truncate error message to avoid extremely long strings
@@ -858,160 +828,36 @@ class MemoryEngine(MemoryEngineInterface):
truncated_error = full_error[:5000] if len(full_error) > 5000 else full_error
async with acquire_with_retry(pool) as conn:
async with conn.transaction():
# Mark this operation as failed
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = 'failed', error_message = $2, updated_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(operation_id),
truncated_error,
)
logger.info(f"Marked async operation as failed: {operation_id}")
# Check if this is a child operation and update parent if all siblings are done
# This happens in the same transaction after the child status is updated
await self._maybe_update_parent_operation(operation_id, conn)
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = 'failed', error_message = $2, updated_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(operation_id),
truncated_error,
)
logger.info(f"Marked async operation as failed: {operation_id}")
except Exception as e:
logger.error(f"Failed to mark operation as failed {operation_id}: {e}")
async def _mark_operation_completed(self, operation_id: str):
"""Helper to mark an operation as completed in the database.
Also checks if this is a child operation and updates the parent if all siblings are done.
Uses a single transaction to avoid race conditions when multiple children complete simultaneously.
"""
"""Helper to mark an operation as completed in the database."""
try:
pool = await self._get_pool()
async with acquire_with_retry(pool) as conn:
async with conn.transaction():
# Mark this operation as completed
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = 'completed', updated_at = NOW(), completed_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(operation_id),
)
logger.info(f"Marked async operation as completed: {operation_id}")
# Check if this is a child operation and update parent if all siblings are done
# This happens in the same transaction after the child status is updated
await self._maybe_update_parent_operation(operation_id, conn)
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = 'completed', updated_at = NOW(), completed_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(operation_id),
)
logger.info(f"Marked async operation as completed: {operation_id}")
except Exception as e:
logger.error(f"Failed to mark operation as completed {operation_id}: {e}")
async def _maybe_update_parent_operation(self, child_operation_id: str, conn):
"""Check if this is a child operation and update parent status if all siblings are done.
Must be called within an active transaction that has already updated the child's status.
Uses SELECT FOR UPDATE to lock the parent and prevent race conditions.
Args:
child_operation_id: The operation ID that just completed or failed
conn: Database connection with an active transaction
"""
try:
# Get this operation's metadata to check if it has a parent
row = await conn.fetchrow(
f"""
SELECT result_metadata, bank_id
FROM {fq_table("async_operations")}
WHERE operation_id = $1
""",
uuid.UUID(child_operation_id),
)
if not row:
return
result_metadata = json.loads(row["result_metadata"]) if row["result_metadata"] else {}
parent_operation_id = result_metadata.get("parent_operation_id")
if not parent_operation_id:
# Not a child operation
return
bank_id = row["bank_id"]
# Lock the parent operation to prevent concurrent updates from other children
# Use FOR UPDATE to ensure only one child can update the parent at a time
parent_row = await conn.fetchrow(
f"""
SELECT operation_id
FROM {fq_table("async_operations")}
WHERE operation_id = $1 AND bank_id = $2
FOR UPDATE
""",
uuid.UUID(parent_operation_id),
bank_id,
)
if not parent_row:
# Parent doesn't exist (shouldn't happen)
return
# Get all sibling operations (including this one)
# This query runs in the same transaction, so it sees the current child's updated status
siblings = await conn.fetch(
f"""
SELECT status
FROM {fq_table("async_operations")}
WHERE bank_id = $1
AND result_metadata::jsonb @> $2::jsonb
""",
bank_id,
json.dumps({"parent_operation_id": parent_operation_id}),
)
if not siblings:
return
# Check if all siblings are done (completed or failed)
all_completed = all(sib["status"] == "completed" for sib in siblings)
any_failed = any(sib["status"] == "failed" for sib in siblings)
all_done = all(sib["status"] in ("completed", "failed") for sib in siblings)
if not all_done:
# Some siblings still pending/processing
return
# All siblings are done - update parent status
if any_failed:
new_status = "failed"
# Set parent error message to indicate child failure
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = $2, error_message = $3, updated_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(parent_operation_id),
new_status,
"One or more sub-batches failed",
)
elif all_completed:
new_status = "completed"
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = $2, updated_at = NOW(), completed_at = NOW()
WHERE operation_id = $1
""",
uuid.UUID(parent_operation_id),
new_status,
)
logger.info(f"Updated parent operation {parent_operation_id} to status '{new_status}' (all children done)")
except Exception as e:
logger.error(f"Failed to update parent operation for child {child_operation_id}: {e}")
# Re-raise to rollback the transaction
raise
async def initialize(self):
"""Initialize the connection pool, models, and background workers.
@@ -1498,7 +1344,6 @@ class MemoryEngine(MemoryEngineInterface):
confidence_score: float | None = None,
document_tags: list[str] | None = None,
return_usage: bool = False,
operation_id: str | None = None,
):
"""
Store multiple content items as memory units in ONE batch operation.
@@ -1579,49 +1424,35 @@ class MemoryEngine(MemoryEngineInterface):
if "document_id" not in item:
item["document_id"] = document_id
# Validate no duplicate document_ids in the batch
# Having duplicate document_ids causes race conditions in document upserts during parallel processing
doc_ids = [item.get("document_id") for item in contents if item.get("document_id")]
if len(doc_ids) != len(set(doc_ids)):
from collections import Counter
duplicates = [doc_id for doc_id, count in Counter(doc_ids).items() if count > 1]
raise ValueError(
f"Batch contains duplicate document_ids: {duplicates}. "
f"Each content item in a batch must have a unique document_id to avoid race conditions."
)
# Auto-chunk large batches by token count to avoid timeouts and memory issues
# Calculate total token count
total_tokens = sum(count_tokens(item.get("content", "")) for item in contents)
# Auto-chunk large batches by character count to avoid timeouts and memory issues
# Calculate total character count
total_chars = sum(len(item.get("content", "")) for item in contents)
total_usage = TokenUsage()
# Get batch size threshold from config
config = get_config()
tokens_per_batch = config.retain_batch_tokens
CHARS_PER_BATCH = 600_000
if total_tokens > tokens_per_batch:
# Split into smaller batches based on token count
if total_chars > CHARS_PER_BATCH:
# Split into smaller batches based on character count
logger.info(
f"Large batch detected ({total_tokens:,} tokens from {len(contents)} items). Splitting into sub-batches of ~{tokens_per_batch:,} tokens each..."
f"Large batch detected ({total_chars:,} chars from {len(contents)} items). Splitting into sub-batches of ~{CHARS_PER_BATCH:,} chars each..."
)
sub_batches = []
current_batch = []
current_batch_tokens = 0
current_batch_chars = 0
for item in contents:
item_tokens = count_tokens(item.get("content", ""))
item_chars = len(item.get("content", ""))
# If adding this item would exceed the limit, start a new batch
# (unless current batch is empty - then we must include it even if it's large)
if current_batch and current_batch_tokens + item_tokens > tokens_per_batch:
if current_batch and current_batch_chars + item_chars > CHARS_PER_BATCH:
sub_batches.append(current_batch)
current_batch = [item]
current_batch_tokens = item_tokens
current_batch_chars = item_chars
else:
current_batch.append(item)
current_batch_tokens += item_tokens
current_batch_chars += item_chars
# Add the last batch
if current_batch:
@@ -1632,9 +1463,9 @@ class MemoryEngine(MemoryEngineInterface):
# Process each sub-batch
all_results = []
for i, sub_batch in enumerate(sub_batches, 1):
sub_batch_tokens = sum(count_tokens(item.get("content", "")) for item in sub_batch)
sub_batch_chars = sum(len(item.get("content", "")) for item in sub_batch)
logger.info(
f"Processing sub-batch {i}/{len(sub_batches)}: {len(sub_batch)} items, {sub_batch_tokens:,} tokens"
f"Processing sub-batch {i}/{len(sub_batches)}: {len(sub_batch)} items, {sub_batch_chars:,} chars"
)
sub_results, sub_usage = await self._retain_batch_async_internal(
@@ -1646,7 +1477,6 @@ class MemoryEngine(MemoryEngineInterface):
fact_type_override=fact_type_override,
confidence_score=confidence_score,
document_tags=document_tags,
operation_id=operation_id,
)
all_results.extend(sub_results)
total_usage = total_usage + sub_usage
@@ -1667,7 +1497,6 @@ class MemoryEngine(MemoryEngineInterface):
fact_type_override=fact_type_override,
confidence_score=confidence_score,
document_tags=document_tags,
operation_id=operation_id,
)
# Call post-operation hook if validator is configured
@@ -1717,7 +1546,6 @@ class MemoryEngine(MemoryEngineInterface):
fact_type_override: str | None = None,
confidence_score: float | None = None,
document_tags: list[str] | None = None,
operation_id: str | None = None,
) -> tuple[list[list[str]], "TokenUsage"]:
"""
Internal method for batch processing without chunking logic.
@@ -1767,8 +1595,6 @@ class MemoryEngine(MemoryEngineInterface):
confidence_score=confidence_score,
document_tags=document_tags,
config=resolved_config,
operation_id=operation_id,
schema=request_context.tenant_id if request_context else None,
)
def recall(
@@ -1856,21 +1682,15 @@ class MemoryEngine(MemoryEngineInterface):
max_entity_tokens: Maximum tokens for entity observations (default 500)
include_chunks: Whether to include raw chunks in the response
max_chunk_tokens: Maximum tokens for chunks (default 8192)
NOTE: Chunks are fetched independently of max_tokens filtering.
This means setting max_tokens=0 will return 0 facts but can still
return chunks from the top-scored (reranked) results.
Chunks are fetched in batches (estimated as (max_chunk_tokens // retain_chunk_size) * 2)
until the token budget is exhausted or all chunks are fetched.
This handles varying chunk sizes across documents.
tags: Optional list of tags for visibility filtering (OR matching - returns
memories that have at least one matching tag)
Returns:
RecallResultModel containing:
- results: List of MemoryFact objects (filtered by max_tokens)
- results: List of MemoryFact objects
- trace: Optional trace information for debugging
- entities: Optional dict of entity states (if include_entities=True)
- chunks: Optional dict of chunks (if include_chunks=True, independent of max_tokens)
- chunks: Optional dict of chunks (if include_chunks=True)
"""
# Authenticate tenant and set schema in context (for fq_table())
await self._authenticate_tenant(request_context)
@@ -2098,8 +1918,7 @@ class MemoryEngine(MemoryEngineInterface):
2. Merge: RRF to combine ranked lists
3. Reranking: Pluggable strategy (heuristic or cross-encoder)
4. Diversity: MMR with λ=0.5
5. Chunks: Fetch chunks from top-scored results (BEFORE token filtering)
6. Token Filter: Limit facts to max_tokens budget
5. Token Filter: Limit results to max_tokens budget
Args:
bank_id: bank IDentifier
@@ -2110,7 +1929,7 @@ class MemoryEngine(MemoryEngineInterface):
enable_trace: Whether to return search trace (deprecated)
include_entities: Whether to include entity observations
max_entity_tokens: Maximum tokens for entity observations
include_chunks: Whether to include raw chunks (fetched before max_tokens filtering)
include_chunks: Whether to include raw chunks
max_chunk_tokens: Maximum tokens for chunks
Returns:
@@ -2533,85 +2352,6 @@ class MemoryEngine(MemoryEngineInterface):
top_scored = scored_results[:rerank_limit]
log_buffer.append(f" [5] Truncated to top {len(top_scored)} results")
# Step 5.5: Fetch chunks from top-scored results (before token filtering)
# Chunks are fetched independently of max_tokens filtering
chunks_dict = None
total_chunk_tokens = 0
if include_chunks and top_scored:
from .response_models import ChunkInfo
# Collect chunk_ids in order of fact relevance (preserving order from top_scored)
# Use a list to maintain order, but track seen chunks to avoid duplicates
chunk_ids_ordered = []
seen_chunk_ids = set()
for sr in top_scored:
chunk_id = sr.retrieval.chunk_id
if chunk_id and chunk_id not in seen_chunk_ids:
chunk_ids_ordered.append(chunk_id)
seen_chunk_ids.add(chunk_id)
if chunk_ids_ordered:
# Estimate batch size based on retain_chunk_size * 2 (rough estimate)
# Chunk sizes vary per document, so we fetch in batches until budget is exhausted
bank_config = await self._config_resolver.resolve_full_config(bank_id, request_context)
estimated_batch_size = max(1, (max_chunk_tokens // bank_config.retain_chunk_size) * 2)
chunks_dict = {}
encoding = _get_tiktoken_encoding()
chunk_offset = 0
# Fetch chunks in batches until we run out of budget or chunks
while chunk_offset < len(chunk_ids_ordered) and total_chunk_tokens < max_chunk_tokens:
# Get next batch of chunk IDs
batch_chunk_ids = chunk_ids_ordered[chunk_offset : chunk_offset + estimated_batch_size]
chunk_offset += estimated_batch_size
# Fetch chunk data from database
async with acquire_with_retry(pool) as conn:
chunks_rows = await conn.fetch(
f"""
SELECT chunk_id, chunk_text, chunk_index
FROM {fq_table("chunks")}
WHERE chunk_id = ANY($1::text[])
""",
batch_chunk_ids,
)
# Create a lookup dict for fast access (preserves order from batch_chunk_ids)
chunks_lookup = {row["chunk_id"]: row for row in chunks_rows}
# Process chunks in order, respecting token budget
for chunk_id in batch_chunk_ids:
if chunk_id not in chunks_lookup:
continue
row = chunks_lookup[chunk_id]
chunk_text = row["chunk_text"]
chunk_tokens = len(encoding.encode(chunk_text))
# Check if adding this chunk would exceed the limit
if total_chunk_tokens + chunk_tokens > max_chunk_tokens:
# Truncate the chunk to fit within the remaining budget
remaining_tokens = max_chunk_tokens - total_chunk_tokens
if remaining_tokens > 0:
# Truncate to remaining tokens
truncated_text = encoding.decode(encoding.encode(chunk_text)[:remaining_tokens])
chunks_dict[chunk_id] = ChunkInfo(
chunk_text=truncated_text, chunk_index=row["chunk_index"], truncated=True
)
total_chunk_tokens = max_chunk_tokens
# Budget exhausted - stop fetching more batches
break
else:
chunks_dict[chunk_id] = ChunkInfo(
chunk_text=chunk_text, chunk_index=row["chunk_index"], truncated=False
)
total_chunk_tokens += chunk_tokens
# If we hit the budget limit in this batch, stop fetching more batches
if total_chunk_tokens >= max_chunk_tokens:
break
# Step 6: Token budget filtering
step_start = time.time()
@@ -2706,6 +2446,68 @@ class MemoryEngine(MemoryEngineInterface):
# Entity observations removed - always set to None
entities_dict = None
# Fetch chunks if requested
chunks_dict = None
total_chunk_tokens = 0
if include_chunks and top_scored:
from .response_models import ChunkInfo
# Collect chunk_ids in order of fact relevance (preserving order from top_scored)
# Use a list to maintain order, but track seen chunks to avoid duplicates
chunk_ids_ordered = []
seen_chunk_ids = set()
for sr in top_scored:
chunk_id = sr.retrieval.chunk_id
if chunk_id and chunk_id not in seen_chunk_ids:
chunk_ids_ordered.append(chunk_id)
seen_chunk_ids.add(chunk_id)
if chunk_ids_ordered:
# Fetch chunk data from database using chunk_ids (no ORDER BY to preserve input order)
async with acquire_with_retry(pool) as conn:
chunks_rows = await conn.fetch(
f"""
SELECT chunk_id, chunk_text, chunk_index
FROM {fq_table("chunks")}
WHERE chunk_id = ANY($1::text[])
""",
chunk_ids_ordered,
)
# Create a lookup dict for fast access
chunks_lookup = {row["chunk_id"]: row for row in chunks_rows}
# Apply token limit and build chunks_dict in the order of chunk_ids_ordered
chunks_dict = {}
encoding = _get_tiktoken_encoding()
for chunk_id in chunk_ids_ordered:
if chunk_id not in chunks_lookup:
continue
row = chunks_lookup[chunk_id]
chunk_text = row["chunk_text"]
chunk_tokens = len(encoding.encode(chunk_text))
# Check if adding this chunk would exceed the limit
if total_chunk_tokens + chunk_tokens > max_chunk_tokens:
# Truncate the chunk to fit within the remaining budget
remaining_tokens = max_chunk_tokens - total_chunk_tokens
if remaining_tokens > 0:
# Truncate to remaining tokens
truncated_text = encoding.decode(encoding.encode(chunk_text)[:remaining_tokens])
chunks_dict[chunk_id] = ChunkInfo(
chunk_text=truncated_text, chunk_index=row["chunk_index"], truncated=True
)
total_chunk_tokens = max_chunk_tokens
# Stop adding more chunks once we hit the limit
break
else:
chunks_dict[chunk_id] = ChunkInfo(
chunk_text=chunk_text, chunk_index=row["chunk_index"], truncated=False
)
total_chunk_tokens += chunk_tokens
# Finalize trace if enabled
trace_dict = None
if tracer:
@@ -5631,10 +5433,10 @@ class MemoryEngine(MemoryEngineInterface):
)
total = total_row["total"] if total_row else 0
# Get operations with pagination (include result_metadata to check for parent operations)
# Get operations with pagination
operations = await conn.fetch(
f"""
SELECT operation_id, operation_type, created_at, status, error_message, result_metadata
SELECT operation_id, operation_type, created_at, status, error_message
FROM {fq_table("async_operations")}
WHERE {where_clause}
ORDER BY created_at DESC
@@ -5645,29 +5447,21 @@ class MemoryEngine(MemoryEngineInterface):
offset,
)
# Build operation list using status from database
# Parent operations have their status updated when all children complete/fail
operation_list = []
for row in operations:
# Map DB status to API status (pending includes processing)
db_status = row["status"]
api_status = "pending" if db_status in ("pending", "processing") else db_status
operation_list.append(
return {
"total": total,
"operations": [
{
"id": str(row["operation_id"]),
"task_type": row["operation_type"],
"items_count": 0,
"document_id": None,
"created_at": row["created_at"].isoformat(),
"status": api_status,
# Map DB status to API status (processing -> pending for simplicity)
"status": "pending" if row["status"] in ("pending", "processing") else row["status"],
"error_message": row["error_message"],
}
)
return {
"total": total,
"operations": operation_list,
for row in operations
],
}
async def get_operation_status(
@@ -5679,13 +5473,10 @@ class MemoryEngine(MemoryEngineInterface):
) -> dict[str, Any]:
"""Get the status of a specific async operation.
For parent operations, the status is automatically updated in the database when all children complete/fail.
Returns:
- status: "pending", "completed", or "failed" (from database)
- status: "pending", "completed", or "failed"
- updated_at: last update timestamp
- completed_at: completion timestamp (if completed)
- child_operations: (for parent operations) list of child operation statuses
"""
await self._authenticate_tenant(request_context)
pool = await self._get_pool()
@@ -5695,7 +5486,7 @@ class MemoryEngine(MemoryEngineInterface):
async with acquire_with_retry(pool) as conn:
row = await conn.fetchrow(
f"""
SELECT operation_id, operation_type, created_at, updated_at, completed_at, status, error_message, result_metadata
SELECT operation_id, operation_type, created_at, updated_at, completed_at, status, error_message
FROM {fq_table("async_operations")}
WHERE operation_id = $1 AND bank_id = $2
""",
@@ -5704,98 +5495,18 @@ class MemoryEngine(MemoryEngineInterface):
)
if row:
# Check if this is a parent operation
result_metadata = json.loads(row["result_metadata"]) if row["result_metadata"] else {}
is_parent = result_metadata.get("is_parent", False)
# Use status from database (parent status is updated when all children complete/fail)
# Map DB status to API status (processing -> pending for simplicity)
db_status = row["status"]
api_status = "pending" if db_status in ("pending", "processing") else db_status
# For parent operations, include child operations list
if is_parent:
# Query child operations
child_rows = await conn.fetch(
f"""
SELECT operation_id, status, error_message, result_metadata
FROM {fq_table("async_operations")}
WHERE bank_id = $1
AND result_metadata::jsonb @> $2::jsonb
ORDER BY (result_metadata->>'sub_batch_index')::int
""",
bank_id,
json.dumps({"parent_operation_id": operation_id}),
)
# Build child operations list and check if parent status needs updating
child_statuses = []
all_done = True
any_failed = False
all_completed = True
for child_row in child_rows:
child_metadata = (
json.loads(child_row["result_metadata"]) if child_row["result_metadata"] else {}
)
child_status = child_row["status"]
child_statuses.append(
{
"operation_id": str(child_row["operation_id"]),
"status": child_status,
"sub_batch_index": child_metadata.get("sub_batch_index"),
"items_count": child_metadata.get("items_count"),
"error_message": child_row["error_message"],
}
)
if child_status not in ("completed", "failed"):
all_done = False
if child_status == "failed":
any_failed = True
if child_status != "completed":
all_completed = False
# Self-healing: if parent status is out of sync with children, update it
if all_done and api_status == "pending":
correct_status = "failed" if any_failed else "completed"
logger.warning(
f"Parent operation {operation_id} status out of sync (DB: pending, should be: {correct_status}). Fixing."
)
await conn.execute(
f"""
UPDATE {fq_table("async_operations")}
SET status = $2, updated_at = NOW(), completed_at = NOW()
WHERE operation_id = $1
""",
op_uuid,
correct_status,
)
api_status = correct_status
return {
"operation_id": operation_id,
"status": api_status,
"operation_type": row["operation_type"],
"created_at": row["created_at"].isoformat() if row["created_at"] else None,
"updated_at": row["updated_at"].isoformat() if row["updated_at"] else None,
"completed_at": row["completed_at"].isoformat() if row["completed_at"] else None,
"error_message": row["error_message"],
"result_metadata": result_metadata,
"child_operations": child_statuses,
}
else:
# Regular operation (not a parent)
return {
"operation_id": operation_id,
"status": api_status,
"operation_type": row["operation_type"],
"created_at": row["created_at"].isoformat() if row["created_at"] else None,
"updated_at": row["updated_at"].isoformat() if row["updated_at"] else None,
"completed_at": row["completed_at"].isoformat() if row["completed_at"] else None,
"error_message": row["error_message"],
"result_metadata": result_metadata,
}
return {
"operation_id": operation_id,
"status": api_status,
"operation_type": row["operation_type"],
"created_at": row["created_at"].isoformat() if row["created_at"] else None,
"updated_at": row["updated_at"].isoformat() if row["updated_at"] else None,
"completed_at": row["completed_at"].isoformat() if row["completed_at"] else None,
"error_message": row["error_message"],
}
else:
# Operation not found
return {
@@ -5971,126 +5682,31 @@ class MemoryEngine(MemoryEngineInterface):
request_context: "RequestContext",
document_tags: list[str] | None = None,
) -> dict[str, Any]:
"""Submit a batch retain operation to run asynchronously.
For large batches (exceeding retain_batch_chars threshold), automatically splits
into smaller sub-batches and creates a parent operation that tracks all children.
"""
"""Submit a batch retain operation to run asynchronously."""
await self._authenticate_tenant(request_context)
# Validate no duplicate document_ids in the batch
# Having duplicate document_ids causes race conditions in document upserts during parallel processing
doc_ids = [item.get("document_id") for item in contents if item.get("document_id")]
if len(doc_ids) != len(set(doc_ids)):
from collections import Counter
task_payload: dict[str, Any] = {"contents": contents}
if document_tags:
task_payload["document_tags"] = document_tags
# Pass tenant_id and api_key_id through task payload so the worker
# can propagate request context to downstream operations (e.g.,
# consolidation and mental model refreshes triggered after retain).
if request_context.tenant_id:
task_payload["_tenant_id"] = request_context.tenant_id
if request_context.api_key_id:
task_payload["_api_key_id"] = request_context.api_key_id
duplicates = [doc_id for doc_id, count in Counter(doc_ids).items() if count > 1]
raise ValueError(
f"Batch contains duplicate document_ids: {duplicates}. "
f"Each content item in a batch must have a unique document_id to avoid race conditions."
)
# Calculate total token count and determine if we need to split
total_tokens = sum(count_tokens(item.get("content", "")) for item in contents)
config = get_config()
tokens_per_batch = config.retain_batch_tokens
# Split into sub-batches based on token count
sub_batches = []
current_batch = []
current_batch_tokens = 0
for item in contents:
item_tokens = count_tokens(item.get("content", ""))
# If adding this item would exceed the limit, start a new batch
# (unless current batch is empty - then we must include it even if it's large)
if current_batch and current_batch_tokens + item_tokens > tokens_per_batch:
sub_batches.append(current_batch)
current_batch = [item]
current_batch_tokens = item_tokens
else:
current_batch.append(item)
current_batch_tokens += item_tokens
# Add the last batch
if current_batch:
sub_batches.append(current_batch)
# Log splitting info if we actually split
if len(sub_batches) > 1:
logger.info(
f"Large async retain batch ({total_tokens:,} tokens from {len(contents)} items). "
f"Split into {len(sub_batches)} sub-batches: {[len(b) for b in sub_batches]} items each"
)
# Always create parent operation (even for single batch - simpler, more reliable code path)
import uuid
parent_operation_id = uuid.uuid4()
pool = await self._get_pool()
# Create typed metadata for parent operation
parent_metadata = BatchRetainParentMetadata(
items_count=len(contents),
total_tokens=total_tokens,
num_sub_batches=len(sub_batches),
result = await self._submit_async_operation(
bank_id=bank_id,
operation_type="retain",
task_type="batch_retain",
task_payload=task_payload,
result_metadata={"items_count": len(contents)},
dedupe_by_bank=False,
)
async with acquire_with_retry(pool) as conn:
await conn.execute(
f"""
INSERT INTO {fq_table("async_operations")} (operation_id, bank_id, operation_type, result_metadata, status)
VALUES ($1, $2, $3, $4, $5)
""",
parent_operation_id,
bank_id,
"batch_retain",
json.dumps(parent_metadata.to_dict()),
"pending", # Will be updated by status aggregation
)
logger.info(f"Created parent operation {parent_operation_id} for {len(sub_batches)} sub-batch(es)")
# Submit child operations for each sub-batch
for i, sub_batch in enumerate(sub_batches, 1):
if len(sub_batches) > 1:
sub_batch_tokens = sum(count_tokens(item.get("content", "")) for item in sub_batch)
logger.info(
f"Submitting sub-batch {i}/{len(sub_batches)}: {len(sub_batch)} items, {sub_batch_tokens:,} tokens"
)
task_payload: dict[str, Any] = {"contents": sub_batch}
if document_tags:
task_payload["document_tags"] = document_tags
# Pass tenant_id and api_key_id through task payload
if request_context.tenant_id:
task_payload["_tenant_id"] = request_context.tenant_id
if request_context.api_key_id:
task_payload["_api_key_id"] = request_context.api_key_id
# Create typed metadata for child operation
child_metadata = BatchRetainChildMetadata(
items_count=len(sub_batch),
parent_operation_id=str(parent_operation_id),
sub_batch_index=i,
total_sub_batches=len(sub_batches),
)
# Create child operation with reference to parent
await self._submit_async_operation(
bank_id=bank_id,
operation_type="retain",
task_type="batch_retain",
task_payload=task_payload,
result_metadata=child_metadata.to_dict(),
dedupe_by_bank=False,
)
return {
"operation_id": str(parent_operation_id),
"items_count": len(contents),
}
result["items_count"] = len(contents)
return result
async def submit_async_consolidation(
self,
@@ -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)
@@ -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:
@@ -97,9 +97,8 @@ async def insert_facts_batch(
FROM input_data
RETURNING id
"""
else: # native or pg_textsearch
else: # native
# Native PostgreSQL: search_vector is GENERATED ALWAYS, don't include it
# pg_textsearch: indexes operate on base columns directly, don't populate search_vector
query = f"""
WITH input_data AS (
SELECT * FROM unnest(
@@ -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"
@@ -164,74 +164,99 @@ async def retrieve_semantic_bm25_combined(
# Build tags clause - param 6 if tags provided
tags_clause = build_tags_where_clause_simple(tags, 6, match=tags_match)
# Build backend-specific BM25 parts
if config.text_search_extension == "vchord":
# VectorChord BM25: use <&> operator with to_bm25query and tokenize
# Note: VectorChord scores are negative (higher = better, so -1 > -10)
bm25_score_expr = "search_vector <&> to_bm25query('idx_memory_units_text_search', tokenize($5, 'llmlingua2'))"
bm25_order_by = f"{bm25_score_expr} DESC"
bm25_where_filter = "" # No additional WHERE filter for vchord
params = [query_emb_str, bank_id, fact_types, limit, query_text] # Pass raw query_text for tokenization
elif config.text_search_extension == "pg_textsearch":
# Timescale pg_textsearch: use <@> operator with to_bm25query
# Note: pg_textsearch scores are negative (lower/more negative = better, so -10 > -1)
# We negate the score to maintain API consistency (higher = better)
bm25_score_expr = "-(text <@> to_bm25query($5, 'idx_memory_units_text_search'))"
bm25_order_by = "text <@> to_bm25query($5, 'idx_memory_units_text_search') ASC"
bm25_where_filter = "" # No additional WHERE filter for pg_textsearch
params = [query_emb_str, bank_id, fact_types, limit, query_text]
if tags:
params.append(tags)
query = f"""
WITH semantic_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
1 - (embedding <=> $1::vector) AS similarity,
NULL::float AS bm25_score,
'semantic' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY embedding <=> $1::vector) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND embedding IS NOT NULL
AND fact_type = ANY($3)
AND (1 - (embedding <=> $1::vector)) >= 0.3
{tags_clause}
),
bm25_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
NULL::float AS similarity,
search_vector <&> to_bm25query('idx_memory_units_text_search', tokenize($5, 'llmlingua2')) AS bm25_score,
'bm25' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY search_vector <&> to_bm25query('idx_memory_units_text_search', tokenize($5, 'llmlingua2')) DESC) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND fact_type = ANY($3)
{tags_clause}
),
semantic AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM semantic_ranked WHERE rn <= $4
),
bm25 AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM bm25_ranked WHERE rn <= $4
)
SELECT * FROM semantic
UNION ALL
SELECT * FROM bm25
"""
else: # native
# Native PostgreSQL: use ts_rank_cd with to_tsquery
query_tsquery = " | ".join(tokens)
bm25_score_expr = "ts_rank_cd(search_vector, to_tsquery('english', $5))"
bm25_order_by = f"{bm25_score_expr} DESC"
bm25_where_filter = "AND search_vector @@ to_tsquery('english', $5)"
params = [query_emb_str, bank_id, fact_types, limit, query_tsquery]
if tags:
params.append(tags)
if tags:
params.append(tags)
# Single query template with backend-specific parts injected
query = f"""
WITH semantic_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
1 - (embedding <=> $1::vector) AS similarity,
NULL::float AS bm25_score,
'semantic' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY embedding <=> $1::vector) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND embedding IS NOT NULL
AND fact_type = ANY($3)
AND (1 - (embedding <=> $1::vector)) >= 0.3
{tags_clause}
),
bm25_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
NULL::float AS similarity,
{bm25_score_expr} AS bm25_score,
'bm25' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY {bm25_order_by}) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND fact_type = ANY($3)
{bm25_where_filter}
{tags_clause}
),
semantic AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM semantic_ranked WHERE rn <= $4
),
bm25 AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM bm25_ranked WHERE rn <= $4
)
SELECT * FROM semantic
UNION ALL
SELECT * FROM bm25
"""
query = f"""
WITH semantic_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
1 - (embedding <=> $1::vector) AS similarity,
NULL::float AS bm25_score,
'semantic' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY embedding <=> $1::vector) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND embedding IS NOT NULL
AND fact_type = ANY($3)
AND (1 - (embedding <=> $1::vector)) >= 0.3
{tags_clause}
),
bm25_ranked AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
NULL::float AS similarity,
ts_rank_cd(search_vector, to_tsquery('english', $5)) AS bm25_score,
'bm25' AS source,
ROW_NUMBER() OVER (PARTITION BY fact_type ORDER BY ts_rank_cd(search_vector, to_tsquery('english', $5)) DESC) AS rn
FROM {fq_table("memory_units")}
WHERE bank_id = $2
AND fact_type = ANY($3)
AND search_vector @@ to_tsquery('english', $5)
{tags_clause}
),
semantic AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM semantic_ranked WHERE rn <= $4
),
bm25 AS (
SELECT id, text, context, event_date, occurred_start, occurred_end, mentioned_at, embedding, fact_type, document_id, chunk_id, tags,
similarity, bm25_score, source
FROM bm25_ranked WHERE rn <= $4
)
SELECT * FROM semantic
UNION ALL
SELECT * FROM bm25
"""
# Combined CTE query for both semantic and BM25 across all fact types
# Uses window functions to limit per fact_type per method
-13
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,
@@ -210,9 +208,6 @@ def main():
embeddings_litellm_api_base=config.embeddings_litellm_api_base,
embeddings_litellm_api_key=config.embeddings_litellm_api_key,
embeddings_litellm_model=config.embeddings_litellm_model,
embeddings_litellm_sdk_api_key=config.embeddings_litellm_sdk_api_key,
embeddings_litellm_sdk_model=config.embeddings_litellm_sdk_model,
embeddings_litellm_sdk_api_base=config.embeddings_litellm_sdk_api_base,
reranker_provider=config.reranker_provider,
reranker_local_model=config.reranker_local_model,
reranker_local_force_cpu=config.reranker_local_force_cpu,
@@ -228,9 +223,6 @@ def main():
reranker_litellm_api_base=config.reranker_litellm_api_base,
reranker_litellm_api_key=config.reranker_litellm_api_key,
reranker_litellm_model=config.reranker_litellm_model,
reranker_litellm_sdk_api_key=config.reranker_litellm_sdk_api_key,
reranker_litellm_sdk_model=config.reranker_litellm_sdk_model,
reranker_litellm_sdk_api_base=config.reranker_litellm_sdk_api_base,
host=args.host,
port=args.port,
base_path=config.base_path,
@@ -247,9 +239,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,
enable_observations=config.enable_observations,
consolidation_batch_size=config.consolidation_batch_size,
consolidation_max_tokens=config.consolidation_max_tokens,
@@ -379,8 +368,6 @@ def main():
reranker_provider=config.reranker_provider,
mcp_enabled=config.mcp_enabled,
version=__version__,
vector_extension=config.vector_extension,
text_search_extension=config.text_search_extension,
)
# Start idle checker in daemon mode
+11 -138
View File
@@ -35,38 +35,20 @@ MIGRATION_LOCK_ID = 123456789
def _detect_vector_extension(conn, vector_extension: str = "pgvector") -> str:
"""
Validate vector extension: 'pgvector', 'vchord', or 'pgvectorscale'.
Validate vector extension: 'vchord' or 'pgvector'.
Args:
conn: SQLAlchemy connection object
vector_extension: Configured extension ("pgvector", "vchord", or "pgvectorscale")
vector_extension: Configured extension ("pgvector" or "vchord")
Returns:
"pgvector", "vchord", or "pgvectorscale"
"vchord" or "pgvector"
Raises:
RuntimeError: If configured extension is not installed
"""
# Verify the configured extension is installed
if vector_extension == "pgvectorscale":
# 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(
"pgvectorscale requires pgvector to be installed. "
"Install it with: CREATE EXTENSION vector; CREATE EXTENSION vectorscale CASCADE;"
)
# Check for vectorscale extension
vectorscale_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")).scalar()
if not vectorscale_check:
raise RuntimeError(
"Configured vector extension 'pgvectorscale' not found. "
"Install it with: CREATE EXTENSION vectorscale CASCADE;"
)
logger.debug("Using configured vector extension: pgvectorscale (DiskANN)")
return "pgvectorscale"
elif vector_extension == "vchord":
if vector_extension == "vchord":
vchord_check = conn.execute(text("SELECT 1 FROM pg_extension WHERE extname = 'vchord'")).scalar()
if not vchord_check:
raise RuntimeError(
@@ -83,9 +65,7 @@ def _detect_vector_extension(conn, vector_extension: str = "pgvector") -> str:
logger.debug("Using configured vector extension: pgvector")
return "pgvector"
else:
raise ValueError(
f"Invalid vector_extension: {vector_extension}. Must be 'pgvector', 'vchord', or 'pgvectorscale'"
)
raise ValueError(f"Invalid vector_extension: {vector_extension}. Must be 'pgvector' or 'vchord'")
def _get_schema_lock_id(schema: str) -> int:
@@ -297,48 +277,6 @@ def run_migrations(
"Please install it with: CREATE EXTENSION vector;"
) from e
# If using pgvectorscale, ensure vectorscale extension is also installed
vector_extension = os.getenv("HINDSIGHT_API_VECTOR_EXTENSION", "pgvector").lower()
if vector_extension == "pgvectorscale":
logger.debug("Checking pgvectorscale (vectorscale) extension availability...")
vectorscale_check = conn.execute(
text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")
).scalar()
if vectorscale_check:
logger.info("pgvectorscale extension already installed")
else:
# Extension doesn't exist - try to install
logger.info("pgvectorscale extension not found, attempting to install...")
try:
conn.execute(text("CREATE EXTENSION vectorscale CASCADE"))
conn.commit()
logger.info("pgvectorscale extension installed successfully")
except Exception as e:
# Installation failed - check one more time in case another process installed it
conn.rollback()
vectorscale_recheck = conn.execute(
text("SELECT 1 FROM pg_extension WHERE extname = 'vectorscale'")
).fetchone()
if vectorscale_recheck:
logger.warning(
"Could not install pgvectorscale extension (permission denied?), "
"but extension exists. Continuing..."
)
else:
# Extension truly doesn't exist and we can't install it
logger.error(
f"pgvectorscale extension is not installed and cannot be installed: {e}. "
f"Please ensure pgvectorscale is installed by a database administrator. "
f"See: https://github.com/timescale/pgvectorscale#installation"
)
raise RuntimeError(
"pgvectorscale extension is required but not installed. "
"Please install it with: CREATE EXTENSION vectorscale CASCADE;"
) from e
# Run migrations while holding the lock
_run_migrations_internal(database_url, script_location, schema=schema)
finally:
@@ -537,17 +475,7 @@ def ensure_embedding_dimension(
conn.commit()
# Recreate index with appropriate type based on detected extension
if vector_ext == "pgvectorscale":
conn.execute(
text(f"""
CREATE INDEX IF NOT EXISTS idx_memory_units_embedding_diskann
ON {schema_name}.memory_units
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
)
logger.info(f"Created DiskANN index for {required_dimension}-dimensional embeddings")
elif vector_ext == "vchord":
if vector_ext == "vchord":
conn.execute(
text(f"""
CREATE INDEX IF NOT EXISTS idx_memory_units_embedding_vchordrq
@@ -609,12 +537,7 @@ def ensure_vector_extension(
]
# Determine target index type
if target_ext == "pgvectorscale":
target_index_type = "diskann"
elif target_ext == "vchord":
target_index_type = "vchordrq"
else:
target_index_type = "hnsw"
target_index_type = "vchordrq" if target_ext == "vchord" else "hnsw"
mismatched_tables = []
tables_with_data = []
@@ -653,9 +576,7 @@ def ensure_vector_extension(
continue
indexdef = current_index_info[0].lower()
if "diskann" in indexdef:
current_index_type = "diskann"
elif "vchordrq" in indexdef:
if "vchordrq" in indexdef:
current_index_type = "vchordrq"
elif "hnsw" in indexdef:
current_index_type = "hnsw"
@@ -688,18 +609,13 @@ def ensure_vector_extension(
# If there's data in any mismatched table, raise error
if tables_with_data:
table_list = ", ".join([f"{table}({count} rows)" for table, count in tables_with_data])
# Map index type back to extension name for error message
current_ext_name = {"diskann": "pgvectorscale", "vchordrq": "vchord", "hnsw": "pgvector"}.get(
current_index_type, current_index_type
)
raise RuntimeError(
f"Cannot change vector extension from {current_index_type} to {target_index_type}: "
f"the following tables contain data: {table_list}. "
f"To change vector extension, you must either:\n"
f" 1. Re-embed all data: DELETE FROM {schema_name}.memory_units; "
f"DELETE FROM {schema_name}.learnings; DELETE FROM {schema_name}.pinned_reflections; then restart\n"
f" 2. Use the current vector extension (set HINDSIGHT_API_VECTOR_EXTENSION='{current_ext_name}')"
f" 2. Use the current vector extension (set HINDSIGHT_API_VECTOR_EXTENSION='{current_index_type.replace('vchordrq', 'vchord').replace('hnsw', 'pgvector')}')"
)
# Tables are empty, safe to recreate indexes
@@ -712,17 +628,7 @@ def ensure_vector_extension(
conn.execute(text(f"DROP INDEX IF EXISTS {schema_name}.{index_name}"))
# Create new index with appropriate type
if target_ext == "pgvectorscale":
logger.info(f"Creating DiskANN index on {table_name}")
conn.execute(
text(f"""
CREATE INDEX IF NOT EXISTS {index_name}
ON {schema_name}.{table_name}
USING diskann (embedding vector_cosine_ops)
WITH (num_neighbors = 50)
""")
)
elif target_ext == "vchord":
if target_ext == "vchord":
logger.info(f"Creating vchordrq index on {table_name}")
conn.execute(
text(f"""
@@ -782,9 +688,6 @@ def ensure_text_search_extension(
if text_search_extension == "vchord":
target_column_type = "bm25vector"
target_index_type = "bm25"
elif text_search_extension == "pg_textsearch":
target_column_type = "text"
target_index_type = "bm25"
else: # native
target_column_type = "tsvector"
target_index_type = "gin"
@@ -872,16 +775,7 @@ def ensure_text_search_extension(
# If there's data in any mismatched table, raise error
if tables_with_data:
table_list = ", ".join([f"{table}({count} rows)" for table, count in tables_with_data])
# Detect current extension from column type
current_col_type = mismatched_tables[0][1]
if current_col_type == "tsvector":
current_ext = "native"
elif current_col_type == "bm25vector":
current_ext = "vchord"
elif current_col_type == "text":
current_ext = "pg_textsearch"
else:
current_ext = "unknown"
current_ext = "native" if mismatched_tables[0][1] == "tsvector" else "vchord"
raise RuntimeError(
f"Cannot change text search extension from {current_ext} to {text_search_extension}: "
f"the following tables contain data: {table_list}. "
@@ -926,27 +820,6 @@ def ensure_text_search_extension(
USING bm25 (search_vector bm25_catalog.bm25_ops)
""")
)
elif text_search_extension == "pg_textsearch":
logger.info(f"Creating TEXT column on {table_name}")
# Dummy TEXT column for consistency (indexes operate on base columns)
conn.execute(text(f"ALTER TABLE {schema_name}.{table_name} ADD COLUMN search_vector TEXT"))
# Create BM25 index on expression
logger.info(f"Creating BM25 index on {table_name}")
# Different expression for each table
if table_name == "memory_units":
index_expr = "(COALESCE(text, '') || ' ' || COALESCE(context, ''))"
else: # reflections
index_expr = "(COALESCE(name, '') || ' ' || content)"
conn.execute(
text(f"""
CREATE INDEX idx_{table_name.replace(".", "_")}_text_search
ON {schema_name}.{table_name}
USING bm25({index_expr})
WITH (text_config='english')
""")
)
else: # native
logger.info(f"Creating tsvector column on {table_name}")
# Different GENERATED expression for each table
+1 -82
View File
@@ -401,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:
@@ -415,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,
)
@@ -441,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.
+1 -2
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "hindsight-api"
version = "0.4.11"
version = "0.4.10"
description = "Hindsight: Agent Memory That Works Like Human Memory"
readme = "README.md"
requires-python = ">=3.11"
@@ -42,7 +42,6 @@ dependencies = [
"typer>=0.9.0",
"cohere>=5.0.0",
"flashrank>=0.2.0",
"litellm>=1.0.0",
# 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
@@ -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
@@ -1,93 +0,0 @@
"""Unit tests for async retain tag propagation."""
from unittest.mock import AsyncMock, MagicMock
import pytest
from hindsight_api.engine.memory_engine import MemoryEngine
from hindsight_api.models import RequestContext
@pytest.mark.asyncio
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"]
result = await MemoryEngine.submit_async_retain(
engine,
bank_id="bank-1",
contents=contents,
document_tags=document_tags,
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
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"
assert kwargs["task_type"] == "batch_retain"
assert kwargs["task_payload"]["contents"] == contents
assert kwargs["task_payload"]["document_tags"] == document_tags
assert kwargs["task_payload"]["_tenant_id"] == "tenant-a"
assert kwargs["task_payload"]["_api_key_id"] == "key-a"
@pytest.mark.asyncio
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 = {
"bank_id": "bank-1",
"contents": [{"content": "Forward tags test."}],
"document_tags": ["scope:client"],
"_tenant_id": "tenant-a",
"_api_key_id": "key-a",
}
await MemoryEngine._handle_batch_retain(engine, task_dict)
engine.retain_batch_async.assert_awaited_once()
kwargs = engine.retain_batch_async.await_args.kwargs
assert kwargs["bank_id"] == "bank-1"
assert kwargs["contents"] == task_dict["contents"]
assert kwargs["document_tags"] == ["scope:client"]
request_context = kwargs["request_context"]
assert request_context.internal is True
assert request_context.user_initiated is True
assert request_context.tenant_id == "tenant-a"
assert request_context.api_key_id == "key-a"
-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"
@@ -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",
},
]
},
@@ -1,392 +0,0 @@
"""
Tests for LiteLLMSDKCrossEncoder.
Tests the LiteLLM SDK-based cross-encoder implementation for reranking.
"""
import os
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from hindsight_api.engine.cross_encoder import LiteLLMSDKCrossEncoder, create_cross_encoder_from_env
class TestLiteLLMSDKCrossEncoder:
"""Test suite for LiteLLMSDKCrossEncoder class."""
@pytest.mark.asyncio
async def test_initialization_success(self):
"""Test successful initialization with valid config."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="deepinfra/Qwen3-reranker-8B",
)
assert encoder.provider_name == "litellm-sdk"
assert encoder.api_key == "test_key"
assert encoder.model == "deepinfra/Qwen3-reranker-8B"
assert encoder._initialized is False
# Mock the litellm import
mock_litellm = MagicMock()
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
assert encoder._initialized is True
@pytest.mark.asyncio
async def test_initialization_missing_package(self):
"""Test initialization fails when litellm package is missing."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
with patch.dict("sys.modules", {"litellm": None}):
with pytest.raises(ImportError, match="litellm is required"):
await encoder.initialize()
@pytest.mark.asyncio
async def test_initialization_idempotent(self):
"""Test that calling initialize() multiple times is safe."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
mock_litellm = MagicMock()
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
assert encoder._initialized is True
# Second call should be no-op
await encoder.initialize()
assert encoder._initialized is True
@pytest.mark.asyncio
async def test_predict_single_query(self):
"""Test prediction with a single query and multiple documents."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="deepinfra/Qwen3-reranker-8B",
)
# Create mock response with results as TypedDicts
mock_response = MagicMock()
mock_response.results = [
{"index": 0, "relevance_score": 0.9},
{"index": 1, "relevance_score": 0.7},
{"index": 2, "relevance_score": 0.5},
]
mock_litellm = MagicMock()
mock_litellm.arerank = AsyncMock(return_value=mock_response)
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
pairs = [
("What is Python?", "Python is a programming language"),
("What is Python?", "Python is a snake"),
("What is Python?", "Python is a British comedy group"),
]
scores = await encoder.predict(pairs)
assert len(scores) == 3
assert scores == [0.9, 0.7, 0.5]
# Verify arerank was called correctly
mock_litellm.arerank.assert_called_once()
call_args = mock_litellm.arerank.call_args
assert call_args.kwargs["model"] == "deepinfra/Qwen3-reranker-8B"
assert call_args.kwargs["query"] == "What is Python?"
assert len(call_args.kwargs["documents"]) == 3
assert call_args.kwargs["api_key"] == "test_key"
@pytest.mark.asyncio
async def test_predict_multiple_queries(self):
"""Test prediction with multiple different queries (grouped efficiently)."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
# First query response
mock_response1 = MagicMock()
mock_response1.results = [
{"index": 0, "relevance_score": 0.9},
{"index": 1, "relevance_score": 0.7},
]
# Second query response
mock_response2 = MagicMock()
mock_response2.results = [
{"index": 0, "relevance_score": 0.8},
]
mock_litellm = MagicMock()
mock_litellm.arerank = AsyncMock(side_effect=[mock_response1, mock_response2])
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
pairs = [
("What is Python?", "Python is a programming language"),
("What is Python?", "Python is a snake"),
("What is Java?", "Java is a programming language"),
]
scores = await encoder.predict(pairs)
assert len(scores) == 3
assert scores[0] == 0.9 # First query, first doc
assert scores[1] == 0.7 # First query, second doc
assert scores[2] == 0.8 # Second query, first doc
# Verify arerank was called twice (once per unique query)
assert mock_litellm.arerank.call_count == 2
@pytest.mark.asyncio
async def test_predict_empty_pairs(self):
"""Test prediction with empty input."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
mock_litellm = MagicMock()
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
scores = await encoder.predict([])
assert scores == []
@pytest.mark.asyncio
async def test_predict_not_initialized(self):
"""Test that predict fails if encoder not initialized."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
pairs = [("query", "document")]
with pytest.raises(RuntimeError, match="not initialized"):
await encoder.predict(pairs)
@pytest.mark.asyncio
async def test_predict_error_handling(self):
"""Test that errors during prediction are raised."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
)
# Mock litellm to raise an error
mock_litellm = MagicMock()
mock_litellm.arerank = AsyncMock(side_effect=Exception("API Error"))
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
pairs = [
("What is Python?", "Python is a programming language"),
]
# Should raise the exception
with pytest.raises(Exception, match="API Error"):
await encoder.predict(pairs)
@pytest.mark.asyncio
async def test_custom_api_base(self):
"""Test that custom API base URL is passed to rerank calls."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="cohere/rerank-english-v3.0",
api_base="https://custom.api.example.com",
)
mock_response = MagicMock()
mock_response.results = [
{"index": 0, "relevance_score": 0.9},
]
mock_litellm = MagicMock()
mock_litellm.arerank = AsyncMock(return_value=mock_response)
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
# Test that api_base is passed to arerank
pairs = [("query", "document")]
scores = await encoder.predict(pairs)
assert scores == [0.9]
mock_litellm.arerank.assert_called_once()
call_args = mock_litellm.arerank.call_args
assert call_args.kwargs["api_base"] == "https://custom.api.example.com"
@pytest.mark.asyncio
async def test_response_with_direct_score_list(self):
"""Test handling of response format with direct score list."""
encoder = LiteLLMSDKCrossEncoder(
api_key="test_key",
model="some-provider/model",
)
# Mock litellm to return direct list of scores
mock_litellm = MagicMock()
mock_litellm.arerank = AsyncMock(return_value=[0.9, 0.7, 0.5])
with patch.dict("sys.modules", {"litellm": mock_litellm}):
await encoder.initialize()
pairs = [
("query", "doc1"),
("query", "doc2"),
("query", "doc3"),
]
scores = await encoder.predict(pairs)
assert scores == [0.9, 0.7, 0.5]
class TestFactoryFunction:
"""Test suite for create_cross_encoder_from_env factory function."""
@pytest.mark.asyncio
async def test_create_litellm_sdk_from_env(self):
"""Test creating LiteLLM SDK cross-encoder from environment variables."""
env_vars = {
"HINDSIGHT_API_RERANKER_PROVIDER": "litellm-sdk",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY": "test_key",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_MODEL": "deepinfra/Qwen3-reranker-8B",
}
with patch.dict(os.environ, env_vars, clear=False):
# Need to reload config to pick up env vars
from hindsight_api.config import HindsightConfig
config = HindsightConfig.from_env()
with patch("hindsight_api.config.get_config", return_value=config):
encoder = create_cross_encoder_from_env()
assert isinstance(encoder, LiteLLMSDKCrossEncoder)
assert encoder.api_key == "test_key"
assert encoder.model == "deepinfra/Qwen3-reranker-8B"
@pytest.mark.asyncio
async def test_create_litellm_sdk_missing_api_key(self):
"""Test that factory raises error when API key is missing."""
env_vars = {
"HINDSIGHT_API_RERANKER_PROVIDER": "litellm-sdk",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_MODEL": "deepinfra/Qwen3-reranker-8B",
}
with patch.dict(os.environ, env_vars, clear=False):
# Remove API key if set
if "HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY" in os.environ:
del os.environ["HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY"]
from hindsight_api.config import HindsightConfig
config = HindsightConfig.from_env()
with patch("hindsight_api.config.get_config", return_value=config):
with pytest.raises(ValueError, match="HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY is required"):
create_cross_encoder_from_env()
@pytest.mark.asyncio
async def test_create_litellm_sdk_with_custom_api_base(self):
"""Test creating LiteLLM SDK cross-encoder with custom API base."""
env_vars = {
"HINDSIGHT_API_RERANKER_PROVIDER": "litellm-sdk",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_API_KEY": "test_key",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_MODEL": "cohere/rerank-english-v3.0",
"HINDSIGHT_API_RERANKER_LITELLM_SDK_API_BASE": "https://custom.api.example.com",
}
with patch.dict(os.environ, env_vars, clear=False):
from hindsight_api.config import HindsightConfig
config = HindsightConfig.from_env()
with patch("hindsight_api.config.get_config", return_value=config):
encoder = create_cross_encoder_from_env()
assert isinstance(encoder, LiteLLMSDKCrossEncoder)
assert encoder.api_base == "https://custom.api.example.com"
class TestLiteLLMSDKCohereCrossEncoder:
"""Tests for LiteLLM SDK calling Cohere (runs in CI with COHERE_API_KEY)."""
@pytest.fixture
async def litellm_cohere_cross_encoder(self):
"""Create LiteLLM SDK cross-encoder instance for Cohere."""
if not os.environ.get("COHERE_API_KEY"):
pytest.skip("Cohere API key not available (set COHERE_API_KEY)")
encoder = LiteLLMSDKCrossEncoder(
api_key=os.environ["COHERE_API_KEY"],
model="cohere/rerank-english-v3.0",
)
await encoder.initialize()
return encoder
@pytest.mark.asyncio
async def test_litellm_sdk_cohere_initialization(self, litellm_cohere_cross_encoder):
"""Test that LiteLLM SDK Cohere cross-encoder initializes correctly."""
assert litellm_cohere_cross_encoder.provider_name == "litellm-sdk"
assert litellm_cohere_cross_encoder.model == "cohere/rerank-english-v3.0"
@pytest.mark.asyncio
async def test_litellm_sdk_cohere_predict(self, litellm_cohere_cross_encoder):
"""Test that LiteLLM SDK can call Cohere rerank API."""
pairs = [
("What is the capital of France?", "Paris is the capital of France."),
("What is the capital of France?", "The Eiffel Tower is in Paris."),
("What is the capital of France?", "Python is a programming language."),
]
scores = await litellm_cohere_cross_encoder.predict(pairs)
assert len(scores) == 3
assert all(isinstance(s, float) for s in scores)
# The first result should be most relevant
assert scores[0] > scores[2], "Direct answer should score higher than unrelated text"
# All scores should be in valid range
assert all(0.0 <= score <= 1.0 for score in scores)
class TestIntegration:
"""Integration tests with real API (optional - requires API keys)."""
@pytest.mark.skipif(
not os.environ.get("DEEPINFRA_API_KEY"),
reason="DEEPINFRA_API_KEY not set - skipping integration test",
)
@pytest.mark.asyncio
async def test_real_deepinfra_api(self):
"""Test with real DeepInfra API (requires DEEPINFRA_API_KEY env var)."""
encoder = LiteLLMSDKCrossEncoder(
api_key=os.environ["DEEPINFRA_API_KEY"],
model="deepinfra/Qwen3-reranker-8B",
)
await encoder.initialize()
pairs = [
("What is Python?", "Python is a high-level programming language"),
("What is Python?", "Python is a species of snake"),
("What is Python?", "Python is unrelated text about cars"),
]
scores = await encoder.predict(pairs)
# First doc should have highest score (most relevant)
assert len(scores) == 3
assert scores[0] > scores[1]
assert scores[1] > scores[2]
assert all(0.0 <= score <= 1.0 for score in scores)
@@ -1,387 +0,0 @@
"""
Tests for LiteLLM SDK embeddings implementation.
These tests cover:
1. Initialization (success, missing package, missing API key, idempotent)
2. Encode (single text, multiple texts, batching, error handling)
3. Provider-specific configuration (Cohere, OpenAI, etc.)
4. Factory function (create from env, validation errors)
5. Dimension detection
"""
import os
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from hindsight_api.config import (
ENV_EMBEDDINGS_LITELLM_SDK_API_KEY,
ENV_EMBEDDINGS_LITELLM_SDK_MODEL,
ENV_EMBEDDINGS_PROVIDER,
HindsightConfig,
)
from hindsight_api.engine.embeddings import LiteLLMSDKEmbeddings, create_embeddings_from_env
class TestLiteLLMSDKEmbeddings:
"""Unit tests for LiteLLMSDKEmbeddings with mocked litellm responses."""
@pytest.fixture
def mock_litellm(self):
"""Mock litellm module."""
mock = MagicMock()
# Mock aembedding (async) for initialization
mock_response = MagicMock()
mock_response.data = [{"embedding": [0.1] * 768, "index": 0}]
mock.aembedding = AsyncMock(return_value=mock_response)
# Mock embedding (sync) for encode
mock_sync_response = MagicMock()
mock_sync_response.data = [
{"embedding": [0.1] * 768, "index": 0},
{"embedding": [0.2] * 768, "index": 1},
]
mock.embedding = MagicMock(return_value=mock_sync_response)
return mock
@pytest.fixture
async def embeddings(self, mock_litellm):
"""Create initialized LiteLLMSDKEmbeddings instance."""
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
# Manually set the mock (simulating successful initialization)
emb._litellm = mock_litellm
emb._dimension = 768
return emb
async def test_initialization_success(self, mock_litellm):
"""Test successful initialization."""
with patch("builtins.__import__", side_effect=lambda name, *args: mock_litellm if name == "litellm" else __import__(name, *args)):
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
assert emb._litellm is None
assert emb._dimension is None
await emb.initialize()
assert emb._litellm is not None
assert emb._dimension == 768
# Verify test embedding was called
mock_litellm.aembedding.assert_called_once_with(
model="cohere/embed-english-v3.0",
input=["test"],
api_key="test_key",
)
async def test_initialization_missing_package(self):
"""Test initialization fails gracefully when litellm is not installed."""
def mock_import(name, *args):
if name == "litellm":
raise ImportError("No module named 'litellm'")
return __import__(name, *args)
with patch("builtins.__import__", side_effect=mock_import):
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
with pytest.raises(ImportError, match="litellm is required"):
await emb.initialize()
async def test_initialization_idempotent(self, embeddings, mock_litellm):
"""Test that calling initialize() multiple times is safe."""
# embeddings._litellm is already set in fixture
assert embeddings._litellm is not None
# Call again
await embeddings.initialize()
# Should still have same litellm instance
assert embeddings._litellm is not None
async def test_encode_single_text(self, embeddings, mock_litellm):
"""Test encoding a single text."""
# Set up mock response
mock_litellm.embedding.return_value.data = [
{"embedding": [0.5] * 768, "index": 0},
]
result = embeddings.encode(["Hello world"])
assert isinstance(result, list)
assert len(result) == 1
assert len(result[0]) == 768
assert all(isinstance(x, float) for x in result[0])
assert all(abs(x - 0.5) < 0.001 for x in result[0])
# Verify call
mock_litellm.embedding.assert_called_once_with(
model="cohere/embed-english-v3.0",
input=["Hello world"],
api_key="test_key",
)
async def test_encode_multiple_texts(self, embeddings, mock_litellm):
"""Test encoding multiple texts."""
# Set up mock response
mock_litellm.embedding.return_value.data = [
{"embedding": [0.1] * 768, "index": 0},
{"embedding": [0.2] * 768, "index": 1},
{"embedding": [0.3] * 768, "index": 2},
]
texts = ["First text", "Second text", "Third text"]
result = embeddings.encode(texts)
assert isinstance(result, list)
assert len(result) == 3
assert len(result[0]) == 768
assert len(result[1]) == 768
assert len(result[2]) == 768
assert all(abs(x - 0.1) < 0.001 for x in result[0])
assert all(abs(x - 0.2) < 0.001 for x in result[1])
assert all(abs(x - 0.3) < 0.001 for x in result[2])
async def test_encode_batching(self, embeddings, mock_litellm):
"""Test that large inputs are batched correctly."""
# Create embeddings with small batch size
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=2, # Small batch for testing
timeout=60.0,
)
emb._litellm = mock_litellm
emb._initialized = True
emb._dimension = 768
# Mock responses for each batch
def mock_embedding_side_effect(model, input, **kwargs):
mock_response = MagicMock()
mock_response.data = [
{"embedding": [float(i)] * 768, "index": i} for i in range(len(input))
]
return mock_response
mock_litellm.embedding.side_effect = mock_embedding_side_effect
# Encode 5 texts (should create 3 batches: 2, 2, 1)
texts = [f"Text {i}" for i in range(5)]
result = emb.encode(texts)
assert isinstance(result, list)
assert len(result) == 5
assert all(len(embedding) == 768 for embedding in result)
# Verify batching: should be called 3 times
assert mock_litellm.embedding.call_count == 3
# Verify batch sizes
calls = mock_litellm.embedding.call_args_list
assert len(calls[0][1]["input"]) == 2 # First batch
assert len(calls[1][1]["input"]) == 2 # Second batch
assert len(calls[2][1]["input"]) == 1 # Third batch
async def test_encode_empty_list(self, embeddings):
"""Test encoding empty list returns empty list."""
result = embeddings.encode([])
assert isinstance(result, list)
assert len(result) == 0
async def test_encode_before_initialization(self, mock_litellm):
"""Test that encode raises error if not initialized."""
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
with pytest.raises(RuntimeError, match="not initialized"):
emb.encode(["test"])
async def test_encode_error_handling(self, embeddings, mock_litellm):
"""Test error handling during encoding."""
# Make embedding raise an error
mock_litellm.embedding.side_effect = Exception("API Error")
with pytest.raises(Exception, match="API Error"):
embeddings.encode(["test"])
async def test_dimension_property(self, embeddings):
"""Test dimension property."""
assert embeddings.dimension == 768
async def test_dimension_before_initialization(self, mock_litellm):
"""Test dimension raises error if not initialized."""
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
with pytest.raises(RuntimeError, match="not initialized"):
_ = emb.dimension
async def test_custom_api_base(self, mock_litellm):
"""Test custom API base URL is passed to embedding calls."""
with patch("builtins.__import__", side_effect=lambda name, *args: mock_litellm if name == "litellm" else __import__(name, *args)):
emb = LiteLLMSDKEmbeddings(
api_key="test_key",
model="cohere/embed-english-v3.0",
api_base="https://custom.api.com",
batch_size=100,
timeout=60.0,
)
await emb.initialize()
# Verify api_base is set
assert emb.api_base == "https://custom.api.com"
# Verify api_base is passed to aembedding
mock_litellm.aembedding.assert_called_once()
call_args = mock_litellm.aembedding.call_args
assert call_args.kwargs["api_base"] == "https://custom.api.com"
# Test encode also passes api_base
mock_litellm.embedding.return_value.data = [{"embedding": [0.1] * 768, "index": 0}]
emb.encode(["test"])
mock_litellm.embedding.assert_called_once()
call_args = mock_litellm.embedding.call_args
assert call_args.kwargs["api_base"] == "https://custom.api.com"
class TestLiteLLMSDKEmbeddingsFactory:
"""Test the factory function for creating LiteLLM SDK embeddings."""
def test_create_from_env_success(self, monkeypatch):
"""Test creating embeddings from environment variables."""
# Mock get_config() to return configured HindsightConfig
mock_config = MagicMock()
mock_config.embeddings_provider = "litellm-sdk"
mock_config.embeddings_litellm_sdk_api_key = "test_key"
mock_config.embeddings_litellm_sdk_model = "cohere/embed-english-v3.0"
mock_config.embeddings_litellm_sdk_api_base = None
with patch("hindsight_api.config.get_config", return_value=mock_config):
embeddings = create_embeddings_from_env()
assert isinstance(embeddings, LiteLLMSDKEmbeddings)
assert embeddings.api_key == "test_key"
assert embeddings.model == "cohere/embed-english-v3.0"
def test_create_from_env_missing_api_key(self, monkeypatch):
"""Test that missing API key raises error."""
# Mock get_config() with missing API key
mock_config = MagicMock()
mock_config.embeddings_provider = "litellm-sdk"
mock_config.embeddings_litellm_sdk_api_key = None # Missing key
mock_config.embeddings_litellm_sdk_model = "cohere/embed-english-v3.0"
with patch("hindsight_api.config.get_config", return_value=mock_config):
with pytest.raises(ValueError, match=ENV_EMBEDDINGS_LITELLM_SDK_API_KEY):
create_embeddings_from_env()
def test_create_from_env_with_api_base(self, monkeypatch):
"""Test creating embeddings with custom API base."""
# Mock get_config() with custom API base
mock_config = MagicMock()
mock_config.embeddings_provider = "litellm-sdk"
mock_config.embeddings_litellm_sdk_api_key = "test_key"
mock_config.embeddings_litellm_sdk_model = "cohere/embed-english-v3.0"
mock_config.embeddings_litellm_sdk_api_base = "https://custom.api.com"
with patch("hindsight_api.config.get_config", return_value=mock_config):
embeddings = create_embeddings_from_env()
assert isinstance(embeddings, LiteLLMSDKEmbeddings)
assert embeddings.api_base == "https://custom.api.com"
class TestLiteLLMSDKCohereEmbeddings:
"""Integration tests calling real Cohere API (matches CI pattern)."""
@pytest.fixture
async def litellm_cohere_embeddings(self):
"""Create embeddings instance with real Cohere API key."""
if not os.environ.get("COHERE_API_KEY"):
pytest.skip("Cohere API key not available")
emb = LiteLLMSDKEmbeddings(
api_key=os.environ["COHERE_API_KEY"],
model="cohere/embed-english-v3.0",
api_base=None,
batch_size=100,
timeout=60.0,
)
await emb.initialize()
return emb
@pytest.mark.asyncio
async def test_litellm_sdk_cohere_encode(self, litellm_cohere_embeddings):
"""Test real Cohere API call for embeddings."""
texts = [
"The quick brown fox jumps over the lazy dog",
"Machine learning is a subset of artificial intelligence",
"Python is a popular programming language",
]
result = litellm_cohere_embeddings.encode(texts)
# Verify result type and shape
assert isinstance(result, list)
assert len(result) == 3
assert all(len(embedding) > 0 for embedding in result)
assert all(isinstance(x, float) for x in result[0])
# Verify embeddings are not zeros (common API failure mode)
for i, embedding in enumerate(result):
assert not all(abs(x) < 0.0001 for x in embedding), f"Embedding {i} is all zeros"
# Verify embeddings are normalized (Cohere returns normalized vectors)
for i, embedding in enumerate(result):
norm = sum(x * x for x in embedding) ** 0.5
assert 0.9 < norm < 1.1, f"Embedding {i} norm {norm} is not close to 1.0"
@pytest.mark.asyncio
async def test_litellm_sdk_cohere_dimension(self, litellm_cohere_embeddings):
"""Test dimension detection with real Cohere API."""
dimension = litellm_cohere_embeddings.dimension
# Cohere embed-english-v3.0 has 1024 dimensions
assert dimension == 1024
@pytest.mark.asyncio
async def test_litellm_sdk_cohere_single_text(self, litellm_cohere_embeddings):
"""Test encoding single text with real Cohere API."""
result = litellm_cohere_embeddings.encode(["Hello world"])
assert isinstance(result, list)
assert len(result) == 1
assert len(result[0]) == 1024
assert not all(abs(x) < 0.0001 for x in result[0])
@@ -1,274 +0,0 @@
"""
Test that recall chunks are fetched independently of max_tokens filtering.
This test verifies the new behavior where:
1. Chunks are fetched BEFORE max_tokens filtering
2. max_tokens=0 returns 0 facts but can still return chunks
3. Chunks are fetched in batches to handle varying chunk sizes
"""
import pytest
import pytest_asyncio
from hindsight_api.engine.memory_engine import Budget
@pytest.mark.asyncio
async def test_recall_chunks_independent_of_max_tokens(memory, request_context):
"""
Test that chunks are fetched independently of max_tokens.
When max_tokens=0, recall should:
- Return 0 memory facts
- Still return chunks (up to max_chunk_tokens)
- Chunks should come from top-scored results before token filtering
"""
bank_id = "test-chunks-independence"
try:
# Retain some test content with substantial size to generate chunks
test_content = """
The quantum computing research team at MIT has made significant breakthroughs.
Dr. Sarah Chen leads the team and focuses on quantum error correction.
The team published three papers in Nature Physics this year.
Their work on topological qubits shows promise for scalable quantum computers.
Collaborators include IBM Research and Google Quantum AI.
The research is funded by a $5M NSF grant running through 2026.
""" * 10 # Repeat to ensure we get multiple chunks
await memory.retain_async(
bank_id=bank_id,
content=test_content,
context="research notes",
request_context=request_context,
)
# Test 1: Normal recall with both facts and chunks
result_normal = await memory.recall_async(
bank_id=bank_id,
query="quantum computing",
max_tokens=4096, # Normal token budget
include_chunks=True,
max_chunk_tokens=2000,
budget=Budget.MID,
request_context=request_context,
)
assert len(result_normal.results) > 0, "Should return memory facts with normal max_tokens"
assert result_normal.chunks is not None, "Should include chunks when requested"
assert len(result_normal.chunks) > 0, "Should return at least one chunk"
# Test 2: Recall with max_tokens=0 but chunks enabled
result_chunks_only = await memory.recall_async(
bank_id=bank_id,
query="quantum computing",
max_tokens=0, # Zero token budget for facts
include_chunks=True,
max_chunk_tokens=2000, # But allow chunks
budget=Budget.MID,
request_context=request_context,
)
# Key assertions for new behavior
assert len(result_chunks_only.results) == 0, "max_tokens=0 should return 0 facts"
assert result_chunks_only.chunks is not None, "Should still include chunks dict"
assert len(result_chunks_only.chunks) > 0, "Should return chunks even with max_tokens=0"
# Verify chunks are from the same content (non-empty text)
for chunk_id, chunk_info in result_chunks_only.chunks.items():
assert len(chunk_info.chunk_text) > 0, "Chunks should contain text"
assert chunk_info.chunk_index >= 0, "Chunk should have valid index"
finally:
# Cleanup
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_recall_chunks_batching_with_varying_sizes(memory, request_context):
"""
Test that chunk batching works correctly with varying chunk sizes.
This verifies that:
1. Chunks are fetched in batches until token budget is exhausted
2. The system handles varying chunk sizes across documents
3. Token budget is respected across multiple batch fetches
"""
bank_id = "test-chunks-batching"
try:
# Retain multiple documents with different content sizes
# Document 1: Short content (small chunks)
await memory.retain_async(
bank_id=bank_id,
content="Alice is a software engineer who specializes in Python programming and machine learning.",
context="doc1",
request_context=request_context,
)
# Document 2: Medium content
content_bob = """
Bob works as a data scientist at a tech startup in San Francisco.
He has expertise in natural language processing and computer vision.
Bob completed his PhD at Stanford University in 2020.
He leads a team of five engineers working on AI-powered recommendation systems.
""" * 5
await memory.retain_async(
bank_id=bank_id,
content=content_bob,
context="doc2",
request_context=request_context,
)
# Document 3: Long content (large chunks)
content_charlie = """
Charlie is the CTO of a growing AI company focused on healthcare applications.
He has over 15 years of experience in software architecture and distributed systems.
Charlie's team builds machine learning models for medical image analysis and diagnosis.
The company recently raised $50 million in Series B funding.
They have partnerships with major hospitals in the United States and Europe.
Charlie holds several patents in medical imaging and deep learning.
""" * 20
await memory.retain_async(
bank_id=bank_id,
content=content_charlie,
context="doc3",
request_context=request_context,
)
# Recall with modest chunk token budget
result = await memory.recall_async(
bank_id=bank_id,
query="Alice Bob Charlie",
max_tokens=0, # No facts, only chunks
include_chunks=True,
max_chunk_tokens=1000, # Limited chunk budget
budget=Budget.MID,
request_context=request_context,
)
assert len(result.results) == 0, "Should return 0 facts with max_tokens=0"
assert result.chunks is not None, "Should include chunks"
# Verify we got chunks and respected the token budget
if len(result.chunks) > 0:
# Count total tokens (approximate)
total_chunk_chars = sum(len(chunk.chunk_text) for chunk in result.chunks.values())
# Very rough estimate: 1 token ≈ 4 characters
estimated_tokens = total_chunk_chars // 4
# Should be reasonably close to budget (within 2x due to estimation and batching)
assert estimated_tokens <= 1000 * 2, f"Should respect chunk token budget (got ~{estimated_tokens} tokens)"
finally:
# Cleanup
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_recall_chunks_ordering_by_relevance(memory, request_context):
"""
Test that chunks are returned in order of fact relevance.
Chunks should be ordered based on the top-scored (reranked) results,
not in document order or random order.
"""
bank_id = "test-chunks-ordering"
try:
# Retain content with different relevance to query
await memory.retain_async(
bank_id=bank_id,
content="The Python programming language is widely used for machine learning and data science applications.",
context="topic: Python",
request_context=request_context,
)
await memory.retain_async(
bank_id=bank_id,
content="JavaScript is commonly used for web development and frontend applications.",
context="topic: JavaScript",
request_context=request_context,
)
await memory.retain_async(
bank_id=bank_id,
content="Python's scikit-learn library is excellent for traditional machine learning tasks and model training.",
context="topic: Python ML",
request_context=request_context,
)
# Query specifically about Python - should rank Python facts higher
result = await memory.recall_async(
bank_id=bank_id,
query="Python machine learning",
max_tokens=0, # No facts
include_chunks=True,
max_chunk_tokens=5000, # Enough for all chunks
budget=Budget.HIGH, # Use high budget for better recall
request_context=request_context,
)
assert len(result.results) == 0, "Should return 0 facts with max_tokens=0"
assert result.chunks is not None, "Should include chunks"
# We should get chunks, and they should be ordered by relevance
# The exact ordering depends on the reranker, but we should have chunks
assert len(result.chunks) > 0, "Should return chunks from relevant facts"
# Verify chunks contain relevant content
all_chunk_text = " ".join(chunk.chunk_text for chunk in result.chunks.values())
# At least some chunks should mention Python (higher relevance)
# This is a soft check since exact ordering depends on scoring
assert "Python" in all_chunk_text or "python" in all_chunk_text.lower(), \
"Chunks should include content about Python (relevant to query)"
finally:
# Cleanup
await memory.delete_bank(bank_id, request_context=request_context)
@pytest.mark.asyncio
async def test_recall_chunks_without_include_flag(memory, request_context):
"""
Test that chunks are NOT returned when include_chunks=False (default).
This ensures backward compatibility - chunks are only fetched when explicitly requested.
"""
bank_id = "test-chunks-no-include"
try:
# Retain content
test_content = """
Sarah is a product manager at a fintech company in New York.
She specializes in user experience design and agile methodologies.
Sarah graduated from MIT with a degree in computer science.
She has led the development of three successful mobile banking applications.
"""
await memory.retain_async(
bank_id=bank_id,
content=test_content,
request_context=request_context,
)
# Recall without include_chunks flag (default is False)
result = await memory.recall_async(
bank_id=bank_id,
query="Sarah product manager",
max_tokens=4096,
request_context=request_context,
# include_chunks=False is the default
)
# Should have facts but no chunks
assert len(result.results) > 0, "Should return facts"
assert result.chunks is None or len(result.chunks) == 0, \
"Should NOT return chunks when include_chunks=False"
finally:
# Cleanup
await memory.delete_bank(bank_id, request_context=request_context)
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "hindsight-cli"
version = "0.4.11"
version = "0.4.10"
edition = "2021"
authors = ["Hindsight Team"]
description = "A beautiful CLI for Hindsight - semantic memory system"
-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
}
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
}
-673
View File
@@ -1,673 +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
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.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)
}
-246
View File
@@ -1,246 +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"`
}
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) *FeaturesInfo {
this := FeaturesInfo{}
this.Observations = observations
this.Mcp = mcp
this.Worker = worker
this.BankConfigApi = bankConfigApi
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
}
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
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",
}
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,270 +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 GraphDataResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &GraphDataResponse{}
// GraphDataResponse Response model for graph data endpoint.
type GraphDataResponse struct {
Nodes []map[string]interface{} `json:"nodes"`
Edges []map[string]interface{} `json:"edges"`
TableRows []map[string]interface{} `json:"table_rows"`
TotalUnits int32 `json:"total_units"`
Limit int32 `json:"limit"`
}
type _GraphDataResponse GraphDataResponse
// NewGraphDataResponse instantiates a new GraphDataResponse 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 NewGraphDataResponse(nodes []map[string]interface{}, edges []map[string]interface{}, tableRows []map[string]interface{}, totalUnits int32, limit int32) *GraphDataResponse {
this := GraphDataResponse{}
this.Nodes = nodes
this.Edges = edges
this.TableRows = tableRows
this.TotalUnits = totalUnits
this.Limit = limit
return &this
}
// NewGraphDataResponseWithDefaults instantiates a new GraphDataResponse 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 NewGraphDataResponseWithDefaults() *GraphDataResponse {
this := GraphDataResponse{}
return &this
}
// GetNodes returns the Nodes field value
func (o *GraphDataResponse) GetNodes() []map[string]interface{} {
if o == nil {
var ret []map[string]interface{}
return ret
}
return o.Nodes
}
// GetNodesOk returns a tuple with the Nodes field value
// and a boolean to check if the value has been set.
func (o *GraphDataResponse) GetNodesOk() ([]map[string]interface{}, bool) {
if o == nil {
return nil, false
}
return o.Nodes, true
}
// SetNodes sets field value
func (o *GraphDataResponse) SetNodes(v []map[string]interface{}) {
o.Nodes = v
}
// GetEdges returns the Edges field value
func (o *GraphDataResponse) GetEdges() []map[string]interface{} {
if o == nil {
var ret []map[string]interface{}
return ret
}
return o.Edges
}
// GetEdgesOk returns a tuple with the Edges field value
// and a boolean to check if the value has been set.
func (o *GraphDataResponse) GetEdgesOk() ([]map[string]interface{}, bool) {
if o == nil {
return nil, false
}
return o.Edges, true
}
// SetEdges sets field value
func (o *GraphDataResponse) SetEdges(v []map[string]interface{}) {
o.Edges = v
}
// GetTableRows returns the TableRows field value
func (o *GraphDataResponse) GetTableRows() []map[string]interface{} {
if o == nil {
var ret []map[string]interface{}
return ret
}
return o.TableRows
}
// GetTableRowsOk returns a tuple with the TableRows field value
// and a boolean to check if the value has been set.
func (o *GraphDataResponse) GetTableRowsOk() ([]map[string]interface{}, bool) {
if o == nil {
return nil, false
}
return o.TableRows, true
}
// SetTableRows sets field value
func (o *GraphDataResponse) SetTableRows(v []map[string]interface{}) {
o.TableRows = v
}
// GetTotalUnits returns the TotalUnits field value
func (o *GraphDataResponse) GetTotalUnits() int32 {
if o == nil {
var ret int32
return ret
}
return o.TotalUnits
}
// GetTotalUnitsOk returns a tuple with the TotalUnits field value
// and a boolean to check if the value has been set.
func (o *GraphDataResponse) GetTotalUnitsOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.TotalUnits, true
}
// SetTotalUnits sets field value
func (o *GraphDataResponse) SetTotalUnits(v int32) {
o.TotalUnits = v
}
// GetLimit returns the Limit field value
func (o *GraphDataResponse) 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 *GraphDataResponse) GetLimitOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Limit, true
}
// SetLimit sets field value
func (o *GraphDataResponse) SetLimit(v int32) {
o.Limit = v
}
func (o GraphDataResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o GraphDataResponse) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["nodes"] = o.Nodes
toSerialize["edges"] = o.Edges
toSerialize["table_rows"] = o.TableRows
toSerialize["total_units"] = o.TotalUnits
toSerialize["limit"] = o.Limit
return toSerialize, nil
}
func (o *GraphDataResponse) 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{
"nodes",
"edges",
"table_rows",
"total_units",
"limit",
}
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)
}
}
varGraphDataResponse := _GraphDataResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varGraphDataResponse)
if err != nil {
return err
}
*o = GraphDataResponse(varGraphDataResponse)
return err
}
type NullableGraphDataResponse struct {
value *GraphDataResponse
isSet bool
}
func (v NullableGraphDataResponse) Get() *GraphDataResponse {
return v.value
}
func (v *NullableGraphDataResponse) Set(val *GraphDataResponse) {
v.value = val
v.isSet = true
}
func (v NullableGraphDataResponse) IsSet() bool {
return v.isSet
}
func (v *NullableGraphDataResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableGraphDataResponse(val *GraphDataResponse) *NullableGraphDataResponse {
return &NullableGraphDataResponse{value: val, isSet: true}
}
func (v NullableGraphDataResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableGraphDataResponse) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,126 +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 HTTPValidationError type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &HTTPValidationError{}
// HTTPValidationError struct for HTTPValidationError
type HTTPValidationError struct {
Detail []ValidationError `json:"detail,omitempty"`
}
// NewHTTPValidationError instantiates a new HTTPValidationError 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 NewHTTPValidationError() *HTTPValidationError {
this := HTTPValidationError{}
return &this
}
// NewHTTPValidationErrorWithDefaults instantiates a new HTTPValidationError 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 NewHTTPValidationErrorWithDefaults() *HTTPValidationError {
this := HTTPValidationError{}
return &this
}
// GetDetail returns the Detail field value if set, zero value otherwise.
func (o *HTTPValidationError) GetDetail() []ValidationError {
if o == nil || IsNil(o.Detail) {
var ret []ValidationError
return ret
}
return o.Detail
}
// GetDetailOk returns a tuple with the Detail field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *HTTPValidationError) GetDetailOk() ([]ValidationError, bool) {
if o == nil || IsNil(o.Detail) {
return nil, false
}
return o.Detail, true
}
// HasDetail returns a boolean if a field has been set.
func (o *HTTPValidationError) HasDetail() bool {
if o != nil && !IsNil(o.Detail) {
return true
}
return false
}
// SetDetail gets a reference to the given []ValidationError and assigns it to the Detail field.
func (o *HTTPValidationError) SetDetail(v []ValidationError) {
o.Detail = v
}
func (o HTTPValidationError) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o HTTPValidationError) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Detail) {
toSerialize["detail"] = o.Detail
}
return toSerialize, nil
}
type NullableHTTPValidationError struct {
value *HTTPValidationError
isSet bool
}
func (v NullableHTTPValidationError) Get() *HTTPValidationError {
return v.value
}
func (v *NullableHTTPValidationError) Set(val *HTTPValidationError) {
v.value = val
v.isSet = true
}
func (v NullableHTTPValidationError) IsSet() bool {
return v.isSet
}
func (v *NullableHTTPValidationError) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableHTTPValidationError(val *HTTPValidationError) *NullableHTTPValidationError {
return &NullableHTTPValidationError{value: val, isSet: true}
}
func (v NullableHTTPValidationError) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableHTTPValidationError) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
@@ -1,182 +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 IncludeOptions type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &IncludeOptions{}
// IncludeOptions Options for including additional data in recall results.
type IncludeOptions struct {
Entities NullableEntityIncludeOptions `json:"entities,omitempty"`
Chunks NullableChunkIncludeOptions `json:"chunks,omitempty"`
}
// NewIncludeOptions instantiates a new IncludeOptions 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 NewIncludeOptions() *IncludeOptions {
this := IncludeOptions{}
return &this
}
// NewIncludeOptionsWithDefaults instantiates a new IncludeOptions 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 NewIncludeOptionsWithDefaults() *IncludeOptions {
this := IncludeOptions{}
return &this
}
// GetEntities returns the Entities field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *IncludeOptions) GetEntities() EntityIncludeOptions {
if o == nil || IsNil(o.Entities.Get()) {
var ret EntityIncludeOptions
return ret
}
return *o.Entities.Get()
}
// GetEntitiesOk returns a tuple with the Entities 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 *IncludeOptions) GetEntitiesOk() (*EntityIncludeOptions, bool) {
if o == nil {
return nil, false
}
return o.Entities.Get(), o.Entities.IsSet()
}
// HasEntities returns a boolean if a field has been set.
func (o *IncludeOptions) HasEntities() bool {
if o != nil && o.Entities.IsSet() {
return true
}
return false
}
// SetEntities gets a reference to the given NullableEntityIncludeOptions and assigns it to the Entities field.
func (o *IncludeOptions) SetEntities(v EntityIncludeOptions) {
o.Entities.Set(&v)
}
// SetEntitiesNil sets the value for Entities to be an explicit nil
func (o *IncludeOptions) SetEntitiesNil() {
o.Entities.Set(nil)
}
// UnsetEntities ensures that no value is present for Entities, not even an explicit nil
func (o *IncludeOptions) UnsetEntities() {
o.Entities.Unset()
}
// GetChunks returns the Chunks field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *IncludeOptions) GetChunks() ChunkIncludeOptions {
if o == nil || IsNil(o.Chunks.Get()) {
var ret ChunkIncludeOptions
return ret
}
return *o.Chunks.Get()
}
// GetChunksOk returns a tuple with the Chunks 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 *IncludeOptions) GetChunksOk() (*ChunkIncludeOptions, bool) {
if o == nil {
return nil, false
}
return o.Chunks.Get(), o.Chunks.IsSet()
}
// HasChunks returns a boolean if a field has been set.
func (o *IncludeOptions) HasChunks() bool {
if o != nil && o.Chunks.IsSet() {
return true
}
return false
}
// SetChunks gets a reference to the given NullableChunkIncludeOptions and assigns it to the Chunks field.
func (o *IncludeOptions) SetChunks(v ChunkIncludeOptions) {
o.Chunks.Set(&v)
}
// SetChunksNil sets the value for Chunks to be an explicit nil
func (o *IncludeOptions) SetChunksNil() {
o.Chunks.Set(nil)
}
// UnsetChunks ensures that no value is present for Chunks, not even an explicit nil
func (o *IncludeOptions) UnsetChunks() {
o.Chunks.Unset()
}
func (o IncludeOptions) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o IncludeOptions) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.Entities.IsSet() {
toSerialize["entities"] = o.Entities.Get()
}
if o.Chunks.IsSet() {
toSerialize["chunks"] = o.Chunks.Get()
}
return toSerialize, nil
}
type NullableIncludeOptions struct {
value *IncludeOptions
isSet bool
}
func (v NullableIncludeOptions) Get() *IncludeOptions {
return v.value
}
func (v *NullableIncludeOptions) Set(val *IncludeOptions) {
v.value = val
v.isSet = true
}
func (v NullableIncludeOptions) IsSet() bool {
return v.isSet
}
func (v *NullableIncludeOptions) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableIncludeOptions(val *IncludeOptions) *NullableIncludeOptions {
return &NullableIncludeOptions{value: val, isSet: true}
}
func (v NullableIncludeOptions) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableIncludeOptions) 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 ListDocumentsResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ListDocumentsResponse{}
// ListDocumentsResponse Response model for list documents endpoint.
type ListDocumentsResponse struct {
Items []map[string]interface{} `json:"items"`
Total int32 `json:"total"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type _ListDocumentsResponse ListDocumentsResponse
// NewListDocumentsResponse instantiates a new ListDocumentsResponse 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 NewListDocumentsResponse(items []map[string]interface{}, total int32, limit int32, offset int32) *ListDocumentsResponse {
this := ListDocumentsResponse{}
this.Items = items
this.Total = total
this.Limit = limit
this.Offset = offset
return &this
}
// NewListDocumentsResponseWithDefaults instantiates a new ListDocumentsResponse 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 NewListDocumentsResponseWithDefaults() *ListDocumentsResponse {
this := ListDocumentsResponse{}
return &this
}
// GetItems returns the Items field value
func (o *ListDocumentsResponse) GetItems() []map[string]interface{} {
if o == nil {
var ret []map[string]interface{}
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 *ListDocumentsResponse) GetItemsOk() ([]map[string]interface{}, bool) {
if o == nil {
return nil, false
}
return o.Items, true
}
// SetItems sets field value
func (o *ListDocumentsResponse) SetItems(v []map[string]interface{}) {
o.Items = v
}
// GetTotal returns the Total field value
func (o *ListDocumentsResponse) 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 *ListDocumentsResponse) GetTotalOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Total, true
}
// SetTotal sets field value
func (o *ListDocumentsResponse) SetTotal(v int32) {
o.Total = v
}
// GetLimit returns the Limit field value
func (o *ListDocumentsResponse) 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 *ListDocumentsResponse) GetLimitOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Limit, true
}
// SetLimit sets field value
func (o *ListDocumentsResponse) SetLimit(v int32) {
o.Limit = v
}
// GetOffset returns the Offset field value
func (o *ListDocumentsResponse) 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 *ListDocumentsResponse) GetOffsetOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Offset, true
}
// SetOffset sets field value
func (o *ListDocumentsResponse) SetOffset(v int32) {
o.Offset = v
}
func (o ListDocumentsResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ListDocumentsResponse) 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 *ListDocumentsResponse) 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)
}
}
varListDocumentsResponse := _ListDocumentsResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varListDocumentsResponse)
if err != nil {
return err
}
*o = ListDocumentsResponse(varListDocumentsResponse)
return err
}
type NullableListDocumentsResponse struct {
value *ListDocumentsResponse
isSet bool
}
func (v NullableListDocumentsResponse) Get() *ListDocumentsResponse {
return v.value
}
func (v *NullableListDocumentsResponse) Set(val *ListDocumentsResponse) {
v.value = val
v.isSet = true
}
func (v NullableListDocumentsResponse) IsSet() bool {
return v.isSet
}
func (v *NullableListDocumentsResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableListDocumentsResponse(val *ListDocumentsResponse) *NullableListDocumentsResponse {
return &NullableListDocumentsResponse{value: val, isSet: true}
}
func (v NullableListDocumentsResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableListDocumentsResponse) 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 ListMemoryUnitsResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ListMemoryUnitsResponse{}
// ListMemoryUnitsResponse Response model for list memory units endpoint.
type ListMemoryUnitsResponse struct {
Items []map[string]interface{} `json:"items"`
Total int32 `json:"total"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type _ListMemoryUnitsResponse ListMemoryUnitsResponse
// NewListMemoryUnitsResponse instantiates a new ListMemoryUnitsResponse 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 NewListMemoryUnitsResponse(items []map[string]interface{}, total int32, limit int32, offset int32) *ListMemoryUnitsResponse {
this := ListMemoryUnitsResponse{}
this.Items = items
this.Total = total
this.Limit = limit
this.Offset = offset
return &this
}
// NewListMemoryUnitsResponseWithDefaults instantiates a new ListMemoryUnitsResponse 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 NewListMemoryUnitsResponseWithDefaults() *ListMemoryUnitsResponse {
this := ListMemoryUnitsResponse{}
return &this
}
// GetItems returns the Items field value
func (o *ListMemoryUnitsResponse) GetItems() []map[string]interface{} {
if o == nil {
var ret []map[string]interface{}
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 *ListMemoryUnitsResponse) GetItemsOk() ([]map[string]interface{}, bool) {
if o == nil {
return nil, false
}
return o.Items, true
}
// SetItems sets field value
func (o *ListMemoryUnitsResponse) SetItems(v []map[string]interface{}) {
o.Items = v
}
// GetTotal returns the Total field value
func (o *ListMemoryUnitsResponse) 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 *ListMemoryUnitsResponse) GetTotalOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Total, true
}
// SetTotal sets field value
func (o *ListMemoryUnitsResponse) SetTotal(v int32) {
o.Total = v
}
// GetLimit returns the Limit field value
func (o *ListMemoryUnitsResponse) 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 *ListMemoryUnitsResponse) GetLimitOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Limit, true
}
// SetLimit sets field value
func (o *ListMemoryUnitsResponse) SetLimit(v int32) {
o.Limit = v
}
// GetOffset returns the Offset field value
func (o *ListMemoryUnitsResponse) 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 *ListMemoryUnitsResponse) GetOffsetOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.Offset, true
}
// SetOffset sets field value
func (o *ListMemoryUnitsResponse) SetOffset(v int32) {
o.Offset = v
}
func (o ListMemoryUnitsResponse) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ListMemoryUnitsResponse) 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 *ListMemoryUnitsResponse) 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)
}
}
varListMemoryUnitsResponse := _ListMemoryUnitsResponse{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varListMemoryUnitsResponse)
if err != nil {
return err
}
*o = ListMemoryUnitsResponse(varListMemoryUnitsResponse)
return err
}
type NullableListMemoryUnitsResponse struct {
value *ListMemoryUnitsResponse
isSet bool
}
func (v NullableListMemoryUnitsResponse) Get() *ListMemoryUnitsResponse {
return v.value
}
func (v *NullableListMemoryUnitsResponse) Set(val *ListMemoryUnitsResponse) {
v.value = val
v.isSet = true
}
func (v NullableListMemoryUnitsResponse) IsSet() bool {
return v.isSet
}
func (v *NullableListMemoryUnitsResponse) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableListMemoryUnitsResponse(val *ListMemoryUnitsResponse) *NullableListMemoryUnitsResponse {
return &NullableListMemoryUnitsResponse{value: val, isSet: true}
}
func (v NullableListMemoryUnitsResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableListMemoryUnitsResponse) 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