Skip to content
GitHubLogin

e80_sdk Reference

API reference for the e80_sdk Python package.

Modules:

  • agents – A framework to build agents.
  • eighty80 – The main access point to 8080 features.
  • endpoint – Provides functionality to serve an 8080 Edge app.
  • errors – Exceptions for e80_sdk
  • sandbox – Implementation of sandboxes using 8080 Edge.
  • secrets – Implementation of secrets set on the 8080 platform.

A framework to build agents.

Modules:

  • definitions – Definitions of models and types.
  • harness – Contains the high-level API for running agents.
  • llm – Contains low-level functions that interact with LLMs.
  • toolbox – Register tool implementations.
  • tools – Provided tools for use by the agent framework.

Definitions of models and types.

Modules:

  • base_tool – Interface for defining tool handlers.
  • exceptionse80_sdk Agent exceptions.
  • serve – Models and dataclasses for serving agents on 8080 Edge.
  • state – Defines the state used for agents.
  • stream_events – Events emitted by e80_sdk.agents.harness stream functions
  • usage – Models used for token usage reporting.

Interface for defining tool handlers.

Classes:

e80_sdk.agents.definitions.base_tool.AsyncToolHandler
Section titled “e80_sdk.agents.definitions.base_tool.AsyncToolHandler”

Bases: ToolHandler, ABC

Functions:

  • handle – An async definition of a this tool.
e80_sdk.agents.definitions.base_tool.AsyncToolHandler.handle
Section titled “e80_sdk.agents.definitions.base_tool.AsyncToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult

An async definition of a this tool.

Parameters:

  • id (str) – The tool call ID returned by the LLM. It must be included if you’re returning a Message.
  • state (State) – The current State.
  • agent_params (dict[str, Any]) – The parameters returned by the LLM, as requested by the Agent.
  • handler_params (dict[str, Any] | None) – The parameters manually set when defining this Tool. None if it does not exist.

Returns:

  • ToolResult – You can return a str as the tool response, or a Message (with the tool call ID from id set), or a completely new State. Or, in a tuple with one of the three previous types and a UsageByModel.
e80_sdk.agents.definitions.base_tool.SyncToolHandler
Section titled “e80_sdk.agents.definitions.base_tool.SyncToolHandler”

Bases: ToolHandler, ABC

Implement this to define a sync tool handler.

Functions:

  • handle – Define the implementation of this tool.
e80_sdk.agents.definitions.base_tool.SyncToolHandler.handle
Section titled “e80_sdk.agents.definitions.base_tool.SyncToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult

Define the implementation of this tool.

Parameters:

  • id (str) – The tool call ID returned by the LLM. It must be included if you’re returning a Message.
  • state (State) – The current State.
  • agent_params (dict[str, Any]) – The parameters returned by the LLM, as requested by the Agent.
  • handler_params (dict[str, Any] | None) – The parameters manually set when defining this Tool. None if it does not exist.

Returns:

  • ToolResult – You can return a str as the tool response, or a Message (with the tool call ID from id set), or a completely new State. Or, in a tuple with one of the three previous types and a UsageByModel.
e80_sdk.agents.definitions.base_tool.ToolHandler
Section titled “e80_sdk.agents.definitions.base_tool.ToolHandler”

You should implement a SyncToolHandler or AsyncToolHandler.

Attributes:

  • key (str) – A key that is unique for every instance of Toolbox.
e80_sdk.agents.definitions.base_tool.ToolHandler.key
Section titled “e80_sdk.agents.definitions.base_tool.ToolHandler.key”
key: str

A key that is unique for every instance of Toolbox.

It will be referenced by e80_sdk.agents.definitions.state.AgentTool.handler.

e80_sdk Agent exceptions.

Classes:

e80_sdk.agents.definitions.exceptions.AgentException
Section titled “e80_sdk.agents.definitions.exceptions.AgentException”

Bases: Exception

e80_sdk.agents.definitions.exceptions.AgentFatalException
Section titled “e80_sdk.agents.definitions.exceptions.AgentFatalException”

Bases: Exception

Models and dataclasses for serving agents on 8080 Edge.

Classes:

e80_sdk.agents.definitions.serve.ServeAgent
Section titled “e80_sdk.agents.definitions.serve.ServeAgent”
ServeAgent(agent: Agent, toolbox: Toolbox) -> None

Functions:

Attributes:

