Class: Leash::Integration::MemoryClient

Inherits:
Object
  • Object
show all
Defined in:
lib/leash/integration/memory.rb

Instance Method Summary collapse

Constructor Details

#initialize(leash) ⇒ MemoryClient

Create a new Memory integration client.

Parameters:

  • leash (Leash::Client)

    the Leash SDK client



11
12
13
# File 'lib/leash/integration/memory.rb', line 11

def initialize(leash)
  @leash = leash
end

Instance Method Details

#add_observations(observations) ⇒ Object

Add new observations to existing entities in the knowledge graph

Parameters:

  • observations (Array)

Returns:

  • (Object)


41
42
43
44
45
46
# File 'lib/leash/integration/memory.rb', line 41

def add_observations(observations)
  params = {
    'observations' => observations
  }.compact
  @leash.call('memory', 'add_observations', params)
end

#create_entities(entities) ⇒ Object

Create multiple new entities in the knowledge graph

Parameters:

  • entities (Array)

Returns:

  • (Object)


19
20
21
22
23
24
# File 'lib/leash/integration/memory.rb', line 19

def create_entities(entities)
  params = {
    'entities' => entities
  }.compact
  @leash.call('memory', 'create_entities', params)
end

#create_relations(relations) ⇒ Object

Create multiple new relations between entities in the knowledge graph. Relations should be in active voice

Parameters:

  • relations (Array)

Returns:

  • (Object)


30
31
32
33
34
35
# File 'lib/leash/integration/memory.rb', line 30

def create_relations(relations)
  params = {
    'relations' => relations
  }.compact
  @leash.call('memory', 'create_relations', params)
end

#delete_entities(entitynames) ⇒ Object

Delete multiple entities and their associated relations from the knowledge graph

Parameters:

  • entitynames (Array)

    An array of entity names to delete

Returns:

  • (Object)


52
53
54
55
56
57
# File 'lib/leash/integration/memory.rb', line 52

def delete_entities(entitynames)
  params = {
    'entityNames' => entitynames
  }.compact
  @leash.call('memory', 'delete_entities', params)
end

#delete_observations(deletions) ⇒ Object

Delete specific observations from entities in the knowledge graph

Parameters:

  • deletions (Array)

Returns:

  • (Object)


63
64
65
66
67
68
# File 'lib/leash/integration/memory.rb', line 63

def delete_observations(deletions)
  params = {
    'deletions' => deletions
  }.compact
  @leash.call('memory', 'delete_observations', params)
end

#delete_relations(relations) ⇒ Object

Delete multiple relations from the knowledge graph

Parameters:

  • relations (Array)

    An array of relations to delete

Returns:

  • (Object)


74
75
76
77
78
79
# File 'lib/leash/integration/memory.rb', line 74

def delete_relations(relations)
  params = {
    'relations' => relations
  }.compact
  @leash.call('memory', 'delete_relations', params)
end

#open_nodes(names) ⇒ Object

Open specific nodes in the knowledge graph by their names

Parameters:

  • names (Array)

    An array of entity names to retrieve

Returns:

  • (Object)


104
105
106
107
108
109
# File 'lib/leash/integration/memory.rb', line 104

def open_nodes(names)
  params = {
    'names' => names
  }.compact
  @leash.call('memory', 'open_nodes', params)
end

#read_graphObject

Read the entire knowledge graph

Returns:

  • (Object)


84
85
86
87
# File 'lib/leash/integration/memory.rb', line 84

def read_graph
  params = {}
  @leash.call('memory', 'read_graph', params)
end

#search_nodes(query) ⇒ Object

Search for nodes in the knowledge graph based on a query

Parameters:

  • query (String)

    The search query to match against entity names, types, and observation content

Returns:

  • (Object)


93
94
95
96
97
98
# File 'lib/leash/integration/memory.rb', line 93

def search_nodes(query)
  params = {
    'query' => query
  }.compact
  @leash.call('memory', 'search_nodes', params)
end