Chat (Experimental API)¶
- class ChatService[source]¶
For interacting with Chat objects
- get(id_, formatter=None)[source]¶
Return a Chat by its id
- Parameters:
id_ (str) –
formatter (InlineAttributionFormatter | None) –
- Return type:
- list(formatter=None)[source]¶
- Parameters:
formatter (InlineAttributionFormatter | None) –
- Return type:
list[Chat]
- new(name, formatter=None)[source]¶
Create a new chat
- Parameters:
name (str) –
formatter (InlineAttributionFormatter | None) –
- Return type:
- class ChatInteraction[source]¶
Represents a single interaction with chat
- field answer: str [Required]¶
- field date_created: datetime [Required]¶
- field interaction_timestamp: str [Required]¶
- field last_updated: datetime [Required]¶
- field question: str [Required]¶
- field sources: list[ChatSource] [Optional]¶
- class StreamingChatInteraction[source]¶
Represents a streaming interaction in a chat session.
This class handles live interactions where the response is obtained in chunks, allowing for real-time processing while the interaction is ongoing.
- __init__(_chat, _formatter, **values)[source]¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_post_init(context, /)¶
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- Return type:
None
- class Chat[source]¶
- ask(question, *, scope=None, formatter=None, streaming=False)[source]¶
Ask a question in the chat
- Parameters:
question (str) –
scope (ChatScope | None) –
formatter (InlineAttributionFormatter | None) –
streaming (bool) –
- Return type:
- field date_created: datetime [Required]¶
- field id: str [Required]¶
- property interactions: list[ChatInteraction]¶
- field last_updated: datetime [Required]¶
- field name: str [Required]¶
- field user_id: str [Required]¶
- class ChatScope[source]¶
- EARNING_CALLS = 'transcripts'¶
- FILES = 'files'¶
- NEWS = 'news'¶
- REGULATORY_FILINGS = 'filings'¶
- __new__(value)¶
- class ChatSource[source]¶
Represents a source in a chat message
- field document_scope: str | None [Required]¶
- field headline: str [Required]¶
- field id: str [Required]¶
- field rp_provider_id: str | None [Required]¶
- field url: str | None [Required]¶
- class InlineAttributionFormatter[source]¶
Interface for formatting inline attributions in chat messages
- abstract format(index, source)[source]¶
Format an inline attribution.
- Parameters:
index (int) – The index of the attribution within the list of attributions.
source (ChatSource) – The inline attribution to format.
- Returns:
A string representing the formatted attribution.
- Return type:
str
- class DefaultFormatter[source]¶
Default formatter for inline attributions in chat messages
- format(index, source)[source]¶
Format an inline attribution using a default reference style.
- Parameters:
index (int) – The index of the attribution within the list of attributions.
source (ChatSource) – The inline attribution to format.
- Returns:
A string representing the formatted attribution in default reference style.
- Return type:
str
- class MarkdownLinkFormatter[source]¶
Formatter for inline attributions in chat messages that uses Markdown links
- __init__(headline_length=None, skip_empty_urls=True)[source]¶
Initialize the MarkdownLinkInlineAttributionFormatter.
- Parameters:
headline_length (int) – The maximum length of the headline to be displayed in the link. Default is 10.
skip_empty_urls (bool) –
- format(index, source)[source]¶
Format an inline attribution as a Markdown link.
- Parameters:
index (int) – The index of the attribution within the list of attributions.
source (ChatSource) – The inline attribution to format.
- Returns:
A string representing the formatted attribution as a Markdown link.
- Return type:
str