e80_sdk.agents.definitions.serve.ServeAgent.agent
Section titled “e80_sdk.agents.definitions.serve.ServeAgent.agent”
agent: Agent
e80_sdk.agents.definitions.serve.ServeAgent.toolbox
Section titled “e80_sdk.agents.definitions.serve.ServeAgent.toolbox”
toolbox: Toolbox
e80_sdk.agents.definitions.serve.StatefulAgentMessage
Section titled “e80_sdk.agents.definitions.serve.StatefulAgentMessage”

Bases: BaseModel

JSON message accepted by the websocket endpoint serving an agent.

Attributes:

e80_sdk.agents.definitions.serve.StatefulAgentMessage.message
Section titled “e80_sdk.agents.definitions.serve.StatefulAgentMessage.message”
message: str
e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage
Section titled “e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage”

Bases: BaseModel

JSON message returned by the websocket endpoint serving an agent.

Attributes:

e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage.response
Section titled “e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage.response”
response: str
e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage.usage
Section titled “e80_sdk.agents.definitions.serve.StatefulAgentResponseMessage.usage”
usage: UsageByModel
e80_sdk.agents.definitions.serve.StatelessAgentRequest
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentRequest”

Bases: BaseModel

JSON Request accepted by the HTTP endpoint serving an agent.

Attributes:

  • message (str) – The message from the user.
  • state (str | None) – The current State as an opaque string.
e80_sdk.agents.definitions.serve.StatelessAgentRequest.message
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentRequest.message”
message: str

The message from the user.

e80_sdk.agents.definitions.serve.StatelessAgentRequest.state
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentRequest.state”
state: str | None = None

The current State as an opaque string.

If this is the first message, send null. In subsequent messages, just pass in the state string returned by the response.

e80_sdk.agents.definitions.serve.StatelessAgentResponse
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentResponse”

Bases: BaseModel

JSON Response returned by the HTTP endpoint serving an agent.

Attributes:

e80_sdk.agents.definitions.serve.StatelessAgentResponse.response
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentResponse.response”
response: str

The response from the LLM.

e80_sdk.agents.definitions.serve.StatelessAgentResponse.state
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentResponse.state”
state: str

The current State as an opaque string.

Pass this as-is to any subsequent requests.

e80_sdk.agents.definitions.serve.StatelessAgentResponse.usage
Section titled “e80_sdk.agents.definitions.serve.StatelessAgentResponse.usage”
usage: UsageByModel

Usage stats from this single turn.

Defines the state used for agents.

Every step of an agent running can be defined as a State mutation.

Classes:

  • Agent – The definition of an Agent.
  • AgentTool – A tool available to an agent.
  • Message – A message in the conversation history.
  • State – The state of the Agent conversation.
  • ToolCalled – A tool called by the LLM in the conversation history.
  • ToolParameter

Bases: BaseModel

The definition of an Agent.

Attributes:

  • instructions (str) – The system instructions for this LLM.
  • model (str) – The model to be used by this LLM.
  • name (str) – The name, which will be passed to the LLM if it supports names.
  • tools (list[AgentTool]) – A list of tools available to this LLM.
e80_sdk.agents.definitions.state.Agent.instructions
Section titled “e80_sdk.agents.definitions.state.Agent.instructions”
instructions: str

The system instructions for this LLM.

e80_sdk.agents.definitions.state.Agent.model
Section titled “e80_sdk.agents.definitions.state.Agent.model”
model: str

The model to be used by this LLM.

e80_sdk.agents.definitions.state.Agent.name
Section titled “e80_sdk.agents.definitions.state.Agent.name”
name: str

The name, which will be passed to the LLM if it supports names.

e80_sdk.agents.definitions.state.Agent.tools
Section titled “e80_sdk.agents.definitions.state.Agent.tools”
tools: list[AgentTool] = []

A list of tools available to this LLM.

All tools should have an implementation in the Toolbox.

e80_sdk.agents.definitions.state.AgentTool
Section titled “e80_sdk.agents.definitions.state.AgentTool”

Bases: BaseModel

A tool available to an agent.

Note that this does not define the implementation of a tool. To define the implementation of the tool, register a ToolHandler to the Toolbox.

Attributes:

  • description (str) – The description passed to the LLM.
  • handler (str) – A reference to the implementation. It MUST correspond to a ToolHandler.key registered with
  • handler_params (dict[str, Any] | None) – Any manually set parameters required by tool handler.
  • name (str) – The name passed to and referenced by the LLM.
  • parameters (list[ToolParameter]) – A list of parameters which the LLM should fill in.
