14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/activeai/behavior/llm/write_function_call.rb', line 14
def call()
prompt = base_prompt
prompt += "/* #{comment} */\n"
complete_result = complete(prompt)
completion = complete_result['choices'][0]['text']
completion = completion.strip.gsub("\n", "\\n")
matcher = /(.*?)\((.*)\)/m
matches = matcher.match(completion)
if matches.nil?
raise "Unmatched router response in #{self.class}"
end
return {
text: completion.strip,
path: matches[1],
params: matches[2].presence && JSON.parse(matches[2])
}
end
|