Skip to content

Commit

Permalink
everything is working now
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Jan 30, 2025
1 parent c0c6a81 commit c6b83b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/ai_bot/personas/persona.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def craft_prompt(context, llm: nil)

prompt.max_pixels = self.class.vision_max_pixels if self.class.vision_enabled
prompt.tools = available_tools.map(&:signature) if available_tools
available_tools.each { |tool| tool.inject_prompt(prompt: prompt, context: context) }
available_tools.each do |tool|
tool.inject_prompt(prompt: prompt, context: context, persona: self)
end
prompt
end

Expand Down
10 changes: 9 additions & 1 deletion lib/ai_bot/tools/create_artifact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def self.signature
}
end

def self.inject_prompt(prompt:, context:)
def self.inject_prompt(prompt:, context:, persona:)
return if persona.options["echo_artifact"] != "true"
# we inject the current artifact content into the last user message
if topic_id = context[:topic_id]
posts = Post.where(topic_id: topic_id)
Expand Down Expand Up @@ -138,6 +139,13 @@ def description_args
def generate_artifact_code(post:, user:)
prompt = build_artifact_prompt(post: post)
response = +""

llm =
(
options[:creator_llm].present? &&
LlmModel.find_by(id: options[:creator_llm].to_i)&.to_llm
) || self.llm

llm.generate(prompt, user: user, feature_name: "create_artifact") do |partial_response|
response << partial_response
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ai_bot/tools/tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def allow_partial_tool_calls?
false
end

def inject_prompt(prompt:, context:)
def inject_prompt(prompt:, context:, persona:)
end
end

Expand Down

0 comments on commit c6b83b2

Please sign in to comment.