e80_sdk.agents.definitions.state.AgentTool.description
Section titled “e80_sdk.agents.definitions.state.AgentTool.description”
description: str

The description passed to the LLM.

e80_sdk.agents.definitions.state.AgentTool.handler
Section titled “e80_sdk.agents.definitions.state.AgentTool.handler”
handler: str

A reference to the implementation. It MUST correspond to a ToolHandler.key registered with the Toolbox.

e80_sdk.agents.definitions.state.AgentTool.handler_params
Section titled “e80_sdk.agents.definitions.state.AgentTool.handler_params”
handler_params: dict[str, Any] | None

Any manually set parameters required by tool handler.

These are specific to the handler implementation, and are NOT used or touched by the LLM. parameters define parameters which the LLM should fill in, while handler_params are parameters set by you.

e80_sdk.agents.definitions.state.AgentTool.name
Section titled “e80_sdk.agents.definitions.state.AgentTool.name”
name: str

The name passed to and referenced by the LLM.

e80_sdk.agents.definitions.state.AgentTool.parameters
Section titled “e80_sdk.agents.definitions.state.AgentTool.parameters”
parameters: list[ToolParameter]

A list of parameters which the LLM should fill in.

Bases: BaseModel

A message in the conversation history.

Attributes:

e80_sdk.agents.definitions.state.Message.content
Section titled “e80_sdk.agents.definitions.state.Message.content”
content: str | None = None
e80_sdk.agents.definitions.state.Message.name
Section titled “e80_sdk.agents.definitions.state.Message.name”
name: str | None = None
e80_sdk.agents.definitions.state.Message.role
Section titled “e80_sdk.agents.definitions.state.Message.role”
role: Literal['assistant', 'user', 'system', 'tool']
e80_sdk.agents.definitions.state.Message.tool_call_id
Section titled “e80_sdk.agents.definitions.state.Message.tool_call_id”
tool_call_id: str | None = None
e80_sdk.agents.definitions.state.Message.tool_calls
Section titled “e80_sdk.agents.definitions.state.Message.tool_calls”
tool_calls: list[ToolCalled] | None = None

Bases: BaseModel

The state of the Agent conversation.

Mutations to this state, either by the LLM, tools, or users constitutes progress in the conversation.

Attributes:

e80_sdk.agents.definitions.state.State.agent
Section titled “e80_sdk.agents.definitions.state.State.agent”
agent: Agent

The agent currently being talked to.

e80_sdk.agents.definitions.state.State.message_history
Section titled “e80_sdk.agents.definitions.state.State.message_history”
message_history: list[Message] = []

A list of messages. Note this is not append-only.

e80_sdk.agents.definitions.state.ToolCalled
Section titled “e80_sdk.agents.definitions.state.ToolCalled”

Bases: BaseModel

A tool called by the LLM in the conversation history.

Attributes:

e80_sdk.agents.definitions.state.ToolCalled.arguments
Section titled “e80_sdk.agents.definitions.state.ToolCalled.arguments”
arguments: str
e80_sdk.agents.definitions.state.ToolCalled.id
Section titled “e80_sdk.agents.definitions.state.ToolCalled.id”
id: str
e80_sdk.agents.definitions.state.ToolCalled.name
Section titled “e80_sdk.agents.definitions.state.ToolCalled.name”
name: str
e80_sdk.agents.definitions.state.ToolParameter
Section titled “e80_sdk.agents.definitions.state.ToolParameter”

Bases: BaseModel

Attributes:

e80_sdk.agents.definitions.state.ToolParameter.arg_type
Section titled “e80_sdk.agents.definitions.state.ToolParameter.arg_type”
arg_type: ToolParameterArgType
e80_sdk.agents.definitions.state.ToolParameter.description
Section titled “e80_sdk.agents.definitions.state.ToolParameter.description”
description: str | None = None
e80_sdk.agents.definitions.state.ToolParameter.name
Section titled “e80_sdk.agents.definitions.state.ToolParameter.name”
name: str

Events emitted by e80_sdk.agents.harness stream functions

Classes:

e80_sdk.agents.definitions.stream_events.BaseStreamEvent
Section titled “e80_sdk.agents.definitions.stream_events.BaseStreamEvent”

Bases: BaseModel

