LLM
Agent
¶
Source code in python/scouter/llm/_llm.pyi
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
|
id
property
¶
The ID of the agent. This is a random uuid7 that is generated when the agent is created.
system_instruction
property
¶
The system message to use for the agent. This is a list of Message objects.
__init__(provider, system_instruction=None)
¶
Create an Agent object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider
|
Provider | str
|
The provider to use for the agent. This can be a Provider enum or a string representing the provider. |
required |
system_instruction
|
Optional[str | List[str] | Message | List[Message]]
|
The system message to use for the agent. This can be a string, a list of strings, a Message object, or a list of Message objects. If None, no system message will be used. This is added to all tasks that the agent executes. If a given task contains it's own system message, the agent's system message will be prepended to the task's system message. |
None
|
Example:
Source code in python/scouter/llm/_llm.pyi
execute_prompt(prompt, output_type=None, model=None)
¶
Execute a prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Prompt
|
` The prompt to execute. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
None
|
model
|
Optional[str]
|
The model to use for the task. If not provided, defaults to the |
None
|
Returns:
Name | Type | Description |
---|---|---|
AgentResponse |
AgentResponse
|
The response from the agent after executing the task. |
Source code in python/scouter/llm/_llm.pyi
execute_task(task, output_type=None, model=None)
¶
Execute a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
The task to execute. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
None
|
model
|
Optional[str]
|
The model to use for the task. If not provided, defaults to the |
None
|
Returns:
Name | Type | Description |
---|---|---|
AgentResponse |
AgentResponse
|
The response from the agent after executing the task. |
Source code in python/scouter/llm/_llm.pyi
AgentResponse
¶
Source code in python/scouter/llm/_llm.pyi
id
property
¶
The ID of the agent response.
log_probs
property
¶
Returns the log probabilities of the agent response if supported. This is primarily used for debugging and analysis purposes.
result
property
¶
The result of the agent response. This can be a Pydantic BaseModel class or a supported
potato_head response type such as Score
. If neither is provided, the response json will
be returned as a dictionary.
token_usage
property
¶
Returns the token usage of the agent response if supported
AudioUrl
¶
Source code in python/scouter/llm/_llm.pyi
format
property
¶
The format of the audio URL.
kind
property
¶
The kind of the content.
media_type
property
¶
The media type of the audio URL.
url
property
¶
The URL of the audio.
__init__(url, kind='audio-url')
¶
Create an AudioUrl object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the audio. |
required |
kind
|
Literal['audio-url']
|
The kind of the content. |
'audio-url'
|
BinaryContent
¶
Source code in python/scouter/llm/_llm.pyi
data
property
¶
The binary data.
format
property
¶
The format of the binary content.
kind
property
¶
The kind of the content.
media_type
property
¶
The media type of the binary content.
__init__(data, media_type, kind='binary')
¶
Create a BinaryContent object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
bytes
|
The binary data. |
required |
media_type
|
str
|
The media type of the binary data. |
required |
kind
|
str
|
The kind of the content |
'binary'
|
Source code in python/scouter/llm/_llm.pyi
CompletionTokenDetails
¶
Details about the completion tokens used in a model response.
Source code in python/scouter/llm/_llm.pyi
accepted_prediction_tokens
property
¶
The number of accepted prediction tokens used in the response.
audio_tokens
property
¶
The number of audio tokens used in the response.
reasoning_tokens
property
¶
The number of reasoning tokens used in the response.
rejected_prediction_tokens
property
¶
The number of rejected prediction tokens used in the response.
DocumentUrl
¶
Source code in python/scouter/llm/_llm.pyi
format
property
¶
The format of the document URL.
kind
property
¶
The kind of the content.
media_type
property
¶
The media type of the document URL.
url
property
¶
The URL of the document.
__init__(url, kind='document-url')
¶
Create a DocumentUrl object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the document. |
required |
kind
|
Literal['document-url']
|
The kind of the content. |
'document-url'
|
Source code in python/scouter/llm/_llm.pyi
EventDetails
¶
Source code in python/scouter/llm/_llm.pyi
duration
property
¶
The duration of the task execution.
end_time
property
¶
The end time of the task execution.
error
property
¶
The error message if the task failed, otherwise None.
prompt
property
¶
The prompt used for the task.
response
property
¶
The response from the agent after executing the task.
start_time
property
¶
The start time of the task execution.
ImageUrl
¶
Source code in python/scouter/llm/_llm.pyi
format
property
¶
The format of the image URL.
kind
property
¶
The kind of the content.
media_type
property
¶
The media type of the image URL.
url
property
¶
The URL of the image.
__init__(url, kind='image-url')
¶
Create an ImageUrl object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the image. |
required |
kind
|
Literal['image-url']
|
The kind of the content. |
'image-url'
|
LogProbs
¶
Source code in python/scouter/llm/_llm.pyi
tokens
property
¶
The log probabilities of the tokens in the response. This is primarily used for debugging and analysis purposes.
Message
¶
Source code in python/scouter/llm/_llm.pyi
191 192 193 194 195 196 197 198 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 |
|
content
property
¶
The content of the message
__init__(content)
¶
Create a Message object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str | ImageUrl | AudioUrl | BinaryContent | DocumentUrl
|
The content of the message. |
required |
bind(name, value)
¶
Bind context to a specific variable in the prompt. This is an immutable operation meaning that it will return a new Message object with the context bound.
Example with Prompt that contains two messages
```python
prompt = Prompt(
model="openai:gpt-4o",
message=[
"My prompt variable is ${variable}",
"This is another message",
],
system_instruction="system_prompt",
)
bounded_prompt = prompt.message[0].bind("variable", "hello world").unwrap() # we bind "hello world" to "variable"
```
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable to bind. |
required |
value
|
str
|
The value to bind the variable to. |
required |
Returns:
Name | Type | Description |
---|---|---|
Message |
Message
|
The message with the context bound. |
Source code in python/scouter/llm/_llm.pyi
bind_mut(name, value)
¶
Bind context to a specific variable in the prompt. This is a mutable operation meaning that it will modify the current Message object.
Example with Prompt that contains two messages
```python
prompt = Prompt(
model="openai:gpt-4o",
message=[
"My prompt variable is ${variable}",
"This is another message",
],
system_instruction="system_prompt",
)
prompt.message[0].bind_mut("variable", "hello world") # we bind "hello world" to "variable"
```
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable to bind. |
required |
value
|
str
|
The value to bind the variable to. |
required |
Returns:
Name | Type | Description |
---|---|---|
Message |
Message
|
The message with the context bound. |
Source code in python/scouter/llm/_llm.pyi
model_dump()
¶
Unwrap the message content and serialize it to a dictionary.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The message dictionary with keys "content" and "role". |
unwrap()
¶
Unwrap the message content.
Returns:
Type | Description |
---|---|
Any
|
A serializable representation of the message content, which can be a string, list, or dict. |
ModelSettings
¶
Source code in python/scouter/llm/_llm.pyi
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
extra_body
property
¶
The extra body to use.
frequency_penalty
property
¶
The frequency penalty to use.
logit_bias
property
¶
The logit bias to use.
max_tokens
property
¶
The maximum number of tokens to generate.
model
property
¶
The model to use.
parallel_tool_calls
property
¶
Whether to allow parallel tool calls.
presence_penalty
property
¶
The presence penalty to use.
provider
property
¶
The provider to use.
seed
property
¶
The seed to use for the model allowing for reproducible results.
stop_sequences
property
¶
The stop sequences to use.
temperature
property
¶
The amount of randomness to use.
timeout
property
¶
The timeout to use.
top_p
property
¶
The top p to use.
__init__(model=None, provider=None, max_tokens=None, temperature=None, top_p=None, frequency_penalty=None, presence_penalty=None, timeout=None, parallel_tool_calls=None, seed=None, logit_bias=None, stop_sequences=None, logprobs=None, extra_body=None)
¶
ModelSettings for configuring the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Optional[str]
|
The model to use. This is required if model is not provided in the prompt.
If not provided, defaults to |
None
|
provider
|
Optional[str]
|
The provider to use. This is required if provider is not provided in the prompt.
If not provided, defaults to |
None
|
max_tokens
|
Optional[int]
|
The maximum number of tokens to generate. |
None
|
temperature
|
Optional[float]
|
The amount of randomness to use. |
None
|
top_p
|
Optional[float]
|
The top p to use. |
None
|
frequency_penalty
|
Optional[float]
|
The frequency penalty to use. Penalizes new tokens based on their frequency in the text. |
None
|
presence_penalty
|
Optional[float]
|
The presence penalty to use. Penalizes new tokens based on whether they already appear in the text. |
None
|
timeout
|
Optional[float]
|
The timeout to use. |
None
|
parallel_tool_calls
|
Optional[bool]
|
Whether to allow parallel tool calls. |
None
|
seed
|
Optional[int]
|
The seed to use for the model allowing for reproducible results. |
None
|
logit_bias
|
Optional[dict[str, int]]
|
The logit bias to use. Modifies the likelihood of specified tokens appearing in the generated text. |
None
|
stop_sequences
|
Optional[List[str]]
|
The stop sequences to use that will cause the model to stop generating text. |
None
|
logprobs
|
Optional[bool]
|
Whether to include log probabilities in the response. This is a gemini specific setting. |
None
|
extra_body
|
Optional[dict[str, Any]]
|
The extra body to use. Must be a dictionary |
None
|
Source code in python/scouter/llm/_llm.pyi
Prompt
¶
Source code in python/scouter/llm/_llm.pyi
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|
message
property
¶
The user message to use in the prompt.
model
property
¶
The model to use for the prompt.
model_identifier
property
¶
Concatenation of provider and model, used for identifying the model in the prompt. This is commonly used with pydantic_ai to identify the model to use for the agent.
model_settings
property
¶
The model settings to use for the prompt.
provider
property
¶
The provider to use for the prompt.
response_json_schema
property
¶
The JSON schema for the response if provided.
system_instruction
property
¶
The system message to use in the prompt.
__init__(message, model=None, provider=None, system_instruction=None, model_settings=None, response_format=None)
¶
Prompt for interacting with an LLM API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str | Sequence[str | ImageUrl | AudioUrl | BinaryContent | DocumentUrl] | Message | List[Message]
|
The prompt to use. |
required |
model
|
str | None
|
The model to use for the prompt. Required if model_settings is not provided.
If not provided, defaults to |
None
|
provider
|
str | None
|
The provider to use for the prompt. Required if model_settings is not provided.
If not provided, defaults |
None
|
system_instruction
|
Optional[str | List[str]]
|
The system prompt to use in the prompt. |
None
|
model_settings
|
None
|
The model settings to use for the prompt. Defaults to None which means no model settings will be used |
None
|
response_format
|
Optional[BaseModel | Score]
|
The response format to use for the prompt. This is used for Structured Outputs (https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat). Currently, response_format only support Pydantic BaseModel classes and the PotatoHead Score class. The provided response_format will be parsed into a JSON schema. |
None
|
Source code in python/scouter/llm/_llm.pyi
bind(name=None, value=None, **kwargs)
¶
Bind context to a specific variable in the prompt. This is an immutable operation meaning that it will return a new Prompt object with the context bound. This will iterate over all user messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable to bind. |
None
|
value
|
str | int | float | bool | list
|
The value to bind the variable to. Must be a JSON serializable type. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to bind to the prompt. This can be used to bind multiple variables at once. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Prompt |
Prompt
|
The prompt with the context bound. |
Source code in python/scouter/llm/_llm.pyi
bind_mut(name=None, value=None, **kwargs)
¶
Bind context to a specific variable in the prompt. This is a mutable operation meaning that it will modify the current Prompt object. This will iterate over all user messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable to bind. |
None
|
value
|
str | int | float | bool | list
|
The value to bind the variable to. Must be a JSON serializable type. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to bind to the prompt. This can be used to bind multiple variables at once. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Prompt |
Prompt
|
The prompt with the context bound. |
Source code in python/scouter/llm/_llm.pyi
from_path(path)
staticmethod
¶
Load a prompt from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
The path to the prompt file. |
required |
Returns:
Name | Type | Description |
---|---|---|
Prompt |
Prompt
|
The loaded prompt. |
model_dump_json()
¶
model_validate_json(json_string)
staticmethod
¶
Validate the model JSON.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The JSON string to validate. |
required |
Returns: Prompt: The prompt object.
save_prompt(path=None)
¶
Save the prompt to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Optional[Path]
|
The path to save the prompt to. If None, the prompt will be saved to the current working directory. |
None
|
PromptTokenDetails
¶
Details about the prompt tokens used in a request.
Source code in python/scouter/llm/_llm.pyi
PyTask
¶
Python-specific task interface for Task objects and results
Source code in python/scouter/llm/_llm.pyi
agent_id
property
¶
The ID of the agent that will execute the task.
dependencies
property
¶
The dependencies of the task.
id
property
¶
The ID of the task.
prompt
property
¶
The prompt to use for the task.
result
property
¶
The result of the task if it has been executed, otherwise None.
status
property
¶
The status of the task.
ResponseLogProbs
¶
Source code in python/scouter/llm/_llm.pyi
Score
¶
A class representing a score with a score value and a reason. This is typically used as a response type for tasks/prompts that require scoring or evaluation of results.
Example:
Prompt(
model="openai:gpt-4o",
message="What is the score of this response?",
system_instruction="system_prompt",
response_format=Score,
)
Source code in python/scouter/llm/_llm.pyi
reason
property
¶
The reason for the score.
score
property
¶
The score value.
Task
¶
Source code in python/scouter/llm/_llm.pyi
dependencies
property
¶
The dependencies of the task.
id
property
¶
The ID of the task.
prompt
property
¶
The prompt to use for the task.
status
property
¶
The status of the task.
__init__(agent_id, prompt, dependencies=[], id=None)
¶
Create a Task object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_id
|
str
|
The ID of the agent that will execute the task. |
required |
prompt
|
Prompt
|
The prompt to use for the task. |
required |
dependencies
|
List[str]
|
The dependencies of the task. |
[]
|
id
|
Optional[str]
|
The ID of the task. If None, a random uuid7 will be generated. |
None
|
Source code in python/scouter/llm/_llm.pyi
TaskEvent
¶
Source code in python/scouter/llm/_llm.pyi
details
property
¶
Additional details about the event. This can include information such as error messages or other relevant data.
id
property
¶
The ID of the event
status
property
¶
The status of the task at the time of the event.
task_id
property
¶
The ID of the task that the event is associated with.
timestamp
property
¶
The timestamp of the event. This is the time when the event occurred.
updated_at
property
¶
The timestamp of when the event was last updated. This is useful for tracking changes to the event.
workflow_id
property
¶
The ID of the workflow that the task is part of.
TaskList
¶
Usage
¶
Usage statistics for a model response.
Source code in python/scouter/llm/_llm.pyi
completion_tokens
property
¶
The number of completion tokens used in the response.
completion_tokens_details
property
¶
Details about the completion tokens used in the response.
finish_reason
property
¶
The reason why the model stopped generating tokens
prompt_tokens
property
¶
The number of prompt tokens used in the request.
prompt_tokens_details
property
¶
Details about the prompt tokens used in the request.
total_tokens
property
¶
The total number of tokens used in the request and response.
Workflow
¶
Source code in python/scouter/llm/_llm.pyi
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
|
agents
property
¶
The agents in the workflow.
is_workflow
property
¶
Returns True if the workflow is a valid workflow, otherwise False. This is used to determine if the workflow can be executed.
name
property
¶
The name of the workflow.
task_list
property
¶
The tasks in the workflow.
__init__(name)
¶
__workflow__()
¶
add_agent(agent)
¶
Add an agent to the workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent
|
Agent
|
The agent to add to the workflow. |
required |
add_task(task, output_type)
¶
Add a task to the workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
The task to add to the workflow. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
required |
Source code in python/scouter/llm/_llm.pyi
add_task_output_types(task_output_types)
¶
Add output types for tasks in the workflow. This is primarily used for when loading a workflow as python objects are not serializable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_output_types
|
Dict[str, Any]
|
A dictionary mapping task IDs to their output types.
This can either be a Pydantic |
required |
Source code in python/scouter/llm/_llm.pyi
add_tasks(tasks)
¶
Add multiple tasks to the workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
List[Task]
|
The tasks to add to the workflow. |
required |
execution_plan()
¶
Get the execution plan for the workflow.
Returns:
Type | Description |
---|---|
Dict[str, List[str]]
|
Dict[str, List[str]]: A dictionary where the keys are task IDs and the values are lists of task IDs that the task depends on. |
Source code in python/scouter/llm/_llm.pyi
is_complete()
¶
Check if the workflow is complete.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the workflow is complete, False otherwise. |
model_dump_json()
¶
model_validate_json(json_string, output_types)
staticmethod
¶
Load a workflow from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The JSON string to validate. |
required |
output_types
|
Optional[Dict[str, Any]]
|
A dictionary mapping task IDs to their output types.
This can either be a Pydantic |
required |
Returns:
Name | Type | Description |
---|---|---|
Workflow |
Workflow
|
The workflow object. |
Source code in python/scouter/llm/_llm.pyi
pending_count()
¶
Get the number of pending tasks in the workflow.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The number of pending tasks in the workflow. |
run(global_context=None)
¶
Run the workflow. This will execute all tasks in the workflow and return when all tasks are complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
global_context
|
Optional[Dict[str, Any]]
|
A dictionary of global context to bind to the workflow. All tasks in the workflow will have this context bound to them. |
None
|