autogen_core.models#

pydantic model AssistantMessage[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "AssistantMessage",
   "type": "object",
   "properties": {
      "content": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "items": {
                  "$ref": "#/$defs/FunctionCall"
               },
               "type": "array"
            }
         ],
         "title": "Content"
      },
      "source": {
         "title": "Source",
         "type": "string"
      },
      "type": {
         "const": "AssistantMessage",
         "default": "AssistantMessage",
         "enum": [
            "AssistantMessage"
         ],
         "title": "Type",
         "type": "string"
      }
   },
   "$defs": {
      "FunctionCall": {
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "arguments": {
               "title": "Arguments",
               "type": "string"
            },
            "name": {
               "title": "Name",
               "type": "string"
            }
         },
         "required": [
            "id",
            "arguments",
            "name"
         ],
         "title": "FunctionCall",
         "type": "object"
      }
   },
   "required": [
      "content",
      "source"
   ]
}

Fields:
  • content (str | List[autogen_core._types.FunctionCall])

  • source (str)

  • type (Literal['AssistantMessage'])

field content: str | List[FunctionCall] [Required]#
field source: str [Required]#
field type: Literal['AssistantMessage'] = 'AssistantMessage'#
class ChatCompletionClient(*args, **kwargs)[source]#

Bases: Protocol