e80_sdk.agents.definitions.stream_events.LLMDeltaEvent
Section titled “e80_sdk.agents.definitions.stream_events.LLMDeltaEvent”

Bases: BaseStreamEvent

Attributes:

e80_sdk.agents.definitions.stream_events.LLMDeltaEvent.delta
Section titled “e80_sdk.agents.definitions.stream_events.LLMDeltaEvent.delta”
delta: str
e80_sdk.agents.definitions.stream_events.LLMDeltaEvent.event_type
Section titled “e80_sdk.agents.definitions.stream_events.LLMDeltaEvent.event_type”
event_type: Literal['llm_delta'] = 'llm_delta'
e80_sdk.agents.definitions.stream_events.LLMResponseEvent
Section titled “e80_sdk.agents.definitions.stream_events.LLMResponseEvent”

Bases: BaseStreamEvent

Attributes:

e80_sdk.agents.definitions.stream_events.LLMResponseEvent.event_type
Section titled “e80_sdk.agents.definitions.stream_events.LLMResponseEvent.event_type”
event_type: Literal['llm_response'] = 'llm_response'
e80_sdk.agents.definitions.stream_events.LLMResponseEvent.response
Section titled “e80_sdk.agents.definitions.stream_events.LLMResponseEvent.response”
response: str
e80_sdk.agents.definitions.stream_events.ToolResultEvent
Section titled “e80_sdk.agents.definitions.stream_events.ToolResultEvent”

Bases: BaseStreamEvent

Attributes:

e80_sdk.agents.definitions.stream_events.ToolResultEvent.event_type
Section titled “e80_sdk.agents.definitions.stream_events.ToolResultEvent.event_type”
event_type: Literal['tool_result'] = 'tool_result'
e80_sdk.agents.definitions.stream_events.ToolResultEvent.message
Section titled “e80_sdk.agents.definitions.stream_events.ToolResultEvent.message”
message: str | None
e80_sdk.agents.definitions.stream_events.ToolResultEvent.tool_id
Section titled “e80_sdk.agents.definitions.stream_events.ToolResultEvent.tool_id”
tool_id: str
e80_sdk.agents.definitions.stream_events.ToolResultEvent.tool_name
Section titled “e80_sdk.agents.definitions.stream_events.ToolResultEvent.tool_name”
tool_name: str
e80_sdk.agents.definitions.stream_events.ToolsCalledEvent
Section titled “e80_sdk.agents.definitions.stream_events.ToolsCalledEvent”

Bases: BaseStreamEvent

Attributes:

e80_sdk.agents.definitions.stream_events.ToolsCalledEvent.event_type
Section titled “e80_sdk.agents.definitions.stream_events.ToolsCalledEvent.event_type”
event_type: Literal['tools_called'] = 'tools_called'
e80_sdk.agents.definitions.stream_events.ToolsCalledEvent.tools_called
Section titled “e80_sdk.agents.definitions.stream_events.ToolsCalledEvent.tools_called”
tools_called: list[ToolCalled]
e80_sdk.agents.definitions.stream_events.TurnFinishedEvent
Section titled “e80_sdk.agents.definitions.stream_events.TurnFinishedEvent”

Bases: BaseStreamEvent

Attributes:

e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.event_type
Section titled “e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.event_type”
event_type: Literal['turn_finished'] = 'turn_finished'
e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.state
Section titled “e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.state”
state: State
e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.usage
Section titled “e80_sdk.agents.definitions.stream_events.TurnFinishedEvent.usage”
usage: UsageByModel

Models used for token usage reporting.

Classes:

e80_sdk.agents.definitions.usage.ModelUsage
Section titled “e80_sdk.agents.definitions.usage.ModelUsage”

Bases: BaseModel

Attributes:

e80_sdk.agents.definitions.usage.ModelUsage.completion_token_rate
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.completion_token_rate”
completion_token_rate: float | None
e80_sdk.agents.definitions.usage.ModelUsage.completion_tokens
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.completion_tokens”
completion_tokens: int
e80_sdk.agents.definitions.usage.ModelUsage.model_name
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.model_name”
model_name: str
e80_sdk.agents.definitions.usage.ModelUsage.prompt_token_rate
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.prompt_token_rate”
prompt_token_rate: float | None
e80_sdk.agents.definitions.usage.ModelUsage.prompt_tokens
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.prompt_tokens”
prompt_tokens: int
e80_sdk.agents.definitions.usage.ModelUsage.requests
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.requests”
requests: int
e80_sdk.agents.definitions.usage.ModelUsage.total_tokens
Section titled “e80_sdk.agents.definitions.usage.ModelUsage.total_tokens”
total_tokens: int
e80_sdk.agents.definitions.usage.UsageByModel
Section titled “e80_sdk.agents.definitions.usage.UsageByModel”

