Runs, gRPC: RunService.Attach
- gRPC request
- AttachRunRequest
- ToolResultList
- ToolResult
- FunctionResult
- StreamEvent
- StreamCursor
- Error
- MessageContent
- ContentPart
- Text
- Message
- Author
- Citation
- Source
- FileChunk
- SearchIndex
- ExpirationConfig
- TextSearchIndex
- ChunkingStrategy
- StaticChunkingStrategy
- NgramTokenizer
- VectorSearchIndex
- HybridSearchIndex
- CombinationStrategy
- MeanCombinationStrategy
- ReciprocalRankFusionCombinationStrategy
- File
- ChunkContent
- ToolCallList
- ToolCall
- FunctionCall
Bi-directional streaming method to interact with a specific run.
Like Listen
, Attach
streams events from the run, but also allows clients to send events back.
For example, it can be used to submit function call results when the run is waiting for user input.
gRPC request
rpc Attach (stream AttachRunRequest) returns (stream StreamEvent)
AttachRunRequest
{
"run_id": "string",
"events_start_idx": "google.protobuf.Int64Value",
// Includes only one of the fields `tool_result_list`
"tool_result_list": {
"tool_results": [
{
// Includes only one of the fields `function_result`
"function_result": {
"name": "string",
// Includes only one of the fields `content`
"content": "string"
// end of the list of possible fields
}
// end of the list of possible fields
}
]
}
// end of the list of possible fields
}
Field |
Description |
run_id |
string Required field. ID of the run to listen to. |
events_start_idx |
Starting index for events. If provided, listening will start from this event. |
tool_result_list |
A list of tool results to submit to the run, such as the output of a function call. Includes only one of the fields Event to submit to the run. |
ToolResultList
Represents a list of tool results.
Field |
Description |
tool_results[] |
A list of tool results. |
ToolResult
Represents the result of a tool call.
Field |
Description |
function_result |
Represents the result of a function call. Includes only one of the fields |
FunctionResult
Represents the result of a function call.
Field |
Description |
name |
string The name of the function that was executed. |
content |
string The result of the function call, represented as a string. Includes only one of the fields |
StreamEvent
{
"event_type": "EventType",
"stream_cursor": {
"current_event_idx": "int64",
"num_user_events_received": "int64"
},
// Includes only one of the fields `error`, `partial_message`, `completed_message`, `tool_call_list`
"error": {
"code": "int64",
"message": "string"
},
"partial_message": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
},
"completed_message": {
"id": "string",
"thread_id": "string",
"created_by": "string",
"created_at": "google.protobuf.Timestamp",
"author": {
"id": "string",
"role": "string"
},
"labels": "map<string, string>",
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
},
"status": "MessageStatus",
"citations": [
{
"sources": [
{
// Includes only one of the fields `chunk`
"chunk": {
"search_index": {
"id": "string",
"folder_id": "string",
"name": "string",
"description": "string",
"created_by": "string",
"created_at": "google.protobuf.Timestamp",
"updated_by": "string",
"updated_at": "google.protobuf.Timestamp",
"expiration_config": {
"expiration_policy": "ExpirationPolicy",
"ttl_days": "int64"
},
"expires_at": "google.protobuf.Timestamp",
"labels": "map<string, string>",
// Includes only one of the fields `text_search_index`, `vector_search_index`, `hybrid_search_index`
"text_search_index": {
"chunking_strategy": {
// Includes only one of the fields `static_strategy`
"static_strategy": {
"max_chunk_size_tokens": "int64",
"chunk_overlap_tokens": "int64"
}
// end of the list of possible fields
},
// Includes only one of the fields `ngram_tokenizer`
"ngram_tokenizer": {
"min_gram": "google.protobuf.Int64Value",
"max_gram": "google.protobuf.Int64Value"
}
// end of the list of possible fields
},
"vector_search_index": {
"doc_embedder_uri": "string",
"query_embedder_uri": "string",
"chunking_strategy": {
// Includes only one of the fields `static_strategy`
"static_strategy": {
"max_chunk_size_tokens": "int64",
"chunk_overlap_tokens": "int64"
}
// end of the list of possible fields
}
},
"hybrid_search_index": {
"text_search_index": {
"chunking_strategy": {
// Includes only one of the fields `static_strategy`
"static_strategy": {
"max_chunk_size_tokens": "int64",
"chunk_overlap_tokens": "int64"
}
// end of the list of possible fields
},
// Includes only one of the fields `ngram_tokenizer`
"ngram_tokenizer": {
"min_gram": "google.protobuf.Int64Value",
"max_gram": "google.protobuf.Int64Value"
}
// end of the list of possible fields
},
"vector_search_index": {
"doc_embedder_uri": "string",
"query_embedder_uri": "string",
"chunking_strategy": {
// Includes only one of the fields `static_strategy`
"static_strategy": {
"max_chunk_size_tokens": "int64",
"chunk_overlap_tokens": "int64"
}
// end of the list of possible fields
}
},
"chunking_strategy": {
// Includes only one of the fields `static_strategy`
"static_strategy": {
"max_chunk_size_tokens": "int64",
"chunk_overlap_tokens": "int64"
}
// end of the list of possible fields
},
"normalization_strategy": "NormalizationStrategy",
"combination_strategy": {
// Includes only one of the fields `mean_combination`, `rrf_combination`
"mean_combination": {
"mean_evaluation_technique": "MeanEvaluationTechnique",
"weights": [
"double"
]
},
"rrf_combination": {
"k": "google.protobuf.Int64Value"
}
// end of the list of possible fields
}
}
// end of the list of possible fields
},
"source_file": {
"id": "string",
"folder_id": "string",
"name": "string",
"description": "string",
"mime_type": "string",
"created_by": "string",
"created_at": "google.protobuf.Timestamp",
"updated_by": "string",
"updated_at": "google.protobuf.Timestamp",
"expiration_config": {
"expiration_policy": "ExpirationPolicy",
"ttl_days": "int64"
},
"expires_at": "google.protobuf.Timestamp",
"labels": "map<string, string>"
},
"content": {
"content": [
{
// Includes only one of the fields `text`
"text": {
"content": "string"
}
// end of the list of possible fields
}
]
}
}
// end of the list of possible fields
}
]
}
]
},
"tool_call_list": {
"tool_calls": [
{
// Includes only one of the fields `function_call`
"function_call": {
"name": "string",
"arguments": "google.protobuf.Struct"
}
// end of the list of possible fields
}
]
}
// end of the list of possible fields
}
Represents an event in the stream of a run.
Field |
Description |
event_type |
enum EventType The type of event.
|
stream_cursor |
The current position in the stream. |
error |
Error information if the run has failed. Includes only one of the fields Event data, which can be one of several types. |
partial_message |
Partially generated message. Includes only one of the fields Event data, which can be one of several types. |
completed_message |
Final message generated by an assistant if a run has completed successfully. Includes only one of the fields Event data, which can be one of several types. |
tool_call_list |
A list of tool calls requested by the assistant. Includes only one of the fields Event data, which can be one of several types. |
StreamCursor
Represents the cursor position in a stream of events.
Field |
Description |
current_event_idx |
int64 Index of the current event in the stream. |
num_user_events_received |
int64 The number of user events received so far. |
Error
Field |
Description |
code |
int64 |
message |
string |
MessageContent
Represents the content of a message, which can consist of multiple parts.
Field |
Description |
content[] |
A list of content parts that make up the message. |
ContentPart
ContentPart represents an individual part of the message content, which can be of various types.
Field |
Description |
text |
Text content of the message part. Includes only one of the fields Specifies the type of content that the part contains. |
Text
Text represents a textual content part of a message.
Field |
Description |
content |
string Text content of the message. |
Message
Field |
Description |
id |
string Unique identifier of the message. |
thread_id |
string ID of the thread that this message belongs to. |
created_by |
string Identifier of the subject who created this message. |
created_at |
Timestamp representing when the message was created. |
author |
Author of the message, containing details about the message's creator. |
labels |
object (map<string, string>) Set of key-value pairs that can be used to organize and categorize the message. |
content |
Content of the message. |
status |
enum MessageStatus Status of the message.
|
citations[] |
List of citations used to generate the message. |
Author
Author of the message, containing details about the message's creator.
Field |
Description |
id |
string Unique identifier of the author. This could be either the user's ID or the assistant's ID, depending on the role. |
role |
string Role of the author, indicating whether the message was created by a "user" or an "assistant". |
Citation
Represents a citation used for generating a message.
Field |
Description |
sources[] |
List of sources for citation. |
Source
Represents a source used for generating a message citation.
Field |
Description |
chunk |
File chunk source. Includes only one of the fields Specifies the type of source type. |
FileChunk
FileChunk represents a chunk of a file used as a source.
Field |
Description |
search_index |
Search index associated with the file chunk. |
source_file |
The original file from which the chunk is derived. |
content |
Content of the file chunk. |
SearchIndex
Represents a search index used to store and query data, either using traditional keyword-based text search or vector-based search mechanisms.
Field |
Description |
id |
string Unique identifier of the search index. |
folder_id |
string ID of the folder that the search index belongs to. |
name |
string Name of the search index. |
description |
string Description of the search index. |
created_by |
string Identifier of the subject who created this search index. |
created_at |
Timestamp representing when the search index was created. |
updated_by |
string Identifier of the subject who last updated this search index. |
updated_at |
Timestamp representing the last time this search index was updated. |
expiration_config |
Configuration for the expiration of the search index, defining when and how the search index will expire. |
expires_at |
Timestamp representing when the search index will expire. |
labels |
object (map<string, string>) Set of key-value pairs that can be used to organize and categorize the search index. |
text_search_index |
Keyword-based text search index configuration. Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
vector_search_index |
Vector-based search index configuration. Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
hybrid_search_index |
Hybrid (vector-based + keyword-based) search index configuration Includes only one of the fields Type of the search index. It can be either a traditional keyword-based text search or a vector-based search. |
ExpirationConfig
Field |
Description |
expiration_policy |
enum ExpirationPolicy
|
ttl_days |
int64 |
TextSearchIndex
Defines the configuration for a traditional keyword-based text search index.
Field |
Description |
chunking_strategy |
Chunking strategy used to split text into smaller chunks before indexing. |
ngram_tokenizer |
Tokenizer that generates n-grams. Includes only one of the fields Tokenizer type used for text search. The tokenizer determines how the |
ChunkingStrategy
Defines a general strategy for chunking text into smaller segments.
Currently, only StaticChunkingStrategy is supported.
Field |
Description |
static_strategy |
Includes only one of the fields |
StaticChunkingStrategy
Defines a chunking strategy where chunks are created with a fixed maximum chunk size and an overlap between consecutive chunks.
Field |
Description |
max_chunk_size_tokens |
int64 The maximum number of tokens allowed in a single chunk. |
chunk_overlap_tokens |
int64 The number of tokens that should overlap between consecutive chunks. |
NgramTokenizer
Configuration for the NgramTokenizer, which splits text into overlapping character sequences (n-grams) of specified lengths.
Example:
Input text: hello
min_gram = 2, max_gram = 3
Generated tokens:
- For n = 2 (2-character n-grams):
he
,el
,ll
,lo
- For n = 3 (3-character n-grams):
hel
,ell
,llo
Final tokens: [he, el, ll, lo, hel, ell, llo]
Field |
Description |
min_gram |
Minimum length of characters in a gram. Defaults to 3 |
max_gram |
Maximum length of characters in a gram. Defaults to 4 |
VectorSearchIndex
Defines the configuration for a vector-based search index. This type uses embeddings to represent documents and queries.
Field |
Description |
doc_embedder_uri |
string The ID of the model to be used for obtaining document text embeddings. |
query_embedder_uri |
string The ID of the model to be used for obtaining query text embeddings. |
chunking_strategy |
Chunking strategy used to split text into smaller chunks before indexing. |
HybridSearchIndex
Defines the configuration for a hybrid (vector-based + keyword-based) search index. This type uses both embeddings and keyword-based search to represent documents and queries.
Field |
Description |
text_search_index |
Configuration for a traditional keyword-based text search index. |
vector_search_index |
Configuration for a vector-based search index. |
chunking_strategy |
Common chunking strategy that applies to both text and vector search indexes. |
normalization_strategy |
enum NormalizationStrategy Normalization strategy for relevance scores from different indices. Default is MIN_MAX_STRATEGY
|
combination_strategy |
Combination strategy for merging rankings from different indices. Default is arithmetic mean |
CombinationStrategy
Combination strategy for merging rankings from different indices
Field |
Description |
mean_combination |
Includes only one of the fields |
rrf_combination |
ReciprocalRankFusionCombinationStrategy Includes only one of the fields |
MeanCombinationStrategy
Field |
Description |
mean_evaluation_technique |
enum MeanEvaluationTechnique Technique for averaging relevance scores from different indices. Default is ARITHMETIC
|
weights[] |
double Weights used for evaluating the weighted mean of relevance scores. The sum of the values must equal 1.0 |
ReciprocalRankFusionCombinationStrategy
https://plg.uwaterloo.ca/~gvcormac/cormacksigir09-rrf.pdf
Field |
Description |
k |
The parameter k for RRFscore. Default is 60 |
File
Field |
Description |
id |
string Unique identifier of the file. |
folder_id |
string ID of the folder that the file belongs to. |
name |
string Name of the file. |
description |
string Description of the file. |
mime_type |
string MIME type of the file, indicating the file's format (e.g., "application/pdf") |
created_by |
string Identifier of the subject who created this file. |
created_at |
Timestamp representing when the file was created. |
updated_by |
string Identifier of the subject who last updated this file. |
updated_at |
Timestamp representing the last time this file was updated. |
expiration_config |
Configuration for the expiration of the file, defining when and how the file will expire. |
expires_at |
Timestamp representing when the file will expire. |
labels |
object (map<string, string>) Set of key-value pairs that can be used to organize and categorize the file. |
ChunkContent
Represents the content of a file chunk.
Field |
Description |
content[] |
A list of content parts that make up the chunk. |
ToolCallList
Represents a list of tool calls.
Field |
Description |
tool_calls[] |
A list of tool calls to be executed. |
ToolCall
Represents a call to a tool.
Field |
Description |
function_call |
Represents a call to a function. Includes only one of the fields |
FunctionCall
Represents the invocation of a function with specific arguments.
Field |
Description |
name |
string The name of the function being called. |
arguments |
The structured arguments passed to the function. |