cohere.types¶
Types for interacting with Cohere chat models using Mirascope.
CohereCallParams
¶
Bases: BaseCallParams[CohereTool]
The parameters to use when calling the Cohere chat API.
Source code in mirascope/cohere/types.py
kwargs(tool_type=CohereTool, exclude=None)
¶
Returns the keyword argument call parameters.
Source code in mirascope/cohere/types.py
CohereCallResponse
¶
Bases: BaseCallResponse[NonStreamedChatResponse, CohereTool]
A convenience wrapper around the Cohere NonStreamedChatResponse
response.
When using Mirascope's convenience wrappers to interact with Cohere chat models via
CohereCall
, responses using CohereCall.call()
will return a CohereCallResponse
whereby the implemented properties allow for simpler syntax and a convenient
developer experience.
Example:
from mirascope.cohere import CohereCall
class BookRecommender(CohereCall):
prompt_template = "Please recommend a {genre} book"
genre: str
response = Bookrecommender(genre="fantasy").call()
print(response.content)
#> The Name of the Wind
print(response.message)
#> ...
print(response.choices)
#> ...
Source code in mirascope/cohere/types.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
citations: Optional[list[ChatCitation]]
property
¶
Returns the citations for the 0th choice message.
content: str
property
¶
Returns the content of the chat completion for the 0th choice.
documents: Optional[list[ChatDocument]]
property
¶
Returns the documents for the 0th choice message.
search_queries: Optional[list[ChatSearchQuery]]
property
¶
Returns the search queries for the 0th choice message.
search_results: Optional[list[ChatSearchResult]]
property
¶
Returns the search results for the 0th choice message.
tool: Optional[CohereTool]
property
¶
Returns the 0th tool for the 0th choice message.
Raises:
Type | Description |
---|---|
ValidationError
|
if the tool call doesn't match the tool's schema. |
tool_calls: Optional[list[ToolCall]]
property
¶
Returns the tool calls for the 0th choice message.
tools: Optional[list[CohereTool]]
property
¶
Returns the tools for the 0th choice message.
Raises:
Type | Description |
---|---|
ValidationError
|
if a tool call doesn't match the tool's schema. |
dump()
¶
Dumps the response to a dictionary.
CohereCallResponseChunk
¶
Bases: BaseCallResponseChunk[StreamedChatResponse, CohereTool]
Convenience wrapper around chat completion streaming chunks.
When using Mirascope's convenience wrappers to interact with Cohere models via
CohereCall.stream
, responses will return an CohereCallResponseChunk
, whereby
the implemented properties allow for simpler syntax and a convenient developer
experience.
Example:
```python from mirascope.cohere import CohereCall
class Math(CohereCall): prompt_template = "What is 1 + 2?"
for chunk in CohereCall().stream(): print(chunk.content)
> 1¶
+¶
2¶
equals¶
¶
3¶
.¶
Source code in mirascope/cohere/types.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
citations: Optional[list[ChatCitation]]
property
¶
Returns the citations for citation-generation event type else None.
content: str
property
¶
Returns the content for the 0th choice delta.
documents: Optional[list[ChatDocument]]
property
¶
Returns the documents for citation-generation event type else None.
event_type: Literal['stream-start', 'search-queries-generation', 'search-results', 'text-generation', 'citation-generation', 'tool-calls-generation', 'stream-end']
property
¶
Returns the type of the chunk.
response: Optional[NonStreamedChatResponse]
property
¶
Returns the response for text-generation event type else None.
search_queries: Optional[list[ChatSearchQuery]]
property
¶
Returns the search queries for search-query event type else None.
search_results: Optional[list[ChatSearchResult]]
property
¶
Returns the search results for search-results event type else None.
tool_calls: Optional[list[ToolCall]]
property
¶
Returns the partial tool calls for the 0th choice message.
CohereEmbeddingResponse
¶
Bases: BaseEmbeddingResponse[SkipValidation[EmbedResponse]]
A convenience wrapper around the Cohere EmbedResponse
response.
Source code in mirascope/cohere/types.py
embeddings: Optional[Union[list[list[float]], list[list[int]]]]
property
¶
Returns the embeddings
RequestOptions
¶
Bases: TypedDict
Redefining their class to use typing_extensions.TypedDict
for Pydantic.