Bases: BaseModel

Attributes:

e80_sdk.agents.definitions.usage.UsageByModel.model_usages
Section titled “e80_sdk.agents.definitions.usage.UsageByModel.model_usages”
model_usages: list[ModelUsage]

Contains the high-level API for running agents.

Classes:

Functions:

AgentResult(llm_response: Message, state: State, usage: UsageByModel) -> None

Functions:

Attributes:

e80_sdk.agents.harness.AgentResult.llm_response
Section titled “e80_sdk.agents.harness.AgentResult.llm_response”
llm_response: Message
state: State
usage: UsageByModel
merge_tool_results(current_state: State, results: list[tuple[State | Message, UsageByModel]]) -> tuple[State, UsageByModel]
run_agent_async(state: State, toolbox: Toolbox, max_turns: int = 10) -> AgentResult
run_agent_sync(state: State, toolbox: Toolbox, max_turns: int = 10) -> AgentResult
stream_agent_async(state: State, toolbox: Toolbox, llm_delta_events: bool = True, final_message_events: bool = False, tool_call_events: bool = True, max_turns: int = 10) -> AsyncGenerator[BaseStreamEvent]

Contains low-level functions that interact with LLMs.

Classes:

Functions:

LLMResult(message: Message, usage: ModelUsage) -> None

Functions:

Attributes:

message: Message
usage: ModelUsage
llm_async(agent: Agent, messages: list[Message], client: AsyncApi | None = None) -> LLMResult
llm_sync(agent: Agent, messages: list[Message], api: SyncApi | None = None) -> LLMResult
stream_llm_async(agent: Agent, messages: list[Message], client: AsyncApi | None = None) -> AsyncGenerator[LLMResult | str]

Register tool implementations.

Classes:

  • Toolbox – Registers tool implementations, aka their handlers.
Toolbox()

Registers tool implementations, aka their handlers.

Pass an instance of Toolbox into the e80_sdk.agents.harness functions, to run an Agent with tool calls. Default tools already have handlers, so you can simply call Toolbox.get_global_instance() to get an instance.

To use a custom handler, register it with a Toolbox using add_handler or with_local_handlers.

Functions:

Attributes:

e80_sdk.agents.toolbox.Toolbox.add_handler
Section titled “e80_sdk.agents.toolbox.Toolbox.add_handler”
add_handler(handler: ToolHandler)

Add a handler to this instance of Toolbox.

Calling this on the global instance will add a handler to the global instance.

e80_sdk.agents.toolbox.Toolbox.default_instance
Section titled “e80_sdk.agents.toolbox.Toolbox.default_instance”
default_instance: Toolbox | None = None
e80_sdk.agents.toolbox.Toolbox.get_global_instance
Section titled “e80_sdk.agents.toolbox.Toolbox.get_global_instance”
get_global_instance() -> Toolbox
e80_sdk.agents.toolbox.Toolbox.run_toolbox_async
Section titled “e80_sdk.agents.toolbox.Toolbox.run_toolbox_async”
run_toolbox_async(state: State, tool_called: ToolCalled) -> tuple[State | Message, UsageByModel]

See run_toolbox_sync.

You can run both sync and async tool handlers using this method.

e80_sdk.agents.toolbox.Toolbox.run_toolbox_sync
Section titled “e80_sdk.agents.toolbox.Toolbox.run_toolbox_sync”
run_toolbox_sync(state: State, tool_called: ToolCalled) -> tuple[State | Message, UsageByModel]

Manually run tools.

Calling this method is only necessary if you’re using the low-level APIs. If you’re running your agent using functions in e80_sdk.agents.harness, you will not need to call this function.

Note that all the ToolHandler instances must implement e80_sdk.agents.definitions.base_tool.SyncToolHandler.

e80_sdk.agents.toolbox.Toolbox.tool_handlers
Section titled “e80_sdk.agents.toolbox.Toolbox.tool_handlers”
tool_handlers: dict[str, ToolHandler] = {}
e80_sdk.agents.toolbox.Toolbox.with_local_handlers
Section titled “e80_sdk.agents.toolbox.Toolbox.with_local_handlers”
with_local_handlers(*args: ToolHandler)

