forked from humanloop/humanloop-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent_kernel_request.py
More file actions
123 lines (97 loc) · 5.09 KB
/
agent_kernel_request.py
File metadata and controls
123 lines (97 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
# This file was auto-generated by Fern from our API Definition.
import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .agent_kernel_request_reasoning_effort import AgentKernelRequestReasoningEffort
from .agent_kernel_request_stop import AgentKernelRequestStop
from .agent_kernel_request_template import AgentKernelRequestTemplate
from .agent_kernel_request_tools_item import AgentKernelRequestToolsItem
from .model_endpoints import ModelEndpoints
from .model_providers import ModelProviders
from .response_format import ResponseFormat
from .template_language import TemplateLanguage
class AgentKernelRequest(UncheckedBaseModel):
"""
Base class used by both PromptKernelRequest and AgentKernelRequest.
Contains the consistent Prompt-related fields.
"""
model: str = pydantic.Field()
"""
The model instance used, e.g. `gpt-4`. See [supported models](https://humanloop.com/docs/reference/supported-models)
"""
endpoint: typing.Optional[ModelEndpoints] = pydantic.Field(default=None)
"""
The provider model endpoint used.
"""
template: typing.Optional[AgentKernelRequestTemplate] = pydantic.Field(default=None)
"""
The template contains the main structure and instructions for the model, including input variables for dynamic values.
For chat models, provide the template as a ChatTemplate (a list of messages), e.g. a system message, followed by a user message with an input variable.
For completion models, provide a prompt template as a string.
Input variables should be specified with double curly bracket syntax: `{{input_name}}`.
"""
template_language: typing.Optional[TemplateLanguage] = pydantic.Field(default=None)
"""
The template language to use for rendering the template.
"""
provider: typing.Optional[ModelProviders] = pydantic.Field(default=None)
"""
The company providing the underlying model service.
"""
max_tokens: typing.Optional[int] = pydantic.Field(default=None)
"""
The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt
"""
temperature: typing.Optional[float] = pydantic.Field(default=None)
"""
What sampling temperature to use when making a generation. Higher values means the model will be more creative.
"""
top_p: typing.Optional[float] = pydantic.Field(default=None)
"""
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
"""
stop: typing.Optional[AgentKernelRequestStop] = pydantic.Field(default=None)
"""
The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.
"""
presence_penalty: typing.Optional[float] = pydantic.Field(default=None)
"""
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.
"""
frequency_penalty: typing.Optional[float] = pydantic.Field(default=None)
"""
Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.
"""
other: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Other parameter values to be passed to the provider call.
"""
seed: typing.Optional[int] = pydantic.Field(default=None)
"""
If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
"""
response_format: typing.Optional[ResponseFormat] = pydantic.Field(default=None)
"""
The format of the response. Only `{"type": "json_object"}` is currently supported for chat.
"""
reasoning_effort: typing.Optional[AgentKernelRequestReasoningEffort] = pydantic.Field(default=None)
"""
Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.
"""
tools: typing.Optional[typing.List[AgentKernelRequestToolsItem]] = None
attributes: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Additional fields to describe the Prompt. Helpful to separate Prompt versions from each other with details on how they were created or used.
"""
max_iterations: typing.Optional[int] = pydantic.Field(default=None)
"""
The maximum number of iterations the Agent can run. This is used to limit the number of times the Agent model is called.
"""
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:
class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow