gpt_engineer.core.ai.ClipboardAI
- class gpt_engineer.core.ai.ClipboardAI(**_)[source]
Bases:
AIInitialize the AI class.
- Parameters:
model_name (str, optional) – The name of the model to use, by default “gpt-4”.
temperature (float, optional) – The temperature to use for the model, by default 0.1.
- backoff_inference(messages)
Perform inference using the language model while implementing an exponential backoff strategy.
This function will retry the inference in case of a rate limit error from the OpenAI API. It uses an exponential backoff strategy, meaning the wait time between retries increases exponentially. The function will attempt to retry up to 7 times within a span of 45 seconds.
- Parameters:
messages (List[Message]) – A list of chat messages which will be passed to the language model for processing.
callbacks (List[Callable]) – A list of callback functions that are triggered after each inference. These functions can be used for logging, monitoring, or other auxiliary tasks.
- Returns:
The output from the language model after processing the provided messages.
- Return type:
Any
- Raises:
openai.error.RateLimitError – If the number of retries exceeds the maximum or if the rate limit persists beyond the allotted time, the function will ultimately raise a RateLimitError.
Example
>>> messages = [SystemMessage(content="Hello"), HumanMessage(content="How's the weather?")] >>> response = backoff_inference(messages)
- static deserialize_messages(jsondictstr: str) List[AIMessage | HumanMessage | SystemMessage]
Deserialize a JSON string to a list of messages.
- Parameters:
jsondictstr (str) – The JSON string to deserialize.
- Returns:
The deserialized list of messages.
- Return type:
List[Message]
- next(messages: List[AIMessage | HumanMessage | SystemMessage], prompt: str | None = None, *, step_name: str) List[AIMessage | HumanMessage | SystemMessage][source]
Not yet fully supported
- static serialize_messages(messages: List[AIMessage | HumanMessage | SystemMessage]) str[source]
Serialize a list of messages to a JSON string.
- Parameters:
messages (List[Message]) – The list of messages to serialize.
- Returns:
The serialized messages as a JSON string.
- Return type:
str
- start(system: str, user: Any, *, step_name: str) List[AIMessage | HumanMessage | SystemMessage]
Start the conversation with a system message and a user message.
- Parameters:
system (str) – The content of the system message.
user (str) – The content of the user message.
step_name (str) – The name of the step.
- Returns:
The list of messages in the conversation.
- Return type:
List[Message]