Returns a new instance of Toolbox with the tool handlers added, without affecting the original instance.

This is effective for ToolHandlers which must be instantiated each time before use.

Provided tools for use by the agent framework.

Modules:

Classes:

e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler
Section titled “e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler”

Bases: SyncToolHandler

Functions:

Attributes:

e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.get_definition
Section titled “e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.get_definition”
get_definition(agent: Agent, delegate_description: str, continue_description: str | None, allow_multiturn: bool = True, allow_multi_instance: bool = False, max_turns: int = 10)
e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.handle
Section titled “e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult
e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.key
Section titled “e80_sdk.agents.tools.delegate_agent.DelegateAgentToolHandler.key”
key: str = '8080.sync.delegate_agent'

Classes:

Functions:

e80_sdk.agents.tools.function.AsyncFunctionToolHandler
Section titled “e80_sdk.agents.tools.function.AsyncFunctionToolHandler”
AsyncFunctionToolHandler(key: str, handler: SupportedFunction[P, Awaitable[FR]])

Bases: AsyncToolHandler

Functions:

Attributes:

e80_sdk.agents.tools.function.AsyncFunctionToolHandler.__call__
Section titled “e80_sdk.agents.tools.function.AsyncFunctionToolHandler.__call__”
__call__(*args, **kwargs)
e80_sdk.agents.tools.function.AsyncFunctionToolHandler.get_definition
Section titled “e80_sdk.agents.tools.function.AsyncFunctionToolHandler.get_definition”
get_definition() -> AgentTool
e80_sdk.agents.tools.function.AsyncFunctionToolHandler.handle
Section titled “e80_sdk.agents.tools.function.AsyncFunctionToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult
e80_sdk.agents.tools.function.AsyncFunctionToolHandler.key
Section titled “e80_sdk.agents.tools.function.AsyncFunctionToolHandler.key”
key = key
e80_sdk.agents.tools.function.SupportedFunction
Section titled “e80_sdk.agents.tools.function.SupportedFunction”

Bases: Protocol

Attributes:

e80_sdk.agents.tools.function.SupportedFunction.__call__
Section titled “e80_sdk.agents.tools.function.SupportedFunction.__call__”
__call__: Callable[P, R]
e80_sdk.agents.tools.function.SupportedFunction.__name__
Section titled “e80_sdk.agents.tools.function.SupportedFunction.__name__”
__name__: str
e80_sdk.agents.tools.function.SyncFunctionToolHandler
Section titled “e80_sdk.agents.tools.function.SyncFunctionToolHandler”
SyncFunctionToolHandler(key: str, handler: SupportedFunction[P, FR])

Bases: SyncToolHandler

Functions:

Attributes:

e80_sdk.agents.tools.function.SyncFunctionToolHandler.__call__
Section titled “e80_sdk.agents.tools.function.SyncFunctionToolHandler.__call__”
__call__(*args, **kwargs)
e80_sdk.agents.tools.function.SyncFunctionToolHandler.get_definition
Section titled “e80_sdk.agents.tools.function.SyncFunctionToolHandler.get_definition”
get_definition() -> AgentTool
e80_sdk.agents.tools.function.SyncFunctionToolHandler.handle
Section titled “e80_sdk.agents.tools.function.SyncFunctionToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult
e80_sdk.agents.tools.function.SyncFunctionToolHandler.key
Section titled “e80_sdk.agents.tools.function.SyncFunctionToolHandler.key”
key = key
e80_sdk.agents.tools.function.function_tool
Section titled “e80_sdk.agents.tools.function.function_tool”
function_tool(*args, **kwargs)

Classes:

e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler”
AsyncSandboxToolHandler(sandbox_client: SandboxClient | None)

Bases: AsyncToolHandler

Functions:

Attributes:

e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_add_javascript_deps_definition
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_add_javascript_deps_definition”
get_add_javascript_deps_definition(*args) -> AgentTool
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_add_python_deps_definition
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_add_python_deps_definition”
get_add_python_deps_definition(*args) -> AgentTool
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_definition_list
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_definition_list”
get_definition_list(*args) -> list[AgentTool]
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_run_javascript_definition
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_run_javascript_definition”
get_run_javascript_definition(*args) -> AgentTool
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_run_python_definition
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.get_run_python_definition”
get_run_python_definition(*args) -> AgentTool
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.handle
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.handle”
handle(id: str, state: State, agent_params: dict[str, Any], handler_params: dict[str, Any] | None) -> ToolResult
e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.key
Section titled “e80_sdk.agents.tools.sandbox.AsyncSandboxToolHandler.key”
key: str = '8080.async.sandbox'

