From 76085724e07edfad97e1f7f06870f38786e0978c Mon Sep 17 00:00:00 2001 From: Vineeth Voruganti <13438633+VVoruganti@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:38:02 -0500 Subject: [PATCH] Release v0.0.14 (#78) * fix(storage) Remove Prepared Statements to make compatible with Supavisor * fix(deriver and dialectic) Use latest user level user_represenation * fix(storage) Switch to text columns for best postgres practices * fix(storage) Update docstrings and document query method * chore(release) v0.0.14 Release State * chore(release) CHANGELOG * fix(deriver) Add more detailed profiling with sentry * chore(release) CHANGELOG * fix(deriver) increase retry limit on anthropic --- CHANGELOG.md | 14 + README.md | 2 +- .../endpoint/documents/query-documents.mdx | 4 +- docs/getting-started/quickstart.mdx | 14 +- docs/openapi.yml | 7769 ++++++++--------- pyproject.toml | 2 +- src/agent.py | 1 + src/db.py | 6 +- src/deriver/__main__.py | 4 +- src/deriver/consumer.py | 29 +- src/deriver/queue.py | 97 +- src/deriver/voe.py | 5 +- src/main.py | 2 +- src/models.py | 78 +- src/routers/apps.py | 51 +- src/routers/collections.py | 17 +- src/routers/documents.py | 46 +- src/routers/messages.py | 37 +- src/routers/metamessages.py | 64 +- src/routers/sessions.py | 76 +- src/routers/users.py | 72 +- src/schemas.py | 6 + tests/routes/test_documents.py | 45 + uv.lock | 2 +- 24 files changed, 4043 insertions(+), 4400 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49bad3c..71dba66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.0.14] — 2024-11-14 + +### Changed + +- Query Documents endpoint is a POST request for better DX +- `String` columns are now `TEXT` columns to match postgres best practices +- Docstrings to have better stainless generations + +### Fixed + +- Dialectic API to use most recent user representation +- Prepared Statements Transient Error with `psycopg` +- Queue parallel worker scheduling + ## [0.0.13] — 2024-11-07 ### Added diff --git a/README.md b/README.md index 748cb63..d79945a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🫡 Honcho -![Static Badge](https://img.shields.io/badge/Version-0.0.13-blue) +![Static Badge](https://img.shields.io/badge/Version-0.0.14-blue) [![Discord](https://img.shields.io/discord/1016845111637839922?style=flat&logo=discord&logoColor=23ffffff&label=Plastic%20Labs&labelColor=235865F2)](https://discord.gg/plasticlabs) [![arXiv](https://img.shields.io/badge/arXiv-2310.06983-b31b1b.svg)](https://arxiv.org/abs/2310.06983) ![GitHub License](https://img.shields.io/github/license/plastic-labs/honcho) diff --git a/docs/api-reference/endpoint/documents/query-documents.mdx b/docs/api-reference/endpoint/documents/query-documents.mdx index ca97f4e..687d868 100644 --- a/docs/api-reference/endpoint/documents/query-documents.mdx +++ b/docs/api-reference/endpoint/documents/query-documents.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/query ---- \ No newline at end of file +openapi: POST /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/query +--- diff --git a/docs/getting-started/quickstart.mdx b/docs/getting-started/quickstart.mdx index 0c72def..5ebe4fb 100644 --- a/docs/getting-started/quickstart.mdx +++ b/docs/getting-started/quickstart.mdx @@ -49,7 +49,7 @@ Next, we want to register an application with the Honcho client: ```python Python -app = client.apps.get_or_create( +app = honcho.apps.get_or_create( name="string", ) ``` @@ -81,11 +81,11 @@ Now let's create a session for that application. Honcho is a user context manage ```python Python -session = client.apps.users.sessions.create(user.id, app.id, location_id=default) +session = honcho.apps.users.sessions.create(user.id, app.id) ``` ```javascript NodeJS -const session = client.apps.users.sessions.create(app.id, user.id, { location_id: "default"}) -> Session +const session = honcho.apps.users.sessions.create(app.id, user.id) -> Session ``` @@ -95,11 +95,11 @@ Let's add a user message and an AI message to that session: ```python Python -client.apps.users.sessions.messages.create(session.id, app.id, user.id, content="Test", is_user=True) +honcho.apps.users.sessions.messages.create(session.id, app.id, user.id, content="Test", is_user=True) ``` ```javascript NodeJS -client.apps.users.sessions.messages.create(app.id, user.id, session.id, { content: "Test", is_user: true }) +honcho.apps.users.sessions.messages.create(app.id, user.id, session.id, { content: "Test", is_user: true }) ``` @@ -109,7 +109,7 @@ You can also easily query Honcho to get the session objects for that user with t ```python Python -async for session in client.apps.users.list(app.id, user.id): +async for session in honcho.apps.users.list(app.id, user.id): doSomethingWith(session) ``` @@ -124,4 +124,4 @@ for await (const session of honcho.apps.users.sessions.list(app.id, user.id)) { This is a super simple overview of how to get up and running with the Honcho SDK. We covered the basic methods for reading and writing from the hosted storage service. Next, we'll cover alternative forms of hosting Honcho. -For a more detailed look at the SDK check out the SDK reference [here](https://api.python.honcho.dev/). \ No newline at end of file +For a more detailed look at the SDK check out the SDK reference [here](/api-reference). diff --git a/docs/openapi.yml b/docs/openapi.yml index 98e0ba1..c8e8162 100644 --- a/docs/openapi.yml +++ b/docs/openapi.yml @@ -1,3910 +1,408 @@ -openapi: 3.1.0 -info: - title: Honcho API - summary: An API for adding personalization to AI Apps - description: |- - This API is used to store data and get insights about users for AI - applications - contact: - name: Plastic Labs - url: https://plasticlabs.ai/ - email: hello@plasticlabs.ai - version: 0.0.13 -servers: - - url: http://127.0.0.1:8000 - description: Local Development Server - - url: https:/demo.honcho.dev - description: Demo Server -paths: - /v1/apps/{app_id}: - get: - tags: - - apps - summary: Get App - description: |- - Get an App by ID - - Args: - app_id (str): The ID of the app - - Returns: - schemas.App: App object - operationId: get_app_v1_apps__app_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/App' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const app = await client.apps.get('app_id'); - - console.log(app.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - app = client.apps.get( - "app_id", - ) - print(app.id) - put: - tags: - - apps - summary: Update App - description: |- - Update an App - - Args: - app_id (str): The ID of the app to update - app (schemas.AppUpdate): The App object containing any new metadata - - Returns: - schemas.App: The App object of the updated App - operationId: update_app_v1_apps__app_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AppUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/App' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const app = await client.apps.update('app_id'); - - console.log(app.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - app = client.apps.update( - app_id="app_id", - ) - print(app.id) - /v1/apps/name/{name}: - get: - tags: - - apps - summary: Get App By Name - description: |- - Get an App by Name - - Args: - app_name (str): The name of the app - - Returns: - schemas.App: App object - operationId: get_app_by_name_v1_apps_name__name__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: name - in: path - required: true - schema: - type: string - title: Name - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/App' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const app = await client.apps.getByName('name'); - - console.log(app.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - app = client.apps.get_by_name( - "name", - ) - print(app.id) - /v1/apps: - post: - tags: - - apps - summary: Create App - description: |- - Create an App - - Args: - app (schemas.AppCreate): The App object containing any metadata - - Returns: - schemas.App: Created App object - operationId: create_app_v1_apps_post - requestBody: +components: + schemas: + AgentChat: + properties: content: - application/json: - schema: - $ref: '#/components/schemas/AppCreate' - required: true - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/App' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - security: - - HTTPBearer: [] - - {} - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const app = await client.apps.create({ name: 'name' }); - - console.log(app.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - app = client.apps.create( - name="name", - ) - print(app.id) - /v1/apps/get_or_create/{name}: - get: - tags: - - apps - summary: Get Or Create App - description: |- - Get or Create an App - - Args: - app_name (str): The name of the app - - Returns: - schemas.App: App object - operationId: get_or_create_app_v1_apps_get_or_create__name__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: name - in: path - required: true - schema: - type: string - title: Name - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/App' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const app = await client.apps.getOrCreate('name'); - - console.log(app.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - app = client.apps.get_or_create( - "name", - ) - print(app.id) - /v1/apps/{app_id}/users: - post: - tags: - - users - summary: Create User - description: |- - Create a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user (schemas.UserCreate): The User object containing any metadata - - Returns: - schemas.User: Created User object - operationId: create_user_v1_apps__app_id__users_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - requestBody: - required: true + title: Content + type: string + required: + - content + title: AgentChat + type: object + AgentQuery: + properties: + queries: + anyOf: + - type: string + - items: + type: string + type: array + title: Queries + required: + - queries + title: AgentQuery + type: object + App: + exclude: + - h_metadata + - public_id + properties: + created_at: + format: date-time + title: Created At + type: string + id: + title: Id + type: string + metadata: + additionalProperties: true + title: Metadata + type: object + name: + title: Name + type: string + required: + - id + - name + - metadata + - created_at + title: App + type: object + AppCreate: + properties: + metadata: + additionalProperties: true + default: {} + title: Metadata + type: object + name: + title: Name + type: string + required: + - name + title: AppCreate + type: object + AppUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + name: + anyOf: + - type: string + - type: 'null' + title: Name + title: AppUpdate + type: object + Collection: + exclude: + - h_metadata + - public_id + properties: + created_at: + format: date-time + title: Created At + type: string + id: + title: Id + type: string + metadata: + additionalProperties: true + title: Metadata + type: object + name: + title: Name + type: string + user_id: + title: User Id + type: string + required: + - id + - name + - user_id + - metadata + - created_at + title: Collection + type: object + CollectionCreate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + default: {} + title: Metadata + name: + title: Name + type: string + required: + - name + title: CollectionCreate + type: object + CollectionGet: + properties: + filter: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filter + title: CollectionGet + type: object + CollectionUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + name: + anyOf: + - type: string + - type: 'null' + title: Name + title: CollectionUpdate + type: object + Document: + exclude: + - h_metadata + - public_id + properties: + collection_id: + title: Collection Id + type: string content: - application/json: - schema: - $ref: '#/components/schemas/UserCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const user = await client.apps.users.create('app_id', { name: 'name' }); - - console.log(user.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - user = client.apps.users.create( - app_id="app_id", - name="name", - ) - print(user.id) - /v1/apps/{app_id}/users/list: - post: - tags: - - users - summary: Get Users - description: |- - Get All Users for an App - - Args: - app_id (str): The ID of the app representing the client - application using honcho - - Returns: - list[schemas.User]: List of User objects - operationId: get_users_v1_apps__app_id__users_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: reverse - in: query - required: false - schema: - type: boolean - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/UserGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_User_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const user of client.apps.users.list('app_id')) { - console.log(user.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.list( - app_id="app_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/name/{name}: - get: - tags: - - users - summary: Get User By Name - description: |- - Get a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - operationId: get_user_by_name_v1_apps__app_id__users_name__name__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: name - in: path - required: true - schema: - type: string - title: Name - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const user = await client.apps.users.getByName('app_id', 'name'); - - console.log(user.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - user = client.apps.users.get_by_name( - name="name", - app_id="app_id", - ) - print(user.id) - /v1/apps/{app_id}/users/{user_id}: - get: - tags: - - users - summary: Get User - description: |- - Get a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - operationId: get_user_v1_apps__app_id__users__user_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const user = await client.apps.users.get('app_id', 'user_id'); - - console.log(user.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - user = client.apps.users.get( - user_id="user_id", - app_id="app_id", - ) - print(user.id) - put: - tags: - - users - summary: Update User - description: |- - Update a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - user (schemas.UserCreate): The User object containing any metadata - - Returns: - schemas.User: Updated User object - operationId: update_user_v1_apps__app_id__users__user_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - requestBody: - required: true + title: Content + type: string + created_at: + format: date-time + title: Created At + type: string + id: + title: Id + type: string + metadata: + additionalProperties: true + title: Metadata + type: object + required: + - id + - content + - metadata + - created_at + - collection_id + title: Document + type: object + DocumentCreate: + properties: content: - application/json: - schema: - $ref: '#/components/schemas/UserUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const user = await client.apps.users.update('app_id', 'user_id'); - - console.log(user.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - user = client.apps.users.update( - user_id="user_id", - app_id="app_id", - ) - print(user.id) - /v1/apps/{app_id}/users/get_or_create/{name}: - get: - tags: - - users - summary: Get Or Create User - description: |- - Get or Create a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - operationId: get_or_create_user_v1_apps__app_id__users_get_or_create__name__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: name - in: path - required: true - schema: - type: string - title: Name - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/User' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const user = await client.apps.users.getOrCreate('app_id', 'name'); - - console.log(user.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - user = client.apps.users.get_or_create( - name="name", - app_id="app_id", - ) - print(user.id) - /v1/apps/{app_id}/users/{user_id}/sessions/list: - post: - tags: - - sessions - summary: Get Sessions - description: |- - Get All Sessions for a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - list[schemas.Session]: List of Session objects - operationId: get_sessions_v1_apps__app_id__users__user_id__sessions_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true + title: Content + type: string + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + default: {} + title: Metadata + required: + - content + title: DocumentCreate + type: object + DocumentGet: + properties: + filter: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filter + title: DocumentGet + type: object + DocumentQuery: + properties: + filter: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filter + query: + title: Query + type: string + top_k: + default: 5 + title: Top K + type: integer + required: + - query + title: DocumentQuery + type: object + DocumentUpdate: + properties: content: - application/json: - schema: - $ref: '#/components/schemas/SessionGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Session_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const session of client.apps.users.sessions.list('app_id', 'user_id')) { - console.log(session.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.sessions.list( - user_id="user_id", - app_id="app_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/sessions: - post: - tags: - - sessions - summary: Create Session - description: |- - Create a Session for a User - - Args: - app_id (str): The ID of the app representing the client - application using honcho - user_id (str): The User ID representing the user, managed by the user - session (schemas.SessionCreate): The Session object containing any - metadata - - Returns: - schemas.Session: The Session object of the new Session - operationId: create_session_v1_apps__app_id__users__user_id__sessions_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - requestBody: - required: true + anyOf: + - type: string + - type: 'null' + title: Content + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + title: DocumentUpdate + type: object + HTTPValidationError: + properties: + detail: + items: + $ref: '#/components/schemas/ValidationError' + title: Detail + type: array + title: HTTPValidationError + type: object + Message: + exclude: + - h_metadata + - public_id + properties: content: - application/json: - schema: - $ref: '#/components/schemas/SessionCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Session' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const session = await client.apps.users.sessions.create('app_id', 'user_id'); - - console.log(session.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - session = client.apps.users.sessions.create( - user_id="user_id", - app_id="app_id", - ) - print(session.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}: - put: - tags: - - sessions - summary: Update Session - description: |- - Update the metadata of a Session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to update - session (schemas.SessionUpdate): The Session object containing any new metadata - - Returns: - schemas.Session: The Session object of the updated Session - operationId: update_session_v1_apps__app_id__users__user_id__sessions__session_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - requestBody: - required: true + title: Content + type: string + created_at: + format: date-time + title: Created At + type: string + id: + title: Id + type: string + is_user: + title: Is User + type: boolean + metadata: + additionalProperties: true + title: Metadata + type: object + session_id: + title: Session Id + type: string + required: + - id + - content + - is_user + - session_id + - metadata + - created_at + title: Message + type: object + MessageCreate: + properties: content: - application/json: - schema: - $ref: '#/components/schemas/SessionUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Session' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const session = await client.apps.users.sessions.update('app_id', 'user_id', 'session_id'); - - console.log(session.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - session = client.apps.users.sessions.update( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - print(session.id) - delete: - tags: - - sessions - summary: Delete Session - description: |- - Delete a session by marking it as inactive - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to delete - - Returns: - dict: A message indicating that the session was deleted - - Raises: - HTTPException: If the session is not found - operationId: delete_session_v1_apps__app_id__users__user_id__sessions__session_id__delete - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: {} - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const session = await client.apps.users.sessions.delete('app_id', 'user_id', 'session_id'); - - console.log(session); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - session = client.apps.users.sessions.delete( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - print(session) - get: - tags: - - sessions - summary: Get Session - description: |- - Get a specific session for a user by ID - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to retrieve - - Returns: - schemas.Session: The Session object of the requested Session - - Raises: - HTTPException: If the session is not found - operationId: get_session_v1_apps__app_id__users__user_id__sessions__session_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Session' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const session = await client.apps.users.sessions.get('app_id', 'user_id', 'session_id'); - - console.log(session.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - session = client.apps.users.sessions.get( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - print(session.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/chat: - post: - tags: - - sessions - summary: Chat - operationId: chat_v1_apps__app_id__users__user_id__sessions__session_id__chat_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - requestBody: - required: true + title: Content + type: string + is_user: + title: Is User + type: boolean + metadata: + additionalProperties: true + default: {} + title: Metadata + type: object + required: + - content + - is_user + title: MessageCreate + type: object + MessageGet: + properties: + filter: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Filter + title: MessageGet + type: object + MessageUpdate: + properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + title: MessageUpdate + type: object + Metamessage: + exclude: + - h_metadata + - public_id + properties: content: - application/json: - schema: - $ref: '#/components/schemas/AgentQuery' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/AgentChat' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const agentChat = await client.apps.users.sessions.chat('app_id', 'user_id', 'session_id', { - queries: 'string', - }); - - console.log(agentChat.content); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - agent_chat = client.apps.users.sessions.chat( - session_id="session_id", - app_id="app_id", - user_id="user_id", - queries="string", - ) - print(agent_chat.content) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/chat/stream: - post: - tags: - - sessions - summary: Get Chat Stream - operationId: get_chat_stream_v1_apps__app_id__users__user_id__sessions__session_id__chat_stream_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - requestBody: - required: true + title: Content + type: string + created_at: + format: date-time + title: Created At + type: string + id: + title: Id + type: string + message_id: + title: Message Id + type: string + metadata: + additionalProperties: true + title: Metadata + type: object + metamessage_type: + title: Metamessage Type + type: string + required: + - id + - metamessage_type + - content + - message_id + - metadata + - created_at + title: Metamessage + type: object + MetamessageCreate: + properties: content: - application/json: - schema: - $ref: '#/components/schemas/AgentQuery' - responses: - '200': - description: Chat stream - content: - application/json: - schema: {} - text/event-stream: - schema: - type: string - format: binary - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const response = await client.apps.users.sessions.stream('app_id', 'user_id', 'session_id', { - queries: 'string', - }); - - console.log(response); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - response = client.apps.users.sessions.stream( - session_id="session_id", - app_id="app_id", - user_id="user_id", - queries="string", - ) - print(response) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/clone: - get: - tags: - - sessions - summary: Clone Session - operationId: clone_session_v1_apps__app_id__users__user_id__sessions__session_id__clone_get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: message_id - in: query - required: false - schema: - anyOf: - - type: string - - type: 'null' - title: Message Id - - name: deep_copy - in: query - required: false - schema: - type: boolean - default: false - title: Deep Copy - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Session' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const session = await client.apps.users.sessions.clone('app_id', 'user_id', 'session_id'); - - console.log(session.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - session = client.apps.users.sessions.clone( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - print(session.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages: - post: - tags: - - messages - summary: Create Message For Session - description: |- - Adds a message to a session - - Args: - app_id (str): The ID of the app representing the client application using honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to add the message to - message (schemas.MessageCreate): The Message object to add containing the message content and type - - Returns: - schemas.Message: The Message object of the added message - - Raises: - HTTPException: If the session is not found - operationId: create_message_for_session_v1_apps__app_id__users__user_id__sessions__session_id__messages_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MessageCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const message = await client.apps.users.sessions.messages.create('app_id', 'user_id', 'session_id', { - content: 'content', - is_user: true, - }); - - console.log(message.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - message = client.apps.users.sessions.messages.create( - session_id="session_id", - app_id="app_id", - user_id="user_id", - content="content", - is_user=True, - ) - print(message.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/list: - post: - tags: - - messages - summary: Get Messages - description: |- - Get all messages for a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - reverse (bool): Whether to reverse the order of the messages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - operationId: get_messages_v1_apps__app_id__users__user_id__sessions__session_id__messages_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MessageGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Message_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const message of client.apps.users.sessions.messages.list('app_id', 'user_id', 'session_id')) { - console.log(message.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.sessions.messages.list( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}: - get: - tags: - - messages - summary: Get Message - operationId: get_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: message_id - in: path - required: true - schema: - type: string - title: Message Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const message = await client.apps.users.sessions.messages.get( - 'app_id', - 'user_id', - 'session_id', - 'message_id', - ); - - console.log(message.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - message = client.apps.users.sessions.messages.get( - message_id="message_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - ) - print(message.id) - put: - tags: - - messages - summary: Update Message - description: Update's the metadata of a message - operationId: update_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: message_id - in: path - required: true - schema: - type: string - title: Message Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MessageUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Message' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const message = await client.apps.users.sessions.messages.update( - 'app_id', - 'user_id', - 'session_id', - 'message_id', - ); - - console.log(message.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - message = client.apps.users.sessions.messages.update( - message_id="message_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - ) - print(message.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages: - post: - tags: - - metamessages - summary: Create Metamessage - description: |- - Adds a message to a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to add the message to - metamessage (schemas.MeteamessageCreate): The metamessage creation object - - Returns: - schemas.Metamessage: The Metamessage object of the added metamessage - - Raises: - HTTPException: If the session is not found - operationId: create_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MetamessageCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Metamessage' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const metamessage = await client.apps.users.sessions.metamessages.create( - 'app_id', - 'user_id', - 'session_id', - { content: 'content', message_id: 'message_id', metamessage_type: 'metamessage_type' }, - ); - - console.log(metamessage.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - metamessage = client.apps.users.sessions.metamessages.create( - session_id="session_id", - app_id="app_id", - user_id="user_id", - content="content", - message_id="message_id", - metamessage_type="metamessage_type", - ) - print(metamessage.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages/list: - post: - tags: - - metamessages - summary: Get Metamessages - description: |- - Get all messages for a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - reverse (bool): Whether to reverse the order of the metamessages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - operationId: get_metamessages_v1_apps__app_id__users__user_id__sessions__session_id__metamessages_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MetamessageGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Metamessage_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const metamessage of client.apps.users.sessions.metamessages.list( - 'app_id', - 'user_id', - 'session_id', - )) { - console.log(metamessage.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.sessions.metamessages.list( - session_id="session_id", - app_id="app_id", - user_id="user_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages/{metamessage_id}: - get: - tags: - - metamessages - summary: Get Metamessage - description: |- - Get a specific Metamessage by ID - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - - Returns: - schemas.Session: The Session object of the requested Session - - Raises: - HTTPException: If the session is not found - operationId: >- - get_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages__metamessage_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: metamessage_id - in: path - required: true - schema: - type: string - title: Metamessage Id - - name: message_id - in: query - required: true - schema: - type: string - title: Message Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Metamessage' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const metamessage = await client.apps.users.sessions.metamessages.get( - 'app_id', - 'user_id', - 'session_id', - 'metamessage_id', - { message_id: 'message_id' }, - ); - - console.log(metamessage.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - metamessage = client.apps.users.sessions.metamessages.get( - metamessage_id="metamessage_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - message_id="message_id", - ) - print(metamessage.id) - put: - tags: - - metamessages - summary: Update Metamessage - description: Update's the metadata of a metamessage - operationId: >- - update_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages__metamessage_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: session_id - in: path - required: true - schema: - type: string - title: Session Id - - name: metamessage_id - in: path - required: true - schema: - type: string - title: Metamessage Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MetamessageUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Metamessage' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const metamessage = await client.apps.users.sessions.metamessages.update( - 'app_id', - 'user_id', - 'session_id', - 'metamessage_id', - { message_id: 'message_id' }, - ); - - console.log(metamessage.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - metamessage = client.apps.users.sessions.metamessages.update( - metamessage_id="metamessage_id", - app_id="app_id", - user_id="user_id", - session_id="session_id", - message_id="message_id", - ) - print(metamessage.id) - /v1/apps/{app_id}/users/{user_id}/metamessages/list: - post: - tags: - - metamessages - summary: Get Metamessages By User - description: |- - Paginate through the user metamessages for a user - - Args: - app_id (str): The ID of the app representing the client application using honcho - user_id (str): The User ID representing the user, managed by the user - reverse (bool): Whether to reverse the order of the metamessages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - operationId: get_metamessages_by_user_v1_apps__app_id__users__user_id__metamessages_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MetamessageGetUserLevel' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Metamessage_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const metamessage of client.apps.users.metamessages.list('app_id', 'user_id')) { - console.log(metamessage.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.metamessages.list( - user_id="user_id", - app_id="app_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/collections/list: - post: - tags: - - collections - summary: Get Collections - description: |- - Get All Collections for a User - - Args: - app_id (str): The ID of the app representing the client - application using honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - list[schemas.Collection]: List of Collection objects - operationId: get_collections_v1_apps__app_id__users__user_id__collections_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Collection_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const collection of client.apps.users.collections.list('app_id', 'user_id')) { - console.log(collection.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.collections.list( - user_id="user_id", - app_id="app_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/collections/name/{name}: - get: - tags: - - collections - summary: Get Collection By Name - operationId: get_collection_by_name_v1_apps__app_id__users__user_id__collections_name__name__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: name - in: path - required: true - schema: - type: string - title: Name - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Collection' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const collection = await client.apps.users.collections.getByName('app_id', 'user_id', 'name'); - - console.log(collection.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - collection = client.apps.users.collections.get_by_name( - name="name", - app_id="app_id", - user_id="user_id", - ) - print(collection.id) - /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}: - get: - tags: - - collections - summary: Get Collection By Id - operationId: get_collection_by_id_v1_apps__app_id__users__user_id__collections__collection_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Collection' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const collection = await client.apps.users.collections.get('app_id', 'user_id', 'collection_id'); - - console.log(collection.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - collection = client.apps.users.collections.get( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - ) - print(collection.id) - put: - tags: - - collections - summary: Update Collection - operationId: update_collection_v1_apps__app_id__users__user_id__collections__collection_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Collection' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const collection = await client.apps.users.collections.update('app_id', 'user_id', 'collection_id'); - - console.log(collection.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - collection = client.apps.users.collections.update( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - ) - print(collection.id) - delete: - tags: - - collections - summary: Delete Collection - operationId: delete_collection_v1_apps__app_id__users__user_id__collections__collection_id__delete - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: {} - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const collection = await client.apps.users.collections.delete('app_id', 'user_id', 'collection_id'); - - console.log(collection); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - collection = client.apps.users.collections.delete( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - ) - print(collection) - /v1/apps/{app_id}/users/{user_id}/collections: - post: - tags: - - collections - summary: Create Collection - operationId: create_collection_v1_apps__app_id__users__user_id__collections_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Collection' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const collection = await client.apps.users.collections.create('app_id', 'user_id', { name: 'name' }); - - console.log(collection.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - collection = client.apps.users.collections.create( - user_id="user_id", - app_id="app_id", - name="name", - ) - print(collection.id) - /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/list: - post: - tags: - - documents - summary: Get Documents - operationId: get_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_list_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - - name: reverse - in: query - required: false - schema: - anyOf: - - type: boolean - - type: 'null' - default: false - title: Reverse - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - description: Page number - default: 1 - title: Page - description: Page number - - name: size - in: query - required: false - schema: - type: integer - maximum: 100 - minimum: 1 - description: Page size - default: 50 - title: Size - description: Page size - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/DocumentGet' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Page_Document_' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - // Automatically fetches more pages as needed. - for await (const document of client.apps.users.collections.documents.list( - 'app_id', - 'user_id', - 'collection_id', - )) { - console.log(document.id); - } - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - page = client.apps.users.collections.documents.list( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - ) - page = page.items[0] - print(page.id) - /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/{document_id}: - get: - tags: - - documents - summary: Get Document - operationId: get_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - - name: document_id - in: path - required: true - schema: - type: string - title: Document Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const document = await client.apps.users.collections.documents.get( - 'app_id', - 'user_id', - 'collection_id', - 'document_id', - ); - - console.log(document.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - document = client.apps.users.collections.documents.get( - document_id="document_id", - app_id="app_id", - user_id="user_id", - collection_id="collection_id", - ) - print(document.id) - put: - tags: - - documents - summary: Update Document - operationId: >- - update_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__put - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - - name: document_id - in: path - required: true - schema: - type: string - title: Document Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/DocumentUpdate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const document = await client.apps.users.collections.documents.update( - 'app_id', - 'user_id', - 'collection_id', - 'document_id', - ); - - console.log(document.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - document = client.apps.users.collections.documents.update( - document_id="document_id", - app_id="app_id", - user_id="user_id", - collection_id="collection_id", - ) - print(document.id) - delete: - tags: - - documents - summary: Delete Document - operationId: >- - delete_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__delete - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - - name: document_id - in: path - required: true - schema: - type: string - title: Document Id - responses: - '200': - description: Successful Response - content: - application/json: - schema: {} - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const document = await client.apps.users.collections.documents.delete( - 'app_id', - 'user_id', - 'collection_id', - 'document_id', - ); - - console.log(document); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - document = client.apps.users.collections.documents.delete( - document_id="document_id", - app_id="app_id", - user_id="user_id", - collection_id="collection_id", - ) - print(document) - /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/query: - get: - tags: - - documents - summary: Query Documents - operationId: query_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_query_get - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - - name: query - in: query - required: true - schema: - type: string - title: Query - - name: top_k - in: query - required: false - schema: - type: integer - default: 5 - title: Top K - - name: filter - in: query - required: false - schema: - anyOf: - - type: string - - type: 'null' - title: Filter - responses: - '200': - description: Successful Response - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Document' - title: >- - Response Query Documents V1 Apps App Id Users User Id Collections Collection Id - Documents Query Get - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const documents = await client.apps.users.collections.documents.query( - 'app_id', - 'user_id', - 'collection_id', - { query: 'query' }, - ); - - console.log(documents); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - documents = client.apps.users.collections.documents.query( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - query="query", - ) - print(documents) - /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents: - post: - tags: - - documents - summary: Create Document - operationId: create_document_v1_apps__app_id__users__user_id__collections__collection_id__documents_post - security: - - HTTPBearer: [] - - {} - parameters: - - name: app_id - in: path - required: true - schema: - type: string - title: App Id - - name: user_id - in: path - required: true - schema: - type: string - title: User Id - - name: collection_id - in: path - required: true - schema: - type: string - title: Collection Id - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/DocumentCreate' - responses: - '200': - description: Successful Response - content: - application/json: - schema: - $ref: '#/components/schemas/Document' - '422': - description: Validation Error - content: - application/json: - schema: - $ref: '#/components/schemas/HTTPValidationError' - x-codeSamples: - - lang: JavaScript - source: |- - import Honcho from 'honcho'; - - const client = new Honcho({ - apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted - }); - - async function main() { - const document = await client.apps.users.collections.documents.create( - 'app_id', - 'user_id', - 'collection_id', - { content: 'content' }, - ); - - console.log(document.id); - } - - main(); - - lang: Python - source: |- - import os - from honcho import Honcho - - client = Honcho( - # This is the default and can be omitted - api_key=os.environ.get("HONCHO_API_KEY"), - ) - document = client.apps.users.collections.documents.create( - collection_id="collection_id", - app_id="app_id", - user_id="user_id", - content="content", - ) - print(document.id) -components: - schemas: - AgentChat: - properties: - content: - type: string - title: Content - type: object - required: - - content - title: AgentChat - AgentQuery: - properties: - queries: - anyOf: - - type: string - - items: - type: string - type: array - title: Queries - type: object - required: - - queries - title: AgentQuery - App: - properties: - id: - type: string - title: Id - name: - type: string - title: Name - metadata: - type: object - title: Metadata - additionalProperties: true - created_at: - type: string - format: date-time - title: Created At - type: object - required: - - id - - name - - metadata - - created_at - title: App - exclude: - - h_metadata - - public_id - AppCreate: - properties: - name: - type: string - title: Name - metadata: - type: object - title: Metadata - default: {} - additionalProperties: true - type: object - required: - - name - title: AppCreate - AppUpdate: - properties: - name: - anyOf: - - type: string - - type: 'null' - title: Name - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - type: object - title: AppUpdate - Collection: - properties: - id: - type: string - title: Id - name: - type: string - title: Name - user_id: - type: string - title: User Id - metadata: - type: object - title: Metadata - additionalProperties: true - created_at: - type: string - format: date-time - title: Created At - type: object - required: - - id - - name - - user_id - - metadata - - created_at - title: Collection - exclude: - - h_metadata - - public_id - CollectionCreate: - properties: - name: - type: string - title: Name - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - default: {} - type: object - required: - - name - title: CollectionCreate - CollectionGet: - properties: - filter: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Filter - type: object - title: CollectionGet - CollectionUpdate: - properties: - name: - anyOf: - - type: string - - type: 'null' - title: Name - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - type: object - title: CollectionUpdate - Document: - properties: - id: - type: string - title: Id - content: - type: string title: Content - metadata: - type: object - title: Metadata - additionalProperties: true - created_at: - type: string - format: date-time - title: Created At - collection_id: type: string - title: Collection Id - type: object - required: - - id - - content - - metadata - - created_at - - collection_id - title: Document - exclude: - - h_metadata - - public_id - DocumentCreate: - properties: - content: + message_id: + title: Message Id type: string - title: Content - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - default: {} - type: object - required: - - content - title: DocumentCreate - DocumentGet: - properties: - filter: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Filter - type: object - title: DocumentGet - DocumentUpdate: - properties: metadata: anyOf: - - type: object - additionalProperties: true + - additionalProperties: true + type: object - type: 'null' - title: Metadata - content: - anyOf: - - type: string - - type: 'null' - title: Content - type: object - title: DocumentUpdate - HTTPValidationError: - properties: - detail: - items: - $ref: '#/components/schemas/ValidationError' - type: array - title: Detail - type: object - title: HTTPValidationError - Message: - properties: - id: - type: string - title: Id - content: - type: string - title: Content - is_user: - type: boolean - title: Is User - session_id: - type: string - title: Session Id - metadata: - type: object - title: Metadata - additionalProperties: true - created_at: - type: string - format: date-time - title: Created At - type: object - required: - - id - - content - - is_user - - session_id - - metadata - - created_at - title: Message - exclude: - - h_metadata - - public_id - MessageCreate: - properties: - content: - type: string - title: Content - is_user: - type: boolean - title: Is User - metadata: - type: object - title: Metadata default: {} - additionalProperties: true - type: object - required: - - content - - is_user - title: MessageCreate - MessageGet: - properties: - filter: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Filter - type: object - title: MessageGet - MessageUpdate: - properties: - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - type: object - title: MessageUpdate - Metamessage: - properties: - id: - type: string - title: Id - metamessage_type: - type: string - title: Metamessage Type - content: - type: string - title: Content - message_id: - type: string - title: Message Id - metadata: - type: object title: Metadata - additionalProperties: true - created_at: - type: string - format: date-time - title: Created At - type: object - required: - - id - - metamessage_type - - content - - message_id - - metadata - - created_at - title: Metamessage - exclude: - - h_metadata - - public_id - MetamessageCreate: - properties: metamessage_type: - type: string title: Metamessage Type - content: - type: string - title: Content - message_id: type: string - title: Message Id - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - default: {} - type: object required: - metamessage_type - content - message_id title: MetamessageCreate + type: object MetamessageGet: properties: - metamessage_type: + filter: anyOf: - - type: string + - additionalProperties: true + type: object - type: 'null' - title: Metamessage Type + title: Filter message_id: anyOf: - type: string - type: 'null' title: Message Id - filter: + metamessage_type: anyOf: - - type: object - additionalProperties: true + - type: string - type: 'null' - title: Filter - type: object + title: Metamessage Type title: MetamessageGet + type: object MetamessageGetUserLevel: properties: filter: anyOf: - - type: object - additionalProperties: true + - additionalProperties: true + type: object - type: 'null' title: Filter metamessage_type: @@ -3912,228 +410,230 @@ components: - type: string - type: 'null' title: Metamessage Type - type: object title: MetamessageGetUserLevel + type: object MetamessageUpdate: properties: message_id: - type: string title: Message Id + type: string + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata metamessage_type: anyOf: - type: string - type: 'null' title: Metamessage Type - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - type: object required: - message_id title: MetamessageUpdate + type: object Page_Collection_: properties: items: items: $ref: '#/components/schemas/Collection' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: - type: integer minimum: 1 title: Page - size: type: integer + pages: + minimum: 0 + title: Pages + type: integer + size: minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[Collection] + type: object Page_Document_: properties: items: items: $ref: '#/components/schemas/Document' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: - type: integer minimum: 1 title: Page - size: type: integer + pages: + minimum: 0 + title: Pages + type: integer + size: minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[Document] + type: object Page_Message_: properties: items: items: $ref: '#/components/schemas/Message' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: + minimum: 1 + title: Page + type: integer + pages: + minimum: 0 + title: Pages type: integer - minimum: 1 - title: Page size: - type: integer minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[Message] + type: object Page_Metamessage_: properties: items: items: $ref: '#/components/schemas/Metamessage' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: - type: integer minimum: 1 title: Page - size: type: integer + pages: + minimum: 0 + title: Pages + type: integer + size: minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[Metamessage] + type: object Page_Session_: properties: items: items: $ref: '#/components/schemas/Session' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: - type: integer minimum: 1 title: Page - size: type: integer + pages: + minimum: 0 + title: Pages + type: integer + size: minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[Session] + type: object Page_User_: properties: items: items: $ref: '#/components/schemas/User' - type: array title: Items - total: - type: integer - minimum: 0 - title: Total + type: array page: - type: integer minimum: 1 title: Page - size: type: integer + pages: + minimum: 0 + title: Pages + type: integer + size: minimum: 1 title: Size - pages: type: integer + total: minimum: 0 - title: Pages - type: object + title: Total + type: integer required: - items - total - page - size title: Page[User] + type: object Session: + exclude: + - h_metadata + - public_id properties: - id: + created_at: + format: date-time + title: Created At type: string + id: title: Id + type: string is_active: - type: boolean title: Is Active - user_id: - type: string - title: User Id + type: boolean metadata: - type: object - title: Metadata additionalProperties: true - created_at: + title: Metadata + type: object + user_id: + title: User Id type: string - format: date-time - title: Created At - type: object required: - id - is_active @@ -4141,62 +641,62 @@ components: - metadata - created_at title: Session - exclude: - - h_metadata - - public_id + type: object SessionCreate: properties: metadata: - type: object - title: Metadata - default: {} additionalProperties: true - type: object + default: {} + title: Metadata + type: object title: SessionCreate + type: object SessionGet: properties: filter: anyOf: - - type: object - additionalProperties: true + - additionalProperties: true + type: object - type: 'null' title: Filter is_active: - type: boolean - title: Is Active default: false - type: object + title: Is Active + type: boolean title: SessionGet + type: object SessionUpdate: properties: metadata: anyOf: - - type: object - additionalProperties: true + - additionalProperties: true + type: object - type: 'null' title: Metadata - type: object title: SessionUpdate + type: object User: + exclude: + - h_metadata + - public_id properties: - id: - type: string - title: Id - name: - type: string - title: Name app_id: - type: string title: App Id - created_at: type: string + created_at: format: date-time title: Created At + type: string + id: + title: Id + type: string metadata: - type: object - title: Metadata additionalProperties: true - type: object + title: Metadata + type: object + name: + title: Name + type: string required: - id - name @@ -4204,70 +704,3313 @@ components: - created_at - metadata title: User - exclude: - - h_metadata - - public_id + type: object UserCreate: properties: - name: - type: string - title: Name metadata: - type: object - title: Metadata - default: {} additionalProperties: true - type: object + default: {} + title: Metadata + type: object + name: + title: Name + type: string required: - name title: UserCreate + type: object UserGet: properties: filter: anyOf: - - type: object - additionalProperties: true + - additionalProperties: true + type: object - type: 'null' title: Filter - type: object title: UserGet + type: object UserUpdate: properties: + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata name: anyOf: - type: string - type: 'null' title: Name - metadata: - anyOf: - - type: object - additionalProperties: true - - type: 'null' - title: Metadata - type: object title: UserUpdate + type: object ValidationError: properties: loc: items: anyOf: - type: string - - type: integer - type: array - title: Location - msg: - type: string - title: Message - type: - type: string - title: Error Type - type: object - required: - - loc - - msg - - type - title: ValidationError - securitySchemes: - HTTPBearer: - type: http - scheme: bearer + - type: integer + title: Location + type: array + msg: + title: Message + type: string + type: + title: Error Type + type: string + required: + - loc + - msg + - type + title: ValidationError + type: object + securitySchemes: + HTTPBearer: + scheme: bearer + type: http +info: + contact: + email: hello@plasticlabs.ai + name: Plastic Labs + url: https://plasticlabs.ai/ + description: |- + This API is used to store data and get insights about users for AI + applications + summary: An API for adding personalization to AI Apps + title: Honcho API + version: 0.0.14 +openapi: 3.1.0 +paths: + /v1/apps: + post: + description: Create a new App + operationId: create_app_v1_apps_post + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AppCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/App' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create App + tags: + - apps + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const app = await client.apps.create({ name: 'name' }); + + console.log(app.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + app = client.apps.create( + name="name", + ) + print(app.id) + /v1/apps/get_or_create/{name}: + get: + description: Get or Create an App + operationId: get_or_create_app_v1_apps_get_or_create__name__get + parameters: + - in: path + name: name + required: true + schema: + title: Name + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/App' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Or Create App + tags: + - apps + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const app = await client.apps.getOrCreate('name'); + + console.log(app.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + app = client.apps.get_or_create( + "name", + ) + print(app.id) + /v1/apps/name/{name}: + get: + description: Get an App by Name + operationId: get_app_by_name_v1_apps_name__name__get + parameters: + - in: path + name: name + required: true + schema: + title: Name + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/App' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get App By Name + tags: + - apps + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const app = await client.apps.getByName('name'); + + console.log(app.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + app = client.apps.get_by_name( + "name", + ) + print(app.id) + /v1/apps/{app_id}: + get: + description: Get an App by ID + operationId: get_app_v1_apps__app_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/App' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get App + tags: + - apps + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const app = await client.apps.get('app_id'); + + console.log(app.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + app = client.apps.get( + "app_id", + ) + print(app.id) + put: + description: Update an App + operationId: update_app_v1_apps__app_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AppUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/App' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update App + tags: + - apps + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const app = await client.apps.update('app_id'); + + console.log(app.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + app = client.apps.update( + app_id="app_id", + ) + print(app.id) + /v1/apps/{app_id}/users: + post: + description: Create a new User + operationId: create_user_v1_apps__app_id__users_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UserCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create User + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const user = await client.apps.users.create('app_id', { name: 'name' }); + + console.log(user.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + user = client.apps.users.create( + app_id="app_id", + name="name", + ) + print(user.id) + /v1/apps/{app_id}/users/get_or_create/{name}: + get: + description: Get a User or create a new one by the input name + operationId: get_or_create_user_v1_apps__app_id__users_get_or_create__name__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: name + required: true + schema: + title: Name + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Or Create User + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const user = await client.apps.users.getOrCreate('app_id', 'name'); + + console.log(user.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + user = client.apps.users.get_or_create( + name="name", + app_id="app_id", + ) + print(user.id) + /v1/apps/{app_id}/users/list: + post: + description: Get All Users for an App + operationId: get_users_v1_apps__app_id__users_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: query + name: reverse + required: false + schema: + default: false + title: Reverse + type: boolean + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UserGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_User_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Users + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const user of client.apps.users.list('app_id')) { + console.log(user.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.list( + app_id="app_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/name/{name}: + get: + description: Get a User by name + operationId: get_user_by_name_v1_apps__app_id__users_name__name__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: name + required: true + schema: + title: Name + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get User By Name + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const user = await client.apps.users.getByName('app_id', 'name'); + + console.log(user.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + user = client.apps.users.get_by_name( + name="name", + app_id="app_id", + ) + print(user.id) + /v1/apps/{app_id}/users/{user_id}: + get: + description: Get a User by ID + operationId: get_user_v1_apps__app_id__users__user_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get User + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const user = await client.apps.users.get('app_id', 'user_id'); + + console.log(user.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + user = client.apps.users.get( + user_id="user_id", + app_id="app_id", + ) + print(user.id) + put: + description: Update a User's name and/or metadata + operationId: update_user_v1_apps__app_id__users__user_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UserUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update User + tags: + - users + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const user = await client.apps.users.update('app_id', 'user_id'); + + console.log(user.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + user = client.apps.users.update( + user_id="user_id", + app_id="app_id", + ) + print(user.id) + /v1/apps/{app_id}/users/{user_id}/collections: + post: + description: Create a new Collection + operationId: create_collection_v1_apps__app_id__users__user_id__collections_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CollectionCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Collection' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create Collection + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const collection = await client.apps.users.collections.create('app_id', 'user_id', { name: 'name' }); + + console.log(collection.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + collection = client.apps.users.collections.create( + user_id="user_id", + app_id="app_id", + name="name", + ) + print(collection.id) + /v1/apps/{app_id}/users/{user_id}/collections/list: + post: + description: Get All Collections for a User + operationId: get_collections_v1_apps__app_id__users__user_id__collections_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CollectionGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Collection_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Collections + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const collection of client.apps.users.collections.list('app_id', 'user_id')) { + console.log(collection.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.collections.list( + user_id="user_id", + app_id="app_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/collections/name/{name}: + get: + description: Get a Collection by Name + operationId: get_collection_by_name_v1_apps__app_id__users__user_id__collections_name__name__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: name + required: true + schema: + title: Name + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Collection' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Collection By Name + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const collection = await client.apps.users.collections.getByName('app_id', 'user_id', 'name'); + + console.log(collection.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + collection = client.apps.users.collections.get_by_name( + name="name", + app_id="app_id", + user_id="user_id", + ) + print(collection.id) + /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}: + delete: + description: Delete a Collection and its documents + operationId: delete_collection_v1_apps__app_id__users__user_id__collections__collection_id__delete + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + responses: + '200': + content: + application/json: + schema: {} + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Delete Collection + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const collection = await client.apps.users.collections.delete('app_id', 'user_id', 'collection_id'); + + console.log(collection); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + collection = client.apps.users.collections.delete( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + ) + print(collection) + get: + description: Get a Collection by ID + operationId: get_collection_by_id_v1_apps__app_id__users__user_id__collections__collection_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Collection' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Collection By Id + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const collection = await client.apps.users.collections.get('app_id', 'user_id', 'collection_id'); + + console.log(collection.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + collection = client.apps.users.collections.get( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + ) + print(collection.id) + put: + description: Update a Collection's name or metadata + operationId: update_collection_v1_apps__app_id__users__user_id__collections__collection_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CollectionUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Collection' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update Collection + tags: + - collections + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const collection = await client.apps.users.collections.update('app_id', 'user_id', 'collection_id'); + + console.log(collection.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + collection = client.apps.users.collections.update( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + ) + print(collection.id) + /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents: + post: + description: Embed text as a vector and create a Document + operationId: create_document_v1_apps__app_id__users__user_id__collections__collection_id__documents_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create Document + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const document = await client.apps.users.collections.documents.create( + 'app_id', + 'user_id', + 'collection_id', + { content: 'content' }, + ); + + console.log(document.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + document = client.apps.users.collections.documents.create( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + content="content", + ) + print(document.id) + /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/list: + post: + description: Get all of the Documents in a Collection + operationId: get_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Document_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Documents + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const document of client.apps.users.collections.documents.list( + 'app_id', + 'user_id', + 'collection_id', + )) { + console.log(document.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.collections.documents.list( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/query: + post: + description: Cosine Similarity Search for Documents + operationId: query_documents_v1_apps__app_id__users__user_id__collections__collection_id__documents_query_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentQuery' + required: true + responses: + '200': + content: + application/json: + schema: + items: + $ref: '#/components/schemas/Document' + title: >- + Response Query Documents V1 Apps App Id Users User Id Collections Collection Id + Documents Query Post + type: array + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Query Documents + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const documents = await client.apps.users.collections.documents.query( + 'app_id', + 'user_id', + 'collection_id', + { query: 'query' }, + ); + + console.log(documents); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + documents = client.apps.users.collections.documents.query( + collection_id="collection_id", + app_id="app_id", + user_id="user_id", + query="query", + ) + print(documents) + /v1/apps/{app_id}/users/{user_id}/collections/{collection_id}/documents/{document_id}: + delete: + description: Delete a Document by ID + operationId: >- + delete_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__delete + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + - in: path + name: document_id + required: true + schema: + title: Document Id + type: string + responses: + '200': + content: + application/json: + schema: {} + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Delete Document + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const document = await client.apps.users.collections.documents.delete( + 'app_id', + 'user_id', + 'collection_id', + 'document_id', + ); + + console.log(document); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + document = client.apps.users.collections.documents.delete( + document_id="document_id", + app_id="app_id", + user_id="user_id", + collection_id="collection_id", + ) + print(document) + get: + description: Get a document by ID + operationId: get_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + - in: path + name: document_id + required: true + schema: + title: Document Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Document + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const document = await client.apps.users.collections.documents.get( + 'app_id', + 'user_id', + 'collection_id', + 'document_id', + ); + + console.log(document.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + document = client.apps.users.collections.documents.get( + document_id="document_id", + app_id="app_id", + user_id="user_id", + collection_id="collection_id", + ) + print(document.id) + put: + description: Update the content and/or the metadata of a Document + operationId: >- + update_document_v1_apps__app_id__users__user_id__collections__collection_id__documents__document_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: collection_id + required: true + schema: + title: Collection Id + type: string + - in: path + name: document_id + required: true + schema: + title: Document Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DocumentUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Document' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update Document + tags: + - documents + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const document = await client.apps.users.collections.documents.update( + 'app_id', + 'user_id', + 'collection_id', + 'document_id', + ); + + console.log(document.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + document = client.apps.users.collections.documents.update( + document_id="document_id", + app_id="app_id", + user_id="user_id", + collection_id="collection_id", + ) + print(document.id) + /v1/apps/{app_id}/users/{user_id}/metamessages/list: + post: + description: Paginate through the user metamessages for a user + operationId: get_metamessages_by_user_v1_apps__app_id__users__user_id__metamessages_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MetamessageGetUserLevel' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Metamessage_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Metamessages By User + tags: + - metamessages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const metamessage of client.apps.users.metamessages.list('app_id', 'user_id')) { + console.log(metamessage.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.metamessages.list( + user_id="user_id", + app_id="app_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/sessions: + post: + description: Create a Session for a User + operationId: create_session_v1_apps__app_id__users__user_id__sessions_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SessionCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Session' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create Session + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const session = await client.apps.users.sessions.create('app_id', 'user_id'); + + console.log(session.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + session = client.apps.users.sessions.create( + user_id="user_id", + app_id="app_id", + ) + print(session.id) + /v1/apps/{app_id}/users/{user_id}/sessions/list: + post: + description: Get All Sessions for a User + operationId: get_sessions_v1_apps__app_id__users__user_id__sessions_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SessionGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Session_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Sessions + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const session of client.apps.users.sessions.list('app_id', 'user_id')) { + console.log(session.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.sessions.list( + user_id="user_id", + app_id="app_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}: + delete: + description: Delete a session by marking it as inactive + operationId: delete_session_v1_apps__app_id__users__user_id__sessions__session_id__delete + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + responses: + '200': + content: + application/json: + schema: {} + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Delete Session + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const session = await client.apps.users.sessions.delete('app_id', 'user_id', 'session_id'); + + console.log(session); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + session = client.apps.users.sessions.delete( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + print(session) + get: + description: Get a specific session for a user by ID + operationId: get_session_v1_apps__app_id__users__user_id__sessions__session_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Session' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Session + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const session = await client.apps.users.sessions.get('app_id', 'user_id', 'session_id'); + + console.log(session.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + session = client.apps.users.sessions.get( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + print(session.id) + put: + description: Update the metadata of a Session + operationId: update_session_v1_apps__app_id__users__user_id__sessions__session_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SessionUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Session' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update Session + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const session = await client.apps.users.sessions.update('app_id', 'user_id', 'session_id'); + + console.log(session.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + session = client.apps.users.sessions.update( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + print(session.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/chat: + post: + description: Chat with the Dialectic API + operationId: chat_v1_apps__app_id__users__user_id__sessions__session_id__chat_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AgentQuery' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AgentChat' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Chat + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const agentChat = await client.apps.users.sessions.chat('app_id', 'user_id', 'session_id', { + queries: 'string', + }); + + console.log(agentChat.content); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + agent_chat = client.apps.users.sessions.chat( + session_id="session_id", + app_id="app_id", + user_id="user_id", + queries="string", + ) + print(agent_chat.content) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/chat/stream: + post: + description: Stream Results from the Dialectic API + operationId: get_chat_stream_v1_apps__app_id__users__user_id__sessions__session_id__chat_stream_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AgentQuery' + required: true + responses: + '200': + content: + application/json: + schema: {} + text/event-stream: + schema: + format: binary + type: string + description: Chat stream + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Chat Stream + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const response = await client.apps.users.sessions.stream('app_id', 'user_id', 'session_id', { + queries: 'string', + }); + + console.log(response); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + response = client.apps.users.sessions.stream( + session_id="session_id", + app_id="app_id", + user_id="user_id", + queries="string", + ) + print(response) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/clone: + get: + description: Clone a session for a user, optionally will deep clone metamessages as well + operationId: clone_session_v1_apps__app_id__users__user_id__sessions__session_id__clone_get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: query + name: message_id + required: false + schema: + anyOf: + - type: string + - type: 'null' + title: Message Id + - in: query + name: deep_copy + required: false + schema: + default: false + title: Deep Copy + type: boolean + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Session' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Clone Session + tags: + - sessions + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const session = await client.apps.users.sessions.clone('app_id', 'user_id', 'session_id'); + + console.log(session.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + session = client.apps.users.sessions.clone( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + print(session.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages: + post: + description: Adds a message to a session + operationId: create_message_for_session_v1_apps__app_id__users__user_id__sessions__session_id__messages_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MessageCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Message' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create Message For Session + tags: + - messages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const message = await client.apps.users.sessions.messages.create('app_id', 'user_id', 'session_id', { + content: 'content', + is_user: true, + }); + + console.log(message.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + message = client.apps.users.sessions.messages.create( + session_id="session_id", + app_id="app_id", + user_id="user_id", + content="content", + is_user=True, + ) + print(message.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/list: + post: + description: Get all messages for a session + operationId: get_messages_v1_apps__app_id__users__user_id__sessions__session_id__messages_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MessageGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Message_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Messages + tags: + - messages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const message of client.apps.users.sessions.messages.list('app_id', 'user_id', 'session_id')) { + console.log(message.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.sessions.messages.list( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}: + get: + description: Get a Message by ID + operationId: get_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: path + name: message_id + required: true + schema: + title: Message Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Message' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Message + tags: + - messages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const message = await client.apps.users.sessions.messages.get( + 'app_id', + 'user_id', + 'session_id', + 'message_id', + ); + + console.log(message.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + message = client.apps.users.sessions.messages.get( + message_id="message_id", + app_id="app_id", + user_id="user_id", + session_id="session_id", + ) + print(message.id) + put: + description: Update the metadata of a Message + operationId: update_message_v1_apps__app_id__users__user_id__sessions__session_id__messages__message_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: path + name: message_id + required: true + schema: + title: Message Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MessageUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Message' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update Message + tags: + - messages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const message = await client.apps.users.sessions.messages.update( + 'app_id', + 'user_id', + 'session_id', + 'message_id', + ); + + console.log(message.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + message = client.apps.users.sessions.messages.update( + message_id="message_id", + app_id="app_id", + user_id="user_id", + session_id="session_id", + ) + print(message.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages: + post: + description: Adds a message to a session + operationId: create_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MetamessageCreate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Metamessage' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Create Metamessage + tags: + - metamessages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const metamessage = await client.apps.users.sessions.metamessages.create( + 'app_id', + 'user_id', + 'session_id', + { content: 'content', message_id: 'message_id', metamessage_type: 'metamessage_type' }, + ); + + console.log(metamessage.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + metamessage = client.apps.users.sessions.metamessages.create( + session_id="session_id", + app_id="app_id", + user_id="user_id", + content="content", + message_id="message_id", + metamessage_type="metamessage_type", + ) + print(metamessage.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages/list: + post: + description: Get all messages for a session + operationId: get_metamessages_v1_apps__app_id__users__user_id__sessions__session_id__metamessages_list_post + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: query + name: reverse + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + default: false + title: Reverse + - description: Page number + in: query + name: page + required: false + schema: + default: 1 + description: Page number + minimum: 1 + title: Page + type: integer + - description: Page size + in: query + name: size + required: false + schema: + default: 50 + description: Page size + maximum: 100 + minimum: 1 + title: Size + type: integer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MetamessageGet' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Page_Metamessage_' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Metamessages + tags: + - metamessages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + // Automatically fetches more pages as needed. + for await (const metamessage of client.apps.users.sessions.metamessages.list( + 'app_id', + 'user_id', + 'session_id', + )) { + console.log(metamessage.id); + } + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + page = client.apps.users.sessions.metamessages.list( + session_id="session_id", + app_id="app_id", + user_id="user_id", + ) + page = page.items[0] + print(page.id) + /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/metamessages/{metamessage_id}: + get: + description: Get a specific Metamessage by ID + operationId: >- + get_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages__metamessage_id__get + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: path + name: metamessage_id + required: true + schema: + title: Metamessage Id + type: string + - in: query + name: message_id + required: true + schema: + title: Message Id + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Metamessage' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Get Metamessage + tags: + - metamessages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const metamessage = await client.apps.users.sessions.metamessages.get( + 'app_id', + 'user_id', + 'session_id', + 'metamessage_id', + { message_id: 'message_id' }, + ); + + console.log(metamessage.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + metamessage = client.apps.users.sessions.metamessages.get( + metamessage_id="metamessage_id", + app_id="app_id", + user_id="user_id", + session_id="session_id", + message_id="message_id", + ) + print(metamessage.id) + put: + description: Update's the metadata of a metamessage + operationId: >- + update_metamessage_v1_apps__app_id__users__user_id__sessions__session_id__metamessages__metamessage_id__put + parameters: + - in: path + name: app_id + required: true + schema: + title: App Id + type: string + - in: path + name: user_id + required: true + schema: + title: User Id + type: string + - in: path + name: session_id + required: true + schema: + title: Session Id + type: string + - in: path + name: metamessage_id + required: true + schema: + title: Metamessage Id + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MetamessageUpdate' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Metamessage' + description: Successful Response + '422': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + description: Validation Error + security: + - HTTPBearer: [] + - {} + summary: Update Metamessage + tags: + - metamessages + x-codeSamples: + - lang: JavaScript + source: |- + import Honcho from 'honcho-ai'; + + const client = new Honcho({ + apiKey: process.env['HONCHO_API_KEY'], // This is the default and can be omitted + }); + + async function main() { + const metamessage = await client.apps.users.sessions.metamessages.update( + 'app_id', + 'user_id', + 'session_id', + 'metamessage_id', + { message_id: 'message_id' }, + ); + + console.log(metamessage.id); + } + + main(); + - lang: Python + source: |- + import os + from honcho import Honcho + + client = Honcho( + api_key=os.environ.get("HONCHO_API_KEY"), # This is the default and can be omitted + ) + metamessage = client.apps.users.sessions.metamessages.update( + metamessage_id="metamessage_id", + app_id="app_id", + user_id="user_id", + session_id="session_id", + message_id="message_id", + ) + print(metamessage.id) +servers: + - description: Local Development Server + url: http://127.0.0.1:8000 + - description: Demo Server + url: https:/demo.honcho.dev diff --git a/pyproject.toml b/pyproject.toml index 869d87d..35e20e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "honcho" -version = "0.0.13" +version = "0.0.14" description = "Honcho Server" authors = [ {name = "Plastic Labs", email = "hello@plasticlabs.ai"}, diff --git a/src/agent.py b/src/agent.py index e3ac710..52195c5 100644 --- a/src/agent.py +++ b/src/agent.py @@ -108,6 +108,7 @@ async def get_latest_user_representation( .where(models.App.public_id == app_id) .where(models.User.public_id == user_id) .where(models.Metamessage.metamessage_type == "user_representation") + .order_by(models.Metamessage.id.desc()) # get the most recent .limit(1) ) result = await db.execute(stmt) diff --git a/src/db.py b/src/db.py index 155b1a1..c252ba8 100644 --- a/src/db.py +++ b/src/db.py @@ -5,11 +5,11 @@ from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from sqlalchemy.orm import declarative_base -# from sqlalchemy.ext.declarative import declarative_base - load_dotenv() -connect_args = {} +connect_args = { + "prepare_threshold": None, +} # if ( # os.environ["DATABASE_TYPE"] == "sqlite" diff --git a/src/deriver/__main__.py b/src/deriver/__main__.py index df2a178..340ae42 100644 --- a/src/deriver/__main__.py +++ b/src/deriver/__main__.py @@ -1,5 +1,4 @@ import asyncio -import argparse import uvloop @@ -7,4 +6,5 @@ if __name__ == "__main__": asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) + diff --git a/src/deriver/consumer.py b/src/deriver/consumer.py index 114e101..128f143 100644 --- a/src/deriver/consumer.py +++ b/src/deriver/consumer.py @@ -1,6 +1,7 @@ import logging import re +import sentry_sdk from rich.console import Console from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession @@ -47,6 +48,7 @@ async def process_item(db: AsyncSession, payload: dict): return +@sentry_sdk.trace async def process_ai_message( content: str, app_id: str, @@ -102,6 +104,7 @@ async def process_ai_message( console.print(content_lines, style="blue") +@sentry_sdk.trace async def process_user_message( content: str, app_id: str, @@ -140,7 +143,9 @@ async def process_user_message( select(models.Metamessage) .where(models.Metamessage.message_id == ai_message.public_id) .where(models.Metamessage.metamessage_type == "tom_inference") - .order_by(models.Metamessage.id.asc()) + .order_by( + models.Metamessage.id.asc() + ) # Get the earliest tom inference on this message .limit(1) ) response = await db.execute(tom_inference_stmt) @@ -151,14 +156,26 @@ async def process_user_message( f"Tom Inference: {tom_inference_metamessage.content}", style="orange1" ) - # Fetch the existing user representation + # Fetch the latest user representation user_representation_stmt = ( select(models.Metamessage) - .where(models.Metamessage.message_id == ai_message.public_id) + .join( + models.Message, + models.Message.public_id == models.Metamessage.message_id, + ) + .join( + models.Session, + models.Message.session_id == models.Session.public_id, + ) + .join(models.User, models.User.public_id == models.Session.user_id) + .join(models.App, models.App.public_id == models.User.app_id) + .where(models.App.public_id == app_id) + .where(models.User.public_id == user_id) .where(models.Metamessage.metamessage_type == "user_representation") - .order_by(models.Metamessage.id.desc()) + .order_by(models.Metamessage.id.desc()) # get the most recent .limit(1) ) + response = await db.execute(user_representation_stmt) existing_representation = response.scalar_one_or_none() @@ -191,7 +208,9 @@ async def process_user_message( console.print(user_representation_response, style="bright_magenta") else: - raise Exception("\033[91mTom Inference NOT READY YET") + raise Exception( + f"\033[91mTom Inference NOT READY YET on message {message_id}" + ) else: console.print("No AI message before this user message", style="red") return diff --git a/src/deriver/queue.py b/src/deriver/queue.py index c0b7d7a..3bf585f 100644 --- a/src/deriver/queue.py +++ b/src/deriver/queue.py @@ -34,6 +34,7 @@ async def get_next_message_for_session( return result.scalar_one_or_none() +@sentry_sdk.trace async def process_session_messages(session_id: int): async with SessionLocal() as db: try: @@ -41,10 +42,15 @@ async def process_session_messages(session_id: int): message = await get_next_message_for_session(db, session_id) if not message: break - - await process_item(db, payload=message.payload) - message.processed = True - await db.commit() + try: + await process_item(db, payload=message.payload) + except Exception as e: + print(e) + sentry_sdk.capture_exception(e) + finally: + # Prevent malformed messages from stalling a queue indefinitely + message.processed = True + await db.commit() # Update last_updated to show this session is still being processed await db.execute( @@ -63,6 +69,7 @@ async def process_session_messages(session_id: int): await db.commit() +@sentry_sdk.trace async def get_available_sessions(db: AsyncSession, limit: int) -> Sequence[Any]: # First, clean up stale sessions (e.g., older than 5 minutes) five_minutes_ago = datetime.utcnow() - timedelta(minutes=5) @@ -89,45 +96,48 @@ async def get_available_sessions(db: AsyncSession, limit: int) -> Sequence[Any]: return result.scalars().all() +@sentry_sdk.trace async def schedule_session( semaphore: asyncio.Semaphore, queue_empty_flag: asyncio.Event ): - async with semaphore, SessionLocal() as db: - try: - available_slots = semaphore._value - # print(available_slots) - new_sessions = await get_available_sessions(db, available_slots) - - if new_sessions: - tasks = [] - for session_id in new_sessions: - try: - # Try to insert the session into active_sessions - await db.execute( - insert(models.ActiveQueueSession).values( - session_id=session_id + async with ( + semaphore, + SessionLocal() as db, + ): + with sentry_sdk.start_transaction( + op="deriver_schedule_session", name="Schedule Deriver Session" + ): + try: + # available_slots = semaphore._value + # print(available_slots) + new_sessions = await get_available_sessions(db, 1) + + if new_sessions: + for session_id in new_sessions: + try: + # Try to insert the session into active_sessions + await db.execute( + insert(models.ActiveQueueSession).values( + session_id=session_id + ) ) - ) - await db.commit() - - # If successful, create a task for this session - # Pass enable_timing to process_session_messages - asyncio.create_task(process_session_messages(session_id)) - except IntegrityError: - # If the session is already in active_sessions, skip it - await db.rollback() - - if tasks: - await asyncio.gather(*tasks) - else: - # No items to process, set the queue_empty_flag - queue_empty_flag.set() - except Exception as e: - rprint("==========") - rprint("Exception") - rprint(e) - rprint("==========") - await db.rollback() + await db.commit() + + # If successful, create a task for this session + await process_session_messages(session_id) + except IntegrityError: + # If the session is already in active_sessions, skip it + await db.rollback() + + else: + # No items to process, set the queue_empty_flag + queue_empty_flag.set() + except Exception as e: + rprint("==========") + rprint("Exception") + rprint(e) + rprint("==========") + await db.rollback() async def polling_loop(semaphore: asyncio.Semaphore, queue_empty_flag: asyncio.Event): @@ -139,8 +149,9 @@ async def polling_loop(semaphore: asyncio.Semaphore, queue_empty_flag: asyncio.E if semaphore.locked(): await asyncio.sleep(1) # Sleep briefly if the semaphore is fully locked continue - await schedule_session(semaphore, queue_empty_flag) - # await asyncio.sleep(0) # Yield control to allow tasks to run + # Create a task instead of awaiting + asyncio.create_task(schedule_session(semaphore, queue_empty_flag)) + await asyncio.sleep(0) # Give other tasks a chance to run async def main(): @@ -149,8 +160,8 @@ async def main(): sentry_sdk.init( dsn=os.getenv("SENTRY_DSN"), enable_tracing=True, - traces_sample_rate=1.0, - profiles_sample_rate=1.0, + traces_sample_rate=0.4, + profiles_sample_rate=0.4, integrations=[ AsyncioIntegration(), ], diff --git a/src/deriver/voe.py b/src/deriver/voe.py index d2763e8..e3721ea 100644 --- a/src/deriver/voe.py +++ b/src/deriver/voe.py @@ -1,11 +1,13 @@ import os +import sentry_sdk from anthropic import Anthropic # Initialize the Anthropic client -anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY")) +anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"), max_retries=5) +@sentry_sdk.trace async def tom_inference( chat_history: str, session_id: str, user_representation: str = "None" ) -> str: @@ -65,6 +67,7 @@ async def tom_inference( return message.content[0].text +@sentry_sdk.trace async def user_representation( chat_history: str, session_id: str, diff --git a/src/main.py b/src/main.py index ea76ed3..58a282d 100644 --- a/src/main.py +++ b/src/main.py @@ -47,7 +47,7 @@ async def lifespan(app: FastAPI): summary="An API for adding personalization to AI Apps", description="""This API is used to store data and get insights about users for AI applications""", - version="0.0.13", + version="0.0.14", contact={ "name": "Plastic Labs", "url": "https://plasticlabs.ai", diff --git a/src/models.py b/src/models.py index b81115e..0ee3ac7 100644 --- a/src/models.py +++ b/src/models.py @@ -6,13 +6,13 @@ from sqlalchemy import ( BigInteger, Boolean, + CheckConstraint, DateTime, ForeignKey, Identity, - String, UniqueConstraint, ) -from sqlalchemy.dialects.postgresql import JSONB +from sqlalchemy.dialects.postgresql import JSONB, TEXT from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.sql import func @@ -27,15 +27,21 @@ class App(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) - name: Mapped[str] = mapped_column(String(512), index=True, unique=True) + name: Mapped[str] = mapped_column(TEXT, index=True, unique=True) users = relationship("User", back_populates="app") created_at: Mapped[datetime.datetime] = mapped_column( DateTime(timezone=True), index=True, default=func.now() ) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) + __table_args__ = ( + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("length(name) <= 512", name="name_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + ) + class User(Base): __tablename__ = "users" @@ -43,9 +49,9 @@ class User(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) - name: Mapped[str] = mapped_column(String(512), index=True) + name: Mapped[str] = mapped_column(TEXT, index=True) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) created_at: Mapped[datetime.datetime] = mapped_column( DateTime(timezone=True), index=True, default=func.now() @@ -55,7 +61,12 @@ class User(Base): sessions = relationship("Session", back_populates="user") collections = relationship("Collection", back_populates="user") - __table_args__ = (UniqueConstraint("name", "app_id", name="unique_name_app_user"),) + __table_args__ = ( + UniqueConstraint("name", "app_id", name="unique_name_app_user"), + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("length(name) <= 512", name="name_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + ) def __repr__(self) -> str: return f"User(id={self.id}, app_id={self.app_id}, created_at={self.created_at}, h_metadata={self.h_metadata})" @@ -67,7 +78,7 @@ class Session(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) is_active: Mapped[bool] = mapped_column(default=True) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) @@ -78,6 +89,11 @@ class Session(Base): user_id: Mapped[str] = mapped_column(ForeignKey("users.public_id"), index=True) user = relationship("User", back_populates="sessions") + __table_args__ = ( + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + ) + def __repr__(self) -> str: return f"Session(id={self.id}, user_id={self.user_id}, is_active={self.is_active}, created_at={self.created_at}, h_metadata={self.h_metadata})" @@ -88,13 +104,13 @@ class Message(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) session_id: Mapped[str] = mapped_column( ForeignKey("sessions.public_id"), index=True ) is_user: Mapped[bool] - content: Mapped[str] = mapped_column(String(65535)) + content: Mapped[str] = mapped_column(TEXT) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) created_at: Mapped[datetime.datetime] = mapped_column( @@ -103,6 +119,12 @@ class Message(Base): session = relationship("Session", back_populates="messages") metamessages = relationship("Metamessage", back_populates="message") + __table_args__ = ( + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + CheckConstraint("length(content) <= 65535", name="content_length"), + ) + def __repr__(self) -> str: return f"Message(id={self.id}, session_id={self.session_id}, is_user={self.is_user}, content={self.content[10:]})" @@ -113,10 +135,10 @@ class Metamessage(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) - metamessage_type: Mapped[str] = mapped_column(String(512), index=True) - content: Mapped[str] = mapped_column(String(65535)) + metamessage_type: Mapped[str] = mapped_column(TEXT, index=True) + content: Mapped[str] = mapped_column(TEXT) message_id: Mapped[str] = mapped_column( ForeignKey("messages.public_id"), index=True ) @@ -127,6 +149,15 @@ class Metamessage(Base): ) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) + __table_args__ = ( + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + CheckConstraint("length(content) <= 65535", name="content_length"), + CheckConstraint( + "length(metamessage_type) <= 512", name="metamessage_type_length" + ), + ) + def __repr__(self) -> str: return f"Metamessages(id={self.id}, message_id={self.message_id}, metamessage_type={self.metamessage_type}, content={self.content[10:]})" @@ -138,9 +169,9 @@ class Collection(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) - name: Mapped[str] = mapped_column(String(512), index=True) + name: Mapped[str] = mapped_column(TEXT, index=True) created_at: Mapped[datetime.datetime] = mapped_column( DateTime(timezone=True), index=True, default=func.now() ) @@ -150,11 +181,14 @@ class Collection(Base): ) user = relationship("User", back_populates="collections") user_id: Mapped[str] = mapped_column( - String(21), ForeignKey("users.public_id"), index=True + TEXT, ForeignKey("users.public_id"), index=True ) __table_args__ = ( UniqueConstraint("name", "user_id", name="unique_name_collection_user"), + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + CheckConstraint("length(name) <= 512", name="name_length"), ) @@ -164,20 +198,26 @@ class Document(Base): BigInteger, Identity(), primary_key=True, index=True, autoincrement=True ) public_id: Mapped[str] = mapped_column( - String(21), index=True, unique=True, default=generate_nanoid + TEXT, index=True, unique=True, default=generate_nanoid ) h_metadata: Mapped[dict] = mapped_column("metadata", JSONB, default={}) - content: Mapped[str] = mapped_column(String(65535)) + content: Mapped[str] = mapped_column(TEXT) embedding = mapped_column(Vector(1536)) created_at: Mapped[datetime.datetime] = mapped_column( DateTime(timezone=True), index=True, default=func.now() ) collection_id: Mapped[str] = mapped_column( - String(21), ForeignKey("collections.public_id"), index=True + TEXT, ForeignKey("collections.public_id"), index=True ) collection = relationship("Collection", back_populates="documents") + __table_args__ = ( + CheckConstraint("length(public_id) = 21", name="public_id_length"), + CheckConstraint("length(content) <= 65535", name="content_length"), + CheckConstraint("public_id ~ '^[A-Za-z0-9_-]+$'", name="public_id_format"), + ) + class QueueItem(Base): __tablename__ = "queue" diff --git a/src/routers/apps.py b/src/routers/apps.py index b3279be..3539bd0 100644 --- a/src/routers/apps.py +++ b/src/routers/apps.py @@ -16,15 +16,7 @@ @router.get("/{app_id}", response_model=schemas.App) async def get_app(app_id: str, db=db): - """Get an App by ID - - Args: - app_id (str): The ID of the app - - Returns: - schemas.App: App object - - """ + """Get an App by ID""" app = await crud.get_app(db, app_id=app_id) if app is None: raise HTTPException(status_code=404, detail="App not found") @@ -33,15 +25,7 @@ async def get_app(app_id: str, db=db): @router.get("/name/{name}", response_model=schemas.App) async def get_app_by_name(name: str, db=db): - """Get an App by Name - - Args: - app_name (str): The name of the app - - Returns: - schemas.App: App object - - """ + """Get an App by Name""" app = await crud.get_app_by_name(db, name=name) if app is None: raise HTTPException(status_code=404, detail="App not found") @@ -50,15 +34,7 @@ async def get_app_by_name(name: str, db=db): @router.post("", response_model=schemas.App) async def create_app(app: schemas.AppCreate, db=db): - """Create an App - - Args: - app (schemas.AppCreate): The App object containing any metadata - - Returns: - schemas.App: Created App object - - """ + """Create a new App""" try: honcho_app = await crud.create_app(db, app=app) return honcho_app @@ -73,15 +49,7 @@ async def create_app(app: schemas.AppCreate, db=db): @router.get("/get_or_create/{name}", response_model=schemas.App) async def get_or_create_app(name: str, db=db): - """Get or Create an App - - Args: - app_name (str): The name of the app - - Returns: - schemas.App: App object - - """ + """Get or Create an App""" print("name", name) app = await crud.get_app_by_name(db=db, name=name) if app is None: @@ -95,16 +63,7 @@ async def update_app( app: schemas.AppUpdate, db=db, ): - """Update an App - - Args: - app_id (str): The ID of the app to update - app (schemas.AppUpdate): The App object containing any new metadata - - Returns: - schemas.App: The App object of the updated App - - """ + """Update an App""" honcho_app = await crud.update_app(db, app_id=app_id, app=app) if honcho_app is None: raise HTTPException(status_code=404, detail="App not found") diff --git a/src/routers/collections.py b/src/routers/collections.py index 0e21bfd..aa5ad59 100644 --- a/src/routers/collections.py +++ b/src/routers/collections.py @@ -23,17 +23,7 @@ async def get_collections( reverse: Optional[bool] = False, db=db, ): - """Get All Collections for a User - - Args: - app_id (str): The ID of the app representing the client - application using honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - list[schemas.Collection]: List of Collection objects - - """ + """Get All Collections for a User""" return await paginate( db, await crud.get_collections( @@ -49,6 +39,7 @@ async def get_collection_by_name( name: str, db=db, ) -> schemas.Collection: + """Get a Collection by Name""" honcho_collection = await crud.get_collection_by_name( db, app_id=app_id, user_id=user_id, name=name ) @@ -66,6 +57,7 @@ async def get_collection_by_id( collection_id: str, db=db, ) -> schemas.Collection: + """Get a Collection by ID""" honcho_collection = await crud.get_collection_by_id( db, app_id=app_id, user_id=user_id, collection_id=collection_id ) @@ -83,6 +75,7 @@ async def create_collection( collection: schemas.CollectionCreate, db=db, ): + """Create a new Collection""" if collection.name == "honcho": raise HTTPException( status_code=406, @@ -107,6 +100,7 @@ async def update_collection( collection: schemas.CollectionUpdate, db=db, ): + "Update a Collection's name or metadata" if collection.name is None and collection.metadata is None: raise HTTPException( status_code=406, @@ -140,6 +134,7 @@ async def delete_collection( collection_id: str, db=db, ): + """Delete a Collection and its documents""" try: await crud.delete_collection( db, app_id=app_id, user_id=user_id, collection_id=collection_id diff --git a/src/routers/documents.py b/src/routers/documents.py index 4d3506e..e021143 100644 --- a/src/routers/documents.py +++ b/src/routers/documents.py @@ -1,3 +1,4 @@ +import json from collections.abc import Sequence from typing import Optional @@ -25,6 +26,7 @@ async def get_documents( reverse: Optional[bool] = False, db=db, ): + """Get all of the Documents in a Collection""" try: return await paginate( db, @@ -56,6 +58,7 @@ async def get_document( document_id: str, db=db, ): + """Get a document by ID""" honcho_document = await crud.get_document( db, app_id=app_id, @@ -70,30 +73,34 @@ async def get_document( return honcho_document -@router.get("/query", response_model=Sequence[schemas.Document]) +@router.post("/query", response_model=Sequence[schemas.Document]) async def query_documents( app_id: str, user_id: str, collection_id: str, - query: str, - top_k: int = 5, - filter: Optional[str] = None, + options: schemas.DocumentQuery, db=db, ): - if top_k is not None and top_k > 50: - top_k = 50 # TODO see if we need to paginate this - data = None - if filter is not None: - data = json.loads(filter) - return await crud.query_documents( - db=db, - app_id=app_id, - user_id=user_id, - collection_id=collection_id, - query=query, - filter=data, - top_k=top_k, - ) + """Cosine Similarity Search for Documents""" + + try: + top_k = options.top_k + if top_k is not None and top_k > 50: + top_k = 50 # TODO see if we need to paginate this + filter = options.filter + if options.filter == {}: + filter = None + return await crud.query_documents( + db=db, + app_id=app_id, + user_id=user_id, + collection_id=collection_id, + query=options.query, + filter=filter, + top_k=top_k, + ) + except ValueError as e: + raise HTTPException(status_code=400, detail="Error Query Documents") from e @router.post("", response_model=schemas.Document) @@ -104,6 +111,7 @@ async def create_document( document: schemas.DocumentCreate, db=db, ): + """Embed text as a vector and create a Document""" try: return await crud.create_document( db, @@ -130,6 +138,7 @@ async def update_document( document: schemas.DocumentUpdate, db=db, ): + """Update the content and/or the metadata of a Document""" if document.content is None and document.metadata is None: raise HTTPException( status_code=400, detail="content and metadata cannot both be None" @@ -157,6 +166,7 @@ async def delete_document( document_id: str, db=db, ): + """Delete a Document by ID""" response = await crud.delete_document( db, app_id=app_id, diff --git a/src/routers/messages.py b/src/routers/messages.py index 868e2a9..cfbb773 100644 --- a/src/routers/messages.py +++ b/src/routers/messages.py @@ -63,21 +63,7 @@ async def create_message_for_session( background_tasks: BackgroundTasks, db=db, ): - """Adds a message to a session - - Args: - app_id (str): The ID of the app representing the client application using honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to add the message to - message (schemas.MessageCreate): The Message object to add containing the message content and type - - Returns: - schemas.Message: The Message object of the added message - - Raises: - HTTPException: If the session is not found - - """ + """Adds a message to a session""" try: honcho_message = await crud.create_message( db, message=message, app_id=app_id, user_id=user_id, session_id=session_id @@ -110,22 +96,7 @@ async def get_messages( reverse: Optional[bool] = False, db=db, ): - """Get all messages for a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - reverse (bool): Whether to reverse the order of the messages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - - """ + """Get all messages for a session""" try: filter = options.filter if options.filter == {}: @@ -153,7 +124,7 @@ async def get_message( message_id: str, db=db, ): - """ """ + """Get a Message by ID""" honcho_message = await crud.get_message( db, app_id=app_id, session_id=session_id, user_id=user_id, message_id=message_id ) @@ -171,7 +142,7 @@ async def update_message( message: schemas.MessageUpdate, db=db, ): - """Update's the metadata of a message""" + """Update the metadata of a Message""" if message.metadata is None: raise HTTPException(status_code=400, detail="Message metadata cannot be empty") try: diff --git a/src/routers/metamessages.py b/src/routers/metamessages.py index 870645f..ad697f0 100644 --- a/src/routers/metamessages.py +++ b/src/routers/metamessages.py @@ -29,22 +29,7 @@ async def create_metamessage( metamessage: schemas.MetamessageCreate, db=db, ): - """Adds a message to a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to add the message to - metamessage (schemas.MeteamessageCreate): The metamessage creation object - - Returns: - schemas.Metamessage: The Metamessage object of the added metamessage - - Raises: - HTTPException: If the session is not found - - """ + """Adds a message to a session""" try: return await crud.create_metamessage( db, @@ -66,22 +51,7 @@ async def get_metamessages( reverse: Optional[bool] = False, db=db, ): - """Get all messages for a session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - reverse (bool): Whether to reverse the order of the metamessages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - - """ + """Get all messages for a session""" try: return await paginate( db, @@ -108,20 +78,7 @@ async def get_metamessages_by_user( reverse: Optional[bool] = False, db=db, ): - """Paginate through the user metamessages for a user - - Args: - app_id (str): The ID of the app representing the client application using honcho - user_id (str): The User ID representing the user, managed by the user - reverse (bool): Whether to reverse the order of the metamessages - - Returns: - list[schemas.Message]: List of Message objects - - Raises: - HTTPException: If the session is not found - - """ + """Paginate through the user metamessages for a user""" try: return await paginate( db, @@ -150,20 +107,7 @@ async def get_metamessage( metamessage_id: str, db=db, ): - """Get a specific Metamessage by ID - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (int): The ID of the Session to retrieve - - Returns: - schemas.Session: The Session object of the requested Session - - Raises: - HTTPException: If the session is not found - """ + """Get a specific Metamessage by ID""" honcho_metamessage = await crud.get_metamessage( db, app_id=app_id, diff --git a/src/routers/sessions.py b/src/routers/sessions.py index 0a3196d..432b4a6 100644 --- a/src/routers/sessions.py +++ b/src/routers/sessions.py @@ -24,17 +24,7 @@ async def get_sessions( reverse: Optional[bool] = False, db=db, ): - """Get All Sessions for a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - list[schemas.Session]: List of Session objects - - """ + """Get All Sessions for a User""" return await paginate( db, await crud.get_sessions( @@ -55,19 +45,7 @@ async def create_session( session: schemas.SessionCreate, db=db, ): - """Create a Session for a User - - Args: - app_id (str): The ID of the app representing the client - application using honcho - user_id (str): The User ID representing the user, managed by the user - session (schemas.SessionCreate): The Session object containing any - metadata - - Returns: - schemas.Session: The Session object of the new Session - - """ + """Create a Session for a User""" try: value = await crud.create_session( db, app_id=app_id, user_id=user_id, session=session @@ -88,19 +66,7 @@ async def update_session( session: schemas.SessionUpdate, db=db, ): - """Update the metadata of a Session - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to update - session (schemas.SessionUpdate): The Session object containing any new metadata - - Returns: - schemas.Session: The Session object of the updated Session - - """ + """Update the metadata of a Session""" if session.metadata is None: raise HTTPException(status_code=400, detail="Session metadata cannot be empty") try: @@ -118,21 +84,7 @@ async def delete_session( session_id: str, db=db, ): - """Delete a session by marking it as inactive - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to delete - - Returns: - dict: A message indicating that the session was deleted - - Raises: - HTTPException: If the session is not found - - """ + """Delete a session by marking it as inactive""" try: await crud.delete_session( db, app_id=app_id, user_id=user_id, session_id=session_id @@ -149,20 +101,7 @@ async def get_session( session_id: str, db=db, ): - """Get a specific session for a user by ID - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - session_id (str): The ID of the Session to retrieve - - Returns: - schemas.Session: The Session object of the requested Session - - Raises: - HTTPException: If the session is not found - """ + """Get a specific session for a user by ID""" honcho_session = await crud.get_session( db, app_id=app_id, session_id=session_id, user_id=user_id ) @@ -178,7 +117,7 @@ async def chat( session_id: str, query: schemas.AgentQuery, ): - print(query) + """Chat with the Dialectic API""" return await agent.chat( app_id=app_id, user_id=user_id, session_id=session_id, query=query ) @@ -201,6 +140,8 @@ async def get_chat_stream( session_id: str, query: schemas.AgentQuery, ): + """Stream Results from the Dialectic API""" + async def parse_stream(): stream = await agent.chat( app_id=app_id, @@ -226,6 +167,7 @@ async def clone_session( message_id: Optional[str] = None, deep_copy: bool = False, ): + """Clone a session for a user, optionally will deep clone metamessages as well""" return await crud.clone_session( db, app_id=app_id, diff --git a/src/routers/users.py b/src/routers/users.py index 6077115..fcea0eb 100644 --- a/src/routers/users.py +++ b/src/routers/users.py @@ -22,17 +22,7 @@ async def create_user( user: schemas.UserCreate, db=db, ): - """Create a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user (schemas.UserCreate): The User object containing any metadata - - Returns: - schemas.User: Created User object - - """ + """Create a new User""" print("running create_user") try: return await crud.create_user(db, app_id=app_id, user=user) @@ -49,16 +39,7 @@ async def get_users( reverse: bool = False, db=db, ): - """Get All Users for an App - - Args: - app_id (str): The ID of the app representing the client - application using honcho - - Returns: - list[schemas.User]: List of User objects - - """ + """Get All Users for an App""" return await paginate( db, await crud.get_users(db, app_id=app_id, reverse=reverse, filter=options.filter), @@ -71,17 +52,7 @@ async def get_user_by_name( name: str, db=db, ): - """Get a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - - """ + """Get a User by name""" user = await crud.get_user_by_name(db, app_id=app_id, name=name) if user is None: raise HTTPException(status_code=404, detail="User not found") @@ -94,17 +65,7 @@ async def get_user( user_id: str, db=db, ): - """Get a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - - """ + """Get a User by ID""" user = await crud.get_user(db, app_id=app_id, user_id=user_id) if user is None: raise HTTPException(status_code=404, detail="User not found") @@ -113,17 +74,7 @@ async def get_user( @router.get("/get_or_create/{name}", response_model=schemas.User) async def get_or_create_user(app_id: str, name: str, db=db): - """Get or Create a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - - Returns: - schemas.User: User object - - """ + """Get a User or create a new one by the input name""" user = await crud.get_user_by_name(db, app_id=app_id, name=name) if user is None: user = await create_user( @@ -139,18 +90,7 @@ async def update_user( user: schemas.UserUpdate, db=db, ): - """Update a User - - Args: - app_id (str): The ID of the app representing the client application using - honcho - user_id (str): The User ID representing the user, managed by the user - user (schemas.UserCreate): The User object containing any metadata - - Returns: - schemas.User: Updated User object - - """ + """Update a User's name and/or metadata""" try: return await crud.update_user(db, app_id=app_id, user_id=user_id, user=user) except ValueError as e: diff --git a/src/schemas.py b/src/schemas.py index 08e6e19..3df63ad 100644 --- a/src/schemas.py +++ b/src/schemas.py @@ -270,6 +270,12 @@ class DocumentGet(DocumentBase): filter: dict | None = None +class DocumentQuery(DocumentBase): + query: str + filter: dict | None = None + top_k: int = 5 + + class DocumentUpdate(DocumentBase): metadata: dict | None = None content: str | None = None diff --git a/tests/routes/test_documents.py b/tests/routes/test_documents.py index 129f2cc..8819d0d 100644 --- a/tests/routes/test_documents.py +++ b/tests/routes/test_documents.py @@ -91,6 +91,51 @@ def test_get_documents(client, sample_data): assert data["items"][1]["metadata"]["test"] == "key" +def test_query_documents(client, sample_data): + test_app, test_user = sample_data + # Create a collection + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections", + json={"name": str(generate_nanoid()), "metadata": {}}, + ) + assert response.status_code == 200 + collection = response.json() + # Create a document + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections/{collection['id']}/documents", + json={"content": "test_text", "metadata": {"test": "key"}}, + ) + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections/{collection['id']}/documents", + json={"content": "test_text", "metadata": {"test": "key"}}, + ) + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections/{collection['id']}/documents", + json={"content": "test_text", "metadata": {"test": "key2"}}, + ) + # Get the documents + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections/{collection['id']}/documents/query", + json={"query": "test"}, + ) + assert response.status_code == 200 + data = response.json() + print("=====================") + print(data) + print("=====================") + assert len(data) == 3 + + response = client.post( + f"/v1/apps/{test_app.public_id}/users/{test_user.public_id}/collections/{collection['id']}/documents/query", + json={"query": "test", "filter": {"test": "key"}}, + ) + assert response.status_code == 200 + data = response.json() + assert len(data) == 2 + assert data[0]["metadata"]["test"] == "key" + assert data[1]["metadata"]["test"] == "key" + + def test_update_document(client, sample_data): test_app, test_user = sample_data # Create a collection diff --git a/uv.lock b/uv.lock index 40a79ad..17a498d 100644 --- a/uv.lock +++ b/uv.lock @@ -425,7 +425,7 @@ wheels = [ [[package]] name = "honcho" -version = "0.0.13" +version = "0.0.14" source = { virtual = "." } dependencies = [ { name = "anthropic" },