|
| 1 | +"""UiPath Conversation Models. |
| 2 | +
|
| 3 | +This module provides Pydantic models that represent the JSON event schema for conversations between a client (UI) and an LLM/agent. |
| 4 | +
|
| 5 | +The event objects define a hierarchal conversation structure: |
| 6 | +
|
| 7 | +* Conversation |
| 8 | + * Exchange |
| 9 | + * Message |
| 10 | + * Content Parts |
| 11 | + * Citations |
| 12 | + * Tool Calls |
| 13 | + * Tool Results |
| 14 | +
|
| 15 | + A conversation may contain multiple exchanges, and an exchange may contain multiple messages. A message may contain |
| 16 | + multiple content parts, each of which can be text or binary, including media input and output streams; and each |
| 17 | + content part can include multiple citations. A message may also contain multiple tool calls, which may contain a tool |
| 18 | + result. |
| 19 | +
|
| 20 | + The protocol also supports a top level, "async", input media streams (audio and video), which can span multiple |
| 21 | + exchanges. These are used for Gemini's automatic turn detection mode, where the LLM determines when the user has |
| 22 | + stopped talking and starts producing output. The output forms one or more messages in an exchange with no explicit |
| 23 | + input message. However, the LLM may produce an input transcript which can be used to construct the implicit input |
| 24 | + message that started the exchange. |
| 25 | +
|
| 26 | + In addition, the protocol also supports "async" tool calls that span multiple exchanges. This can be used with |
| 27 | + Gemini's asynchronous function calling protocol, which allows function calls to produce results that interrupt the |
| 28 | + conversation when ready, even after multiple exchanges. They also support generating multiple results from a single |
| 29 | + tool call. By contrast most tool calls are scoped to a single message, which contains both the call and the single |
| 30 | + result produced by that call. |
| 31 | +
|
| 32 | + Not all features supported by the protocol will be supported by all clients and LLMs. The optional top level |
| 33 | + `capabilities` property can be used to communicate information about supported features. This property should be set |
| 34 | + on the first event written to a new websocket connection. This initial event may or may not contain additional |
| 35 | + sub-events. |
| 36 | +""" |
| 37 | + |
| 38 | +from .async_stream import ( |
| 39 | + UiPathConversationAsyncInputStreamEndEvent, |
| 40 | + UiPathConversationAsyncInputStreamEvent, |
| 41 | + UiPathConversationAsyncInputStreamStartEvent, |
| 42 | + UiPathConversationInputStreamChunkEvent, |
| 43 | +) |
| 44 | +from .citation import ( |
| 45 | + UiPathConversationCitationEndEvent, |
| 46 | + UiPathConversationCitationEvent, |
| 47 | + UiPathConversationCitationSource, |
| 48 | + UiPathConversationCitationSourceMedia, |
| 49 | + UiPathConversationCitationSourceUrl, |
| 50 | + UiPathConversationCitationStartEvent, |
| 51 | +) |
| 52 | +from .content import ( |
| 53 | + UiPathConversationContentPart, |
| 54 | + UiPathConversationContentPartChunkEvent, |
| 55 | + UiPathConversationContentPartEndEvent, |
| 56 | + UiPathConversationContentPartEvent, |
| 57 | + UiPathConversationContentPartStartEvent, |
| 58 | + UiPathExternalValue, |
| 59 | + UiPathInlineValue, |
| 60 | +) |
| 61 | +from .conversation import ( |
| 62 | + UiPathConversationCapabilities, |
| 63 | + UiPathConversationEndEvent, |
| 64 | + UiPathConversationStartedEvent, |
| 65 | + UiPathConversationStartEvent, |
| 66 | +) |
| 67 | +from .event import UiPathConversationEvent |
| 68 | +from .exchange import ( |
| 69 | + UiPathConversationExchange, |
| 70 | + UiPathConversationExchangeEndEvent, |
| 71 | + UiPathConversationExchangeEvent, |
| 72 | + UiPathConversationExchangeStartEvent, |
| 73 | +) |
| 74 | +from .message import ( |
| 75 | + UiPathConversationMessage, |
| 76 | + UiPathConversationMessageEndEvent, |
| 77 | + UiPathConversationMessageEvent, |
| 78 | + UiPathConversationMessageStartEvent, |
| 79 | +) |
| 80 | +from .meta import UiPathConversationMetaEvent |
| 81 | +from .tool import ( |
| 82 | + UiPathConversationToolCall, |
| 83 | + UiPathConversationToolCallEndEvent, |
| 84 | + UiPathConversationToolCallEvent, |
| 85 | + UiPathConversationToolCallResult, |
| 86 | + UiPathConversationToolCallStartEvent, |
| 87 | +) |
| 88 | + |
| 89 | +__all__ = [ |
| 90 | + # Root |
| 91 | + "UiPathConversationEvent", |
| 92 | + # Conversation |
| 93 | + "UiPathConversationCapabilities", |
| 94 | + "UiPathConversationStartEvent", |
| 95 | + "UiPathConversationStartedEvent", |
| 96 | + "UiPathConversationEndEvent", |
| 97 | + # Exchange |
| 98 | + "UiPathConversationExchangeStartEvent", |
| 99 | + "UiPathConversationExchangeEndEvent", |
| 100 | + "UiPathConversationExchangeEvent", |
| 101 | + "UiPathConversationExchange", |
| 102 | + # Message |
| 103 | + "UiPathConversationMessageStartEvent", |
| 104 | + "UiPathConversationMessageEndEvent", |
| 105 | + "UiPathConversationMessageEvent", |
| 106 | + "UiPathConversationMessage", |
| 107 | + # Content |
| 108 | + "UiPathConversationContentPartChunkEvent", |
| 109 | + "UiPathConversationContentPartStartEvent", |
| 110 | + "UiPathConversationContentPartEndEvent", |
| 111 | + "UiPathConversationContentPartEvent", |
| 112 | + "UiPathConversationContentPart", |
| 113 | + "UiPathInlineValue", |
| 114 | + "UiPathExternalValue", |
| 115 | + # Citation |
| 116 | + "UiPathConversationCitationStartEvent", |
| 117 | + "UiPathConversationCitationEndEvent", |
| 118 | + "UiPathConversationCitationEvent", |
| 119 | + "UiPathConversationCitationSource", |
| 120 | + "UiPathConversationCitationSourceUrl", |
| 121 | + "UiPathConversationCitationSourceMedia", |
| 122 | + # Tool |
| 123 | + "UiPathConversationToolCallStartEvent", |
| 124 | + "UiPathConversationToolCallEndEvent", |
| 125 | + "UiPathConversationToolCallEvent", |
| 126 | + "UiPathConversationToolCallResult", |
| 127 | + "UiPathConversationToolCall", |
| 128 | + # Async Stream |
| 129 | + "UiPathConversationInputStreamChunkEvent", |
| 130 | + "UiPathConversationAsyncInputStreamStartEvent", |
| 131 | + "UiPathConversationAsyncInputStreamEndEvent", |
| 132 | + "UiPathConversationAsyncInputStreamEvent", |
| 133 | + # Meta |
| 134 | + "UiPathConversationMetaEvent", |
| 135 | +] |
0 commit comments