The main access point to 8080 features.

Classes:

  • Eighty80 – The main entrypoint into the 8080 SDK.
Eighty80(*, api_key: str | None = None, env: Environment | None = None)

The main entrypoint into the 8080 SDK.

Call its methods to access different 8080 services.

Functions:

  • init
  • api – Obtain an API object that is relatively similar to the OpenAI SDK.
  • api_async – Obtain an API object that is relatively similar to the OpenAI SDK.
  • close
  • close_async
  • sandbox – Create a new sandbox where you can execute arbitrary Python
api(*, secret_name: str | None = None, base_path: str | None = None, api_key: str | None = None, headers: dict[str, str] | None = None) -> SyncApi

Obtain an API object that is relatively similar to the OpenAI SDK.

from openai import OpenAI
from e80_sdk import Eighty80
old_client = OpenAI(...)
drop_me_in = Eighty80().api()
old_client.chat.completions.create(
model="", messages=[...]
)
old_client.completion.create(
model="", messages=[...]
)

The arguments and output types should similar to the ones outputted by the OpenAI SDK. Most code should just work with minor changes.

You may use the authentication information passed into Eighty80, or you may use alternative authentication information via secrets set on the 8080 platform or manually passed in.

:headers: If base_path and api_key is both set, you may also set headers to pass along additional headers.

Parameters:

  • secret_name (str | None) – Use a URL and API key stored as a secret on the 8080 platform. Note that the secret will be retrieved async when calling this method, so please store the result if you’re using this method.

Authentication information must be set on the Eighty80 instance or else you will receive an error.

  • base_path (str | None) – Use an API pointed at this base_path. You must also set api_key if this is set.
  • api_key (str | None) – Use an API with this api_key. You must also set base_path
api_async(*, secret_name: str | None = None, base_path: str | None = None, api_key: str | None = None, headers: dict[str, str] | None = None) -> AsyncApi

Obtain an API object that is relatively similar to the OpenAI SDK.

from openai import AsyncOpenAI
from e80_sdk import Eighty80
old_client = AsyncOpenAI(...)
drop_me_in = Eighty80().api_async()
await old_client.chat.completions.create(
model="", messages=[...]
)
await old_client.completion.create(
model="", messages=[...]
)

For more information about parameters, please see the synchronous version api.

close() -> None
close_async() -> None
sandbox() -> AsyncIterator[SandboxClient]

Create a new sandbox where you can execute arbitrary Python and Javascript code.

Use this as an async context manager so the sandbox will get cleaned up automatically.

from e80_sdk import Eighty80
async with Eighty80.sandbox() as sandbox_client:
sandbox_client.run_python("print('hello world')")
sandbox_client.install_python_dependencies(["requests"])

Provides functionality to serve an 8080 Edge app.

Classes:

Functions:

Attributes:

Eighty80App()

Bases: FastAPI

Functions:

  • init
  • serve_agent – Decorator to serve an agent defined by the e80_sdk.agents framework.
serve_agent(endpoint_base: str | None = None, stateless_endpoint: str | None = None, websocket_endpoint: str | None = None, stateless_streaming_endpoint: str | None = None, websocket_streaming_endpoint: str | None = None) -> Callable[[ServeAgentEndpoint], None]

Decorator to serve an agent defined by the e80_sdk.agents framework.

The simplest way to use this decorator is to define a function returning an e80_sdk.agents.definitions.state.Agent. If you want a custom Toolbox use e80_sdk.agents.definitions.serve.AgentResult.

Agents using tools that require cleanup after the conversation can use a middleware pattern by accepting a “next” argument in their decorated function. Pass the Agent definition to next instead of returning it, and return the result of next. An example:

from e80_sdk import eighty80_app
from e80_sdk.agents.definitions.serve import AgentResult
from e80_sdk.agents.definitions.state import Agent
from e80_sdk.agents.toolbox import Toolbox
app = eighty80_app()
@app.serve_agent()
def agent_endpoint(next):
# Do any setup here...
resp = next(
AgentResult(
agent=Agent(...),
toolbox=Toolbox(...)
)
)
# Do any cleanup here.
return resp
eighty80_app() -> Eighty80App

