Module: DeepAgents
- Defined in:
- lib/deepagents.rb,
lib/deepagents/graph.rb,
lib/deepagents/state.rb,
lib/deepagents/tools.rb,
lib/deepagents/errors.rb,
lib/deepagents/models.rb,
lib/deepagents/version.rb,
lib/deepagents/sub_agent.rb
Defined Under Namespace
Modules: Graph, Models, StandardTools Classes: CredentialsError, DeepAgentState, Error, FileError, FileNotFoundError, FileSystem, LLMResponseError, MaxIterationsError, ModelError, ReactAgent, StateError, SubAgent, SubAgentError, SubAgentNotFoundError, SubAgentRegistry, Todo, Tool, ToolCallParseError, ToolError, ToolNotFoundError, ToolRegistry
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.claude_model(api_key: nil, model: "claude-3-sonnet-20240229") ⇒ Object
Convenience method to create a Claude model.
-
.create_deep_agent(tools, instructions, model: nil, subagents: nil, state_schema: nil) ⇒ Object
Main entry point to create a deep agent.
-
.openai_model(api_key: nil, model: "gpt-4o") ⇒ Object
Convenience method to create an OpenAI model.
Class Method Details
.claude_model(api_key: nil, model: "claude-3-sonnet-20240229") ⇒ Object
Convenience method to create a Claude model
41 42 43 44 45 46 47 48 49 |
# File 'lib/deepagents.rb', line 41 def self.claude_model(api_key: nil, model: "claude-3-sonnet-20240229") begin Models::Claude.new(api_key: api_key, model: model) rescue LoadError => e raise Error, "Failed to create Claude model: The 'anthropic' gem is not installed. Please run 'gem install anthropic' or add it to your Gemfile." rescue => e raise Error, "Failed to create Claude model: #{e.}" end end |
.create_deep_agent(tools, instructions, model: nil, subagents: nil, state_schema: nil) ⇒ Object
Main entry point to create a deep agent
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/deepagents.rb', line 15 def self.create_deep_agent(tools, instructions, model: nil, subagents: nil, state_schema: nil) begin # Validate inputs raise ArgumentError, "Tools must be an array" unless tools.is_a?(Array) raise ArgumentError, "Instructions cannot be nil or empty" if instructions.nil? || instructions.empty? # If model is a string, try to create an appropriate model adapter if model.is_a?(String) if model.downcase.include?("claude") model = Models::Claude.new(model: model) elsif model.downcase.include?("gpt") || model.downcase.include?("openai") model = Models::OpenAI.new(model: model) else # Default to Claude if we can't determine the model type model = Models::Claude.new(model: model) end end Graph.create_deep_agent(tools, instructions, model: model, subagents: subagents, state_schema: state_schema) rescue => e # Wrap any errors in our own Error class raise Error, "Failed to create deep agent: #{e.}" end end |
.openai_model(api_key: nil, model: "gpt-4o") ⇒ Object
Convenience method to create an OpenAI model
52 53 54 55 56 57 58 59 60 |
# File 'lib/deepagents.rb', line 52 def self.openai_model(api_key: nil, model: "gpt-4o") begin Models::OpenAI.new(api_key: api_key, model: model) rescue LoadError => e raise Error, "Failed to create OpenAI model: The 'openai' gem is not installed. Please run 'gem install openai' or add it to your Gemfile." rescue => e raise Error, "Failed to create OpenAI model: #{e.}" end end |