<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pam</title>
    <description>The latest articles on Forem by Pam (@pamb).</description>
    <link>https://forem.com/pamb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2677395%2F76fa1784-d69b-401f-be6b-b0641768ba59.jpeg</url>
      <title>Forem: Pam</title>
      <link>https://forem.com/pamb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pamb"/>
    <language>en</language>
    <item>
      <title>AI Helps Learning</title>
      <dc:creator>Pam</dc:creator>
      <pubDate>Sun, 26 Jan 2025 20:12:55 +0000</pubDate>
      <link>https://forem.com/pamb/ai-helps-learning-13po</link>
      <guid>https://forem.com/pamb/ai-helps-learning-13po</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://srv.buysellads.com/ads/long/x/T6EK3TDFTTTTTT6WWB6C5TTTTTTGBRAPKATTTTTTWTFVT7YTTTTTTKPPKJFH4LJNPYYNNSZL2QLCE2DPPQVCEI45GHBT" rel="noopener noreferrer"&gt;Agent.ai&lt;/a&gt; Challenge: Assembly of Agents (&lt;a href="https://dev.to/challenges/agentai"&gt;See Details&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AI as an Educational Tool
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I am all about learning and creating roadmaps on how to best learn a topic. I used ruby/rails to implement an ai agent and the &lt;code&gt;ruby-openai&lt;/code&gt; gem to access openAI's API token.  I then created models to represent agents and their interactions as well as creating a controller and service to handle requests and invoke AI agents.&lt;/li&gt;
&lt;li&gt;I used Hotwire, turbo for the frontend.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class AiAgentsController &amp;lt; ApplicationController
  def new
  end

  def invoke_agent
    user_query = params[:query]
    begin
      @ai_response = AiService.invoke_agent(user_query)
      Query.create(user_query: user_query, ai_response: @ai_response)

      respond_to do |format|
        format.turbo_stream
        format.html { redirect_to root_path, notice: "Query processed successfully" }
      end
    rescue StandardError =&amp;gt; e
      error_message = e.message
      Rails.logger.error("AI Agent Error: #{error_message}")

      respond_to do |format|
        format.turbo_stream { 
          render turbo_stream: turbo_stream.update("response_frame", 
            partial: "error", 
            locals: { message: error_message })
        }
        format.html { redirect_to root_path, alert: error_message }
      end
    end
  end

  def index
    @queries = Query.all
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'openai'