actual_usage() RequestUsage[source]#
property capabilities: ModelCapabilities#
count_tokens(messages: Sequence[Annotated[SystemMessage | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], tools: Sequence[Tool | ToolSchema] = []) int[source]#
async create(messages: Sequence[Annotated[SystemMessage | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], tools: Sequence[Tool | ToolSchema] = [], json_output: bool | None = None, extra_create_args: Mapping[str, Any] = {}, cancellation_token: CancellationToken | None = None) CreateResult[source]#
create_stream(messages: Sequence[Annotated[SystemMessage | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], tools: Sequence[Tool | ToolSchema] = [], json_output: bool | None = None, extra_create_args: Mapping[str, Any] = {}, cancellation_token: CancellationToken | None = None) AsyncGenerator[str | CreateResult, None][source]#
remaining_tokens(messages: Sequence[Annotated[SystemMessage | UserMessage | AssistantMessage | FunctionExecutionResultMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], tools: Sequence[Tool | ToolSchema] = []) int[source]#
total_usage() RequestUsage[source]#
pydantic model ChatCompletionTokenLogprob[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "ChatCompletionTokenLogprob",
   "type": "object",
   "properties": {
      "token": {
         "title": "Token",
         "type": "string"
      },
      "logprob": {
         "title": "Logprob",
         "type": "number"
      },
      "top_logprobs": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/TopLogprob"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Top Logprobs"
      },
      "bytes": {
         "anyOf": [
            {
               "items": {
                  "type": "integer"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Bytes"
      }
   },
   "$defs": {
      "TopLogprob": {
         "properties": {
            "logprob": {
               "title": "Logprob",
               "type": "number"
            },
            "bytes": {
               "anyOf": [
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Bytes"
            }
         },
         "required": [
            "logprob"
         ],
         "title": "TopLogprob",
         "type": "object"
      }
   },
   "required": [
      "token",
      "logprob"
   ]
}

Fields:
  • bytes (List[int] | None)

  • logprob (float)

  • token (str)

  • top_logprobs (List[autogen_core.models._types.TopLogprob] | None)

field bytes: List[int] | None = None#
field logprob: float [Required]#
field token: str [Required]#
field top_logprobs: List[TopLogprob] | None = None#
pydantic model CreateResult[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "CreateResult",
   "type": "object",
   "properties": {
      "finish_reason": {
         "enum": [
            "stop",
            "length",
            "function_calls",
            "content_filter"
         ],
         "title": "Finish Reason",
         "type": "string"
      },
      "content": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "items": {
                  "$ref": "#/$defs/FunctionCall"
               },
               "type": "array"
            }
         ],
         "title": "Content"
      },
      "usage": {
         "$ref": "#/$defs/RequestUsage"
      },
      "cached": {
         "title": "Cached",
         "type": "boolean"
      },
      "logprobs": {
         "anyOf": [
            {
               "items": {
                  "$ref": "#/$defs/ChatCompletionTokenLogprob"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Logprobs"
      }
   },
   "$defs": {
      "ChatCompletionTokenLogprob": {
         "properties": {
            "token": {
               "title": "Token",
               "type": "string"
            },
            "logprob": {
               "title": "Logprob",
               "type": "number"
            },
            "top_logprobs": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/TopLogprob"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Top Logprobs"
            },
            "bytes": {
               "anyOf": [
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Bytes"
            }
         },
         "required": [
            "token",
            "logprob"
         ],
         "title": "ChatCompletionTokenLogprob",
         "type": "object"
      },
      "FunctionCall": {
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "arguments": {
               "title": "Arguments",
               "type": "string"
            },
            "name": {
               "title": "Name",
               "type": "string"
            }
         },
         "required": [
            "id",
            "arguments",
            "name"
         ],
         "title": "FunctionCall",
         "type": "object"
      },
      "RequestUsage": {
         "properties": {
            "prompt_tokens": {
               "title": "Prompt Tokens",
               "type": "integer"
            },
            "completion_tokens": {
               "title": "Completion Tokens",
               "type": "integer"
            }
         },
         "required": [
            "prompt_tokens",
            "completion_tokens"
         ],
         "title": "RequestUsage",
         "type": "object"
      },
      "TopLogprob": {
         "properties": {
            "logprob": {
               "title": "Logprob",
               "type": "number"
            },
            "bytes": {
               "anyOf": [
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Bytes"
            }
         },
         "required": [
            "logprob"
         ],
         "title": "TopLogprob",
         "type": "object"
      }
   },
   "required": [
      "finish_reason",
      "content",
      "usage",
      "cached"
   ]
}

Fields:
  • cached (bool)

  • content (str | List[autogen_core._types.FunctionCall])

  • finish_reason (Literal['stop', 'length', 'function_calls', 'content_filter'])

  • logprobs (List[autogen_core.models._types.ChatCompletionTokenLogprob] | None)

  • usage (autogen_core.models._types.RequestUsage)

field cached: bool [Required]#
field content: str | List[FunctionCall] [Required]#
field finish_reason: Literal['stop', 'length', 'function_calls', 'content_filter'] [Required]#
field logprobs: List[ChatCompletionTokenLogprob] | None = None#
field usage: RequestUsage [Required]#
pydantic model FunctionExecutionResult[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "FunctionExecutionResult",
   "type": "object",
   "properties": {
      "content": {
         "title": "Content",
         "type": "string"
      },
      "call_id": {
         "title": "Call Id",
         "type": "string"
      }
   },
   "required": [
      "content",
      "call_id"
   ]
}

Fields:
  • call_id (str)

  • content (str)

field call_id: str [Required]#
field content: str [Required]#
pydantic model FunctionExecutionResultMessage[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "FunctionExecutionResultMessage",
   "type": "object",
   "properties": {
      "content": {
         "items": {
            "$ref": "#/$defs/FunctionExecutionResult"
         },
         "title": "Content",
         "type": "array"
      },
      "type": {
         "const": "FunctionExecutionResultMessage",
         "default": "FunctionExecutionResultMessage",
         "enum": [
            "FunctionExecutionResultMessage"
         ],
         "title": "Type",
         "type": "string"
      }
   },
   "$defs": {
      "FunctionExecutionResult": {
         "properties": {
            "content": {
               "title": "Content",
               "type": "string"
            },
            "call_id": {
               "title": "Call Id",
               "type": "string"
            }
         },
         "required": [
            "content",
            "call_id"
         ],
         "title": "FunctionExecutionResult",
         "type": "object"
      }
   },
   "required": [
      "content"
   ]
}

Fields:
  • content (List[autogen_core.models._types.FunctionExecutionResult])

  • type (Literal['FunctionExecutionResultMessage'])

field content: List[FunctionExecutionResult] [Required]#
field type: Literal['FunctionExecutionResultMessage'] = 'FunctionExecutionResultMessage'#
class ModelCapabilities[source]#

Bases: TypedDict

function_calling: Required[bool]#
json_output: Required[bool]#
vision: Required[bool]#
class RequestUsage(prompt_tokens: int, completion_tokens: int)[source]#

Bases: object

completion_tokens: int#
prompt_tokens: int#
pydantic model SystemMessage[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "SystemMessage",
   "type": "object",
   "properties": {
      "content": {
         "title": "Content",
         "type": "string"
      },
      "type": {
         "const": "SystemMessage",
         "default": "SystemMessage",
         "enum": [
            "SystemMessage"
         ],
         "title": "Type",
         "type": "string"
      }
   },
   "required": [
      "content"
   ]
}

Fields:
  • content (str)

  • type (Literal['SystemMessage'])

field content: str [Required]#
field type: Literal['SystemMessage'] = 'SystemMessage'#
class TopLogprob(logprob: float, bytes: List[int] | None = None)[source]#

Bases: object

bytes: List[int] | None = None#
logprob: float#
pydantic model UserMessage[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "UserMessage",
   "type": "object",
   "properties": {
      "content": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "items": {
                  "anyOf": [
                     {
                        "type": "string"
                     },
                     {}
                  ]
               },
               "type": "array"
            }
         ],
         "title": "Content"
      },
      "source": {
         "title": "Source",
         "type": "string"
      },
      "type": {
         "const": "UserMessage",
         "default": "UserMessage",
         "enum": [
            "UserMessage"
         ],
         "title": "Type",
         "type": "string"
      }
   },
   "required": [
      "content",
      "source"
   ]
}

Fields:
  • content (str | List[str | autogen_core._image.Image])

  • source (str)

  • type (Literal['UserMessage'])

field content: str | List[str | Image] [Required]#
field source: str [Required]#
field type: Literal['UserMessage'] = 'UserMessage'#