import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const chatThreadHistory = await client.chatThreads.messages.retrieve('thread_id');
console.log(chatThreadHistory.application_spec_id);{
"thread": {
"id": "<string>",
"title": "<string>",
"application_variant_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"thread_metadata": {},
"archived_at": "2023-11-07T05:31:56Z"
},
"messages": [
{
"entry": {
"id": "<string>",
"input": {},
"output": {},
"aggregated": true,
"application_spec_id": "<string>",
"application_variant_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"operation_status": "SUCCESS",
"created_at": "2023-11-07T05:31:56Z",
"operation_metadata": {},
"chat_thread_id": "<string>",
"interaction_source": "EXTERNAL_AI"
},
"spans": [
{
"id": "<string>",
"node_id": "<string>",
"operation_type": "TEXT_INPUT",
"operation_status": "SUCCESS",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"application_interaction_id": "<string>",
"application_variant_id": "<string>",
"operation_input": {},
"operation_output": {},
"operation_expected": {},
"operation_metadata": {},
"end_timestamp": "2023-11-07T05:31:56Z",
"trace_id": "<string>",
"parent_id": "<string>",
"group_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user"
}
],
"feedback": {
"id": "<string>",
"chat_thread_id": "<string>",
"application_interaction_id": "<string>",
"sentiment": "positive",
"description": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
}
],
"application_spec_id": "<string>"
}import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
const chatThreadHistory = await client.chatThreads.messages.retrieve('thread_id');
console.log(chatThreadHistory.application_spec_id);{
"thread": {
"id": "<string>",
"title": "<string>",
"application_variant_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"thread_metadata": {},
"archived_at": "2023-11-07T05:31:56Z"
},
"messages": [
{
"entry": {
"id": "<string>",
"input": {},
"output": {},
"aggregated": true,
"application_spec_id": "<string>",
"application_variant_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"operation_status": "SUCCESS",
"created_at": "2023-11-07T05:31:56Z",
"operation_metadata": {},
"chat_thread_id": "<string>",
"interaction_source": "EXTERNAL_AI"
},
"spans": [
{
"id": "<string>",
"node_id": "<string>",
"operation_type": "TEXT_INPUT",
"operation_status": "SUCCESS",
"start_timestamp": "2023-11-07T05:31:56Z",
"duration_ms": 123,
"application_interaction_id": "<string>",
"application_variant_id": "<string>",
"operation_input": {},
"operation_output": {},
"operation_expected": {},
"operation_metadata": {},
"end_timestamp": "2023-11-07T05:31:56Z",
"trace_id": "<string>",
"parent_id": "<string>",
"group_id": "<string>",
"account_id": "<string>",
"created_by_user_id": "<string>",
"created_by_identity_type": "user"
}
],
"feedback": {
"id": "<string>",
"chat_thread_id": "<string>",
"application_interaction_id": "<string>",
"sentiment": "positive",
"description": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}
}
],
"application_spec_id": "<string>"
}Fetch the thread by account instead of user
Fetch spans for each message
Successful Response
Show child attributes
The ID of the account that owns the given entity.
The user who originally created the entity.
The type of identity that created the entity.
user, service_account The date and time when the entity was created in ISO format.
The date and time when the entity was last updated in ISO format.
The date and time when the entity was archived in ISO format.
Show child attributes
Show child attributes
Boolean of whether this interaction has been uploaded to s3 bucket yet, default is false
How much time the step took in milliseconds(ms)
The outcome of the operation
SUCCESS, ERROR, CANCELED The date and time when the entity was created in ISO format.
The JSON representation of the metadata insights emitted through the execution. This can differ based on different types of operations
EXTERNAL_AI, EVALUATION, SGP_CHAT, AGENTS_SERVICE Show child attributes
Identifies the application step
The id of the node in the application_variant config that emitted this insight
Type of the operation, e.g. RERANKING
TEXT_INPUT, TEXT_OUTPUT, COMPLETION_INPUT, COMPLETION, KB_RETRIEVAL, KB_INPUT, RERANKING, EXTERNAL_ENDPOINT, PROMPT_ENGINEERING, DOCUMENT_INPUT, MAP_REDUCE, DOCUMENT_SEARCH, DOCUMENT_PROMPT, CUSTOM, CODE_EXECUTION, DATA_MANIPULATION, EVALUATION, FILE_RETRIEVAL, KB_ADD_CHUNK, KB_MANAGEMENT, GUARDRAIL, TRACER, AGENT_TRACER, AGENT_WORKFLOW, STANDALONE The outcome of the operation
SUCCESS, ERROR, CANCELED The start time of the step
How much time the step took in milliseconds(ms)
The interaction ID this span belongs to
The id of the application variant this span belongs to
The JSON representation of the input that this step received
The JSON representation of the output that this step emitted
The JSON representation of the expected output for this step
The JSON representation of the metadata insights emitted through the execution. This can differ based on different types of operations
The end time of the step, nullable, since it can be set to done at a later point in time.
The root-level ID where this span belongs to
Who is the parent span of this current span, null if span is root parent.
The ID of the group this span belongs to
The ID of the account that owns the given entity.
The user who originally created the entity.
The type of identity that created the entity.
user, service_account Show child attributes
positive, negative The date and time when the entity was created in ISO format.
The ID of the application spec that the thread belongs to.