Class: Langsmith::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/langsmith/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data) ⇒ Project

Initialize a new Project instance

Parameters:

  • client (Langsmith::Client)

    The LangSmith client

  • data (Hash)

    Project data from the API



11
12
13
14
15
16
17
18
# File 'lib/langsmith/project.rb', line 11

def initialize(client, data)
  @client = client
  @id = data["id"]
  @name = data["name"]
  @description = data["description"]
  @created_at = data["created_at"] ? Time.parse(data["created_at"]) : nil
  @tenant_id = data["tenant_id"]
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/langsmith/project.rb', line 5

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/langsmith/project.rb', line 5

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/langsmith/project.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/langsmith/project.rb', line 5

def name
  @name
end

#tenant_idObject (readonly)

Returns the value of attribute tenant_id.



5
6
7
# File 'lib/langsmith/project.rb', line 5

def tenant_id
  @tenant_id
end

Instance Method Details

#create_run(name:, run_type:, inputs: {}, extra: {}) ⇒ Langsmith::Run

Create a new run in this project

Parameters:

  • name (String)

    Name of the run

  • run_type (String)

    Type of run (e.g., llm, chain, tool)

  • inputs (Hash) (defaults to: {})

    Input values for the run

  • extra (Hash) (defaults to: {})

    Additional metadata for the run

Returns:



27
28
29
# File 'lib/langsmith/project.rb', line 27

def create_run(name:, run_type:, inputs: {}, extra: {})
  @client.create_run(name: name, run_type: run_type, project_name: @name, inputs: inputs, extra: extra)
end

#list_runs(run_type: nil, limit: 100) ⇒ Array<Langsmith::Run>

List runs in this project

Parameters:

  • run_type (String) (defaults to: nil)

    Filter by run type

  • limit (Integer) (defaults to: 100)

    Maximum number of runs to return

Returns:



36
37
38
# File 'lib/langsmith/project.rb', line 36

def list_runs(run_type: nil, limit: 100)
  @client.list_runs(project_name: @name, run_type: run_type, limit: limit)
end