Skip to content

Commit

Permalink
Merge pull request #19 from tungnt1203/update_mind
Browse files Browse the repository at this point in the history
Updated mind
  • Loading branch information
tungnt1203 authored Nov 5, 2024
2 parents 1528089 + 86f194a commit 04ba7e6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/minds/minds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Minds
DEFAULT_PROMPT_TEMPLATE = "Use your database tools to answer the user's question: {{question}}"

class Mind
attr_accessor :name, :model_name, :provider, :parameters, :created_at, :updated_at, :datasources
attr_reader :name, :model_name, :provider, :parameters, :created_at, :updated_at, :datasources, :prompt_template

def initialize(client, attributes = {})
@client = client
Expand Down Expand Up @@ -38,14 +38,13 @@ def initialize(client, attributes = {})
# @return [void]
def update(name: nil, model_name: nil, provider: nil, prompt_template: nil, datasources: nil, parameters: nil)
data = {}

ds_names = []
datasources.each do |ds|
ds_name = @client.minds.check_datasource(ds)
ds_names << ds_name
data["datasources"] = ds_names
end if datasources

data["datasources"] = ds_names
data["name"] = name if name
data["model_name"] = model_name if model_name
data["provider"] = provider if provider
Expand All @@ -55,6 +54,16 @@ def update(name: nil, model_name: nil, provider: nil, prompt_template: nil, data
@client.patch(path: "projects/#{@project}/minds/#{@name}", parameters: data)

@name = name if name && name != @name

updated_mind = @client.minds.find(@name)

@model_name = updated_mind.model_name
@datasources = updated_mind.datasources
@parameters = updated_mind.parameters
@prompt_template = updated_mind.prompt_template
@provider = updated_mind.provider
@created_at = updated_mind.created_at
@updated_at = updated_mind.updated_at
end

##
Expand Down

0 comments on commit 04ba7e6

Please sign in to comment.