class Wco::AiWriter
def self.run_prompt prompt
def self.run_prompt prompt out = HTTParty.post("https://api.openai.com/v1/chat/completions", { headers: { "Content-Type": "application/json", "Authorization": "Bearer #{OPENAI_API_KEY}", }, body: { model: 'gpt-3.5-turbo', messages: [ { role: "system", content: "You are a knowledgable office assistant." }, { role: 'user', content: prompt }, ] }.to_json }) out = JSON.parse out.response.body out.deep_symbolize_keys! puts! out, 'chatgpt response' out = out[:choices][0][:message][:content] return out end