Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 4872ba9

Browse files
committed
remove TODO code
1 parent a094bec commit 4872ba9

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

evals/lib/eval.rb

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -241,87 +241,6 @@ def pdf_to_text(llm, path:)
241241
upload.destroy if upload
242242
end
243243

244-
### TODO: SAM this code needs to move into PromptEvaluator in a coherent way in a future PR
245-
def prompt_call(
246-
llm,
247-
system_prompt:,
248-
message:,
249-
temperature: nil,
250-
tools: nil,
251-
stream: false,
252-
output_thinking: false,
253-
followup: nil
254-
)
255-
if tools
256-
tools.each do |tool|
257-
tool.symbolize_keys!
258-
tool[:parameters]&.each(&:symbolize_keys!)
259-
end
260-
end
261-
prompt =
262-
DiscourseAi::Completions::Prompt.new(
263-
system_prompt,
264-
messages: [{ type: :user, content: message }],
265-
)
266-
267-
prompt.tools = tools if tools
268-
269-
result = nil
270-
generate_result =
271-
lambda do
272-
if stream
273-
result = []
274-
llm
275-
.llm_model
276-
.to_llm
277-
.generate(
278-
prompt,
279-
user: Discourse.system_user,
280-
temperature: temperature,
281-
output_thinking: output_thinking,
282-
) { |partial| result << partial }
283-
else
284-
result =
285-
llm.llm_model.to_llm.generate(
286-
prompt,
287-
user: Discourse.system_user,
288-
temperature: temperature,
289-
output_thinking: output_thinking,
290-
)
291-
end
292-
end
293-
294-
generate_result.call
295-
296-
if followup
297-
followup = followup.dup.symbolize_keys!
298-
prompt.tools = followup[:tools] if followup[:tools]
299-
prompt.push_model_response(result)
300-
message = followup[:message].dup
301-
message = message.symbolize_keys!
302-
message[:type] = message[:type].to_sym if message[:type]
303-
%i[id name].each do |key|
304-
if message[key].is_a?(Array)
305-
type, inner_key = message[key]
306-
# this allows us to dynamically set the id or name of the tool call
307-
prev = prompt.messages.reverse.find { |m| m[:type] == type.to_sym }
308-
message[key] = prev[inner_key.to_sym] if prev
309-
end
310-
end
311-
312-
prompt.push(**message)
313-
314-
begin
315-
generate_result.call
316-
rescue => e
317-
# should not happen but it helps debugging...
318-
puts e
319-
result = []
320-
end
321-
end
322-
result
323-
end
324-
325244
def edit_artifact(llm, css_path:, js_path:, html_path:, instructions_path:)
326245
css = File.read(css_path)
327246
js = File.read(js_path)

0 commit comments

Comments
 (0)