Serve an 8080 edge app.

app = eighty80_app()
@app.get("/example")
def example():
return { "message": "Hello world" }
handler = LoggingHandler(level=(logging.INFO), logger_provider=logger_provider)
log_exporter = OTLPLogExporter(endpoint=f'{_otel_collector_url}/v1/logs')
logger_provider = LoggerProvider(resource=resource)
meter_provider = MeterProvider(resource=resource, metric_readers=([PeriodicExportingMetricReader(OTLPMetricExporter(endpoint=f'{_otel_collector_url}/v1/metrics'))] if _otel_collector_url else []))
project_slug = os.environ['8080_PROJECT_SLUG']
resource = Resource.create(attributes={SERVICE_NAME: project_slug})
stream_handler = logging.StreamHandler()
tracer_provider = TracerProvider(resource=resource)

Exceptions for e80_sdk

Classes:

Bases: Exception

Bases: Exception

Implementation of sandboxes using 8080 Edge.

Classes:

RunCodeResult(is_successful: bool, result: str, error: str) -> None

Functions:

Attributes:

error: str

e80_sdk.sandbox.RunCodeResult.is_successful

Section titled “e80_sdk.sandbox.RunCodeResult.is_successful”
is_successful: bool
result: str
SandboxClient(auth_token: str, base_url: str)

Functions:

Attributes:

destroy()

e80_sdk.sandbox.SandboxClient.install_javascript_dependency

Section titled “e80_sdk.sandbox.SandboxClient.install_javascript_dependency”
install_javascript_dependency(deps: list[str])

e80_sdk.sandbox.SandboxClient.install_python_dependencies

Section titled “e80_sdk.sandbox.SandboxClient.install_python_dependencies”
install_python_dependencies(deps: list[str])

e80_sdk.sandbox.SandboxClient.run_javascript

Section titled “e80_sdk.sandbox.SandboxClient.run_javascript”
run_javascript(code: str) -> RunCodeResult
run_python(code: str) -> RunCodeResult
session = httpx.Client(headers={'Authorization': f'Bearer {self._auth_token}', 'Content-Type': 'application/json'})

e80_sdk.sandbox.SandboxClient.wait_until_ready

Section titled “e80_sdk.sandbox.SandboxClient.wait_until_ready”
wait_until_ready()

Implementation of secrets set on the 8080 platform.

Classes:

Bases: BaseModel

Attributes:

api_key: str
url: str

Bases: BaseModel

Attributes:

name: str
type: str
value: str | dict
Secrets(*, secrets_file: str | None = None, secrets_json: str | None = None)

Access secrets set on the 8080 platform in your code.

You should not need to manually ingest any secrets. Calling the get_* methods should just work. To use secrets when developing locally with e80 dev, please make sure the option to expose the secret locally is checked on the platform.

Functions:

get_json_secret(key: str) -> Any

Access and parse a JSON secret.

After parsing as JSON, no type checking or coercion occurs. The format will be whatever you set in the 8080 platform.

Throws an exception if:

  • Secret key does not exist
  • Secret key has a different type
  • Secret key is not exposed for the environment
    • Please make sure to expose the secret for local development
get_openai_secret(key: str) -> OpenAISecret

Access and parse an OpenAI secret.

Throws an exception if:

  • This secret with key key does not exist
  • This secret with key key is not exposed for the environment
    • Please make sure to expose the secret for local development

The return value is strongly typed. See the example below. Example:

from e80_sdk import Eighty80
# Set in the 8080 platform
foo = Eighty80.secrets().get_openai_secret('foo')
print(foo.url) # The URL as a string
print(foo.api_key) # The API key as a string

Note that you don’t need to create an OpenAI SDK client manually. You can directly get an OpenAI SDK like such:

from e80_sdk import Eighty80
# Assumes you set an OpenAI secret named 'foo' in the 8080 platform.
sdk = Eighty80.completion_sdk('foo')
async_sdk = Eighty80.async_completion_sdk('foo') # Async client
get_string_secret(key: str) -> str

Access a string secret, and returns the string.

Throws an exception if:

  • Secret key does not exist
  • Secret key has a different type
  • Secret key is not exposed for the environment
    • Please make sure to expose the secret for local development