class AiService
  class RateLimitError &amp;lt; StandardError; end
  MAX_RETRIES = 3
  BASE_WAIT_TIME = 10  # Increased base wait time

  def self.invoke_agent(query)
    retries = 0
    begin
      client = OpenAI::Client.new(access_token: ENV['OPENAI_API_KEY'])

      response = client.chat(
        parameters: {
          model: "gpt-4o-mini",
          messages: [
            { role: "system", content: "You are a helpful assistant" },
            { role: "user", content: query }
          ],
          max_tokens: 150,
          temperature: 0.7
        }
      )

      response.dig("choices", 0, "message", "content").to_s.strip
    rescue Faraday::TooManyRequestsError =&amp;gt; e
      retries += 1
      if retries &amp;lt;= MAX_RETRIES
        wait_time = BASE_WAIT_TIME * retries  # Linear backoff: 10, 20, 30 seconds
        Rails.logger.warn("Rate limit hit (#{retries}/#{MAX_RETRIES}). Waiting #{wait_time} seconds...")
        sleep(wait_time)
        retry
      else
        Rails.logger.error("Rate limit exceeded. Response: #{e.response&amp;amp;.body}")
        raise RateLimitError, "Please wait a few minutes before trying again"
      end
    rescue StandardError =&amp;gt; e
      Rails.logger.error("OpenAI Error: #{e.class} - #{e.message}")
      raise "API Error: #{e.message}"
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/PamBWillenz/Ai-agent" rel="noopener noreferrer"&gt;https://github.com/PamBWillenz/Ai-agent&lt;/a&gt;&lt;br&gt;
I used ruby/rails to implement an ai agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Home&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewtf7jfkod3ymisk09sp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewtf7jfkod3ymisk09sp.png" alt="Image description" width="800" height="357"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frniu34no7i20qcc0p1gd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frniu34no7i20qcc0p1gd.png" alt="Image description" width="481" height="784"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Query Answers&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvcvkxdrwmphh0r5jmb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvcvkxdrwmphh0r5jmb4.png" alt="Image description" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent.ai Experience
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Not as intuitive as I thought. I used the platform openai.com. I built my ai agent in ruby/rails and the API key was harder to set up then I thought it would be. &lt;/li&gt;
&lt;li&gt;I had to save the key in &lt;code&gt;.env&lt;/code&gt; but initiating it was more complex.&lt;/li&gt;
&lt;li&gt;The instructions were not clear for the language and framework I was using.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Was the builder tool intuitive and easy to use?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Were the instructions and documentation clear?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No, not exactly. The API key that was generated was in a different format and there were no examples for the framework/language I was using. After many attempts I finally used a curl command to get my framework to connect properly to the AI agent. I used a gem (library in rails) to make the AI api connection.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>agentaichallenge</category>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Labels for any occasion</title>
      <dc:creator>Pam</dc:creator>
      <pubDate>Tue, 14 Jan 2025 23:30:36 +0000</pubDate>
      <link>https://forem.com/pamb/labels-for-any-occasion-2ni8</link>
      <guid>https://forem.com/pamb/labels-for-any-occasion-2ni8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/github"&gt;GitHub Copilot Challenge &lt;/a&gt;: New Beginnings&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I built a label maker in ruby/rails to help automate the laborious task of writing names and addresses from a list to envelopes, if you want to do it the old fashion way and not electronically. Like holidays, thank you's, etc...
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Demo -
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;List Home Page&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F09nv4mc9wgj719exga1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F09nv4mc9wgj719exga1z.png" alt="List home page" width="800" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Holiday Contact View&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8s8dbp9t8jd2ll0x1xek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8s8dbp9t8jd2ll0x1xek.png" alt="Holiday contact view" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Labels to Print&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2qj8jajhcidk14rzo9wa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2qj8jajhcidk14rzo9wa.png" alt="Labels downloaded" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My repo -
&lt;/h2&gt;

&lt;h5&gt;
  
  
  &lt;a href="https://github.com/PamBWillenz/Label-Generator" rel="noopener noreferrer"&gt;https://github.com/PamBWillenz/Label-Generator&lt;/a&gt;
&lt;/h5&gt;

&lt;h2&gt;
  
  
  Copilot Experience -
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I used a prompt to get an outline of my project - "I would like to build an app using Ruby, Rails that creates a list of contacts that have names and addresses so I can print labels. Can you give me steps?"&lt;/li&gt;
&lt;li&gt;I then asked copilot to recommend gems to use to print labels.&lt;/li&gt;
&lt;li&gt;I used chat with the file I wanted to edit, then I would incorporate the edits. &lt;/li&gt;
&lt;li&gt;I had an issue with my assets conflicting because I wanted to use bootstrap with simple_form. With Copilot's help I managed to figure out the conflicts and import bootstrap thru node modules vs directly from the gem.&lt;/li&gt;
&lt;li&gt;I used 3 different models.&lt;/li&gt;
&lt;li&gt;I used autocomplete and also used copilot to generate my tests and my seed file. I have used edits, which I love but did not use that today.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  GitHub Models
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I started with Claude 3.5 Sonnet, then went to o1 Preview and used GPT 4o the most. When I continually got the same response or the model said I was out of prompts (o1 preview), I switched models. I especially did this when I was troubleshooting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I feel like New Beginnings mean new ways to approach challenges. My husband and I had a list of more than 200 family and friends that we wanted to send holiday cards, and we had no way to get them in a format to print labels. I wrote all the labels by hand, both for the to: and from:. We can order labels for the from: but you can't do that for the to: so I wanted to automate the process. &lt;/p&gt;

&lt;p&gt;I hope this can help others who want to automate their label list printing and use code to automate the process. &lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>githubchallenge</category>
      <category>webdev</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
