Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated mind #19

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/minds/minds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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 @@ -35,14 +35,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 @@ -52,6 +51,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

# Add a datasource to the mind
Expand Down