Skip to main content
GET
/
v2
/
workspaces
/
{workspace_id}
/
sessions
/
{session_id}
/
context
JavaScript
import Honcho from '@honcho-ai/core';

const client = new Honcho({
  apiKey: 'My API Key',
});

const response = await client.workspaces.sessions.getContext('workspace_id', 'session_id');

console.log(response.id);
{
  "id": "<string>",
  "messages": [
    {
      "id": "<string>",
      "content": "<string>",
      "peer_id": "<string>",
      "session_id": "<string>",
      "metadata": {},
      "created_at": "2023-11-07T05:31:56Z",
      "workspace_id": "<string>",
      "token_count": 123
    }
  ],
  "summary": {
    "content": "<string>",
    "message_id": "<string>",
    "summary_type": "<string>",
    "created_at": "<string>",
    "token_count": 123
  },
  "peer_representation": {
    "explicit": [
      {
        "created_at": "2023-11-07T05:31:56Z",
        "message_ids": [
          [
            "<any>"
          ]
        ],
        "session_name": "<string>",
        "content": "<string>"
      }
    ],
    "deductive": [
      {
        "created_at": "2023-11-07T05:31:56Z",
        "message_ids": [
          [
            "<any>"
          ]
        ],
        "session_name": "<string>",
        "premises": [
          "<string>"
        ],
        "conclusion": "<string>"
      }
    ]
  },
  "peer_card": [
    "<string>"
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

workspace_id
string
required

ID of the workspace

session_id
string
required

ID of the session

Query Parameters

tokens
integer | null

Number of tokens to use for the context. Includes summary if set to true. Includes representation and peer card if they are included in the response. If not provided, the context will be exhaustive (within 100000 tokens)

Required range: x <= 100000
last_message
string | null

The most recent message, used to fetch semantically relevant observations

summary
boolean
default:true

Whether or not to include a summary if one is available for the session

peer_target
string | null

The target of the perspective. If given without peer_perspective, will get the Honcho-level representation and peer card for this peer. If given with peer_perspective, will get the representation and card for this peer from the perspective of that peer.

peer_perspective
string | null

A peer to get context for. If given, response will attempt to include representation and card from the perspective of that peer. Must be provided with peer_target.

Response

Successful Response

id
string
required
messages
Message · object[]
required
summary
object | null

The summary if available

peer_representation
object | null

The peer representation, if context is requested from a specific perspective A Representation is a traversable and diffable map of observations. At the base, we have a list of explicit observations, derived from a peer's messages.

From there, deductive observations can be made by establishing logical relationships between explicit observations.

In the future, we can add more levels of reasoning on top of these.

All of a peer's observations are stored as documents in a collection. These documents can be queried in various ways to produce this Representation object.

Additionally, a "working representation" is a version of this data structure representing the most recent observations within a single session.

A representation can have a maximum number of observations, which is applied individually to each level of reasoning. If a maximum is set, observations are added and removed in FIFO order.

peer_card
string[] | null

The peer card, if context is requested from a specific perspective