<?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>DEV Community: Francis Oyakhire</title>
    <description>The latest articles on DEV Community by Francis Oyakhire (@apexgridtech).</description>
    <link>https://dev.to/apexgridtech</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4044028%2F5a1615d4-3ad0-4b6e-b6ea-0cded6818546.png</url>
      <title>DEV Community: Francis Oyakhire</title>
      <link>https://dev.to/apexgridtech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/apexgridtech"/>
    <language>en</language>
    <item>
      <title>Ollama v1 OpenAI Compat Drops Think Toggle</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Tue, 01 Dec 2026 15:00:15 +0000</pubDate>
      <link>https://dev.to/apexgridtech/ollama-v1-openai-compat-drops-think-toggle-3om0</link>
      <guid>https://dev.to/apexgridtech/ollama-v1-openai-compat-drops-think-toggle-3om0</guid>
      <description>&lt;p&gt;This week, the AI world buzzed with Decrypt’s deep dive into Alibaba’s Qwen model family, sparking renewed interest in how large language models are being deployed across different ecosystems. While the article highlights the versatility of Qwen, it didn’t mention a subtle but critical issue we recently encountered while working with Ollama’s OpenAI-compatible endpoint. Let’s walk through how we uncovered and resolved this problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: A Silent Toggle Drop
&lt;/h2&gt;

&lt;p&gt;We were experimenting with the Qwen3 model via Ollama’s &lt;code&gt;/v1&lt;/code&gt; endpoint, which is designed to be compatible with OpenAI’s API. Our goal was to test the model’s behavior under various conditions, including a simple &lt;code&gt;think: false&lt;/code&gt; toggle to bypass internal reasoning and get a direct response. However, we noticed a strange behavior: the model would consume its entire &lt;code&gt;num_predict&lt;/code&gt; budget on internal reasoning and return empty content, despite the &lt;code&gt;think: false&lt;/code&gt; flag being set.&lt;/p&gt;

&lt;p&gt;This led us to investigate further. We started by comparing the payloads sent to the &lt;code&gt;/v1&lt;/code&gt; endpoint versus the native &lt;code&gt;/api/chat&lt;/code&gt; endpoint. The &lt;code&gt;/v1&lt;/code&gt; endpoint is designed to mimic OpenAI’s API, but it appears to silently ignore certain parameters, including the &lt;code&gt;think&lt;/code&gt; flag for models in the Qwen3 family.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix: Switching to Native Endpoint
&lt;/h2&gt;

&lt;p&gt;After isolating the issue, we decided to test the same prompt using the native &lt;code&gt;/api/chat&lt;/code&gt; endpoint. The difference was immediate and significant. Not only did the model respect the &lt;code&gt;think: false&lt;/code&gt; toggle, but it also returned the expected output without exhausting the token budget. This confirmed that the issue was specific to the &lt;code&gt;/v1&lt;/code&gt; endpoint’s handling of the &lt;code&gt;think&lt;/code&gt; parameter for Qwen3 models.&lt;/p&gt;

&lt;p&gt;Here’s a comparison of the payloads sent to both endpoints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="n"&gt;Payload&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt; &lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="n"&gt;OpenAI&lt;/span&gt;&lt;span class="err"&gt;-&lt;/span&gt;&lt;span class="n"&gt;compat&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"qwen3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"What is the capital of France?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"think"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"num_predict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="n"&gt;Payload&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt; &lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="n"&gt;native&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"qwen3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"What is the capital of France?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"think"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"num_predict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, the payloads look identical. But the key difference lies in how the &lt;code&gt;think&lt;/code&gt; parameter is interpreted by each endpoint. The &lt;code&gt;/v1&lt;/code&gt; endpoint appears to be misinterpreting or ignoring this parameter for Qwen3 models, leading to unexpected behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tradeoffs and Considerations
&lt;/h2&gt;

&lt;p&gt;Switching to the native &lt;code&gt;/api/chat&lt;/code&gt; endpoint resolved the immediate issue, but it comes with its own tradeoffs. The &lt;code&gt;/v1&lt;/code&gt; endpoint offers a familiar interface for developers used to OpenAI’s API, which can be a significant advantage in terms of integration and tooling. However, it may not support all features or parameters consistently across different model families, as we’ve seen with Qwen3.&lt;/p&gt;

&lt;p&gt;On the other hand, the &lt;code&gt;/api/chat&lt;/code&gt; endpoint provides more direct control over the model’s behavior but requires developers to adapt to a different API structure. This can be a hurdle for teams that are heavily invested in OpenAI-compatible tooling.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s Next
&lt;/h2&gt;

&lt;p&gt;We’re currently working on a wrapper that abstracts these differences, allowing developers to use a unified interface regardless of the backend. This will help mitigate the pain points of switching between endpoints while ensuring consistent behavior across model families. We’re also in touch with the Ollama team to see if there’s a plan to address this discrepancy in future releases.&lt;/p&gt;

&lt;p&gt;Have you encountered similar issues when working with OpenAI-compatible endpoints? We’d love to hear about your experiences and how you’ve navigated these challenges.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>ollama</category>
      <category>debugging</category>
      <category>python</category>
    </item>
    <item>
      <title>Postiz Self Host Bluesky Python Client</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Wed, 25 Nov 2026 15:00:16 +0000</pubDate>
      <link>https://dev.to/apexgridtech/postiz-self-host-bluesky-python-client-542b</link>
      <guid>https://dev.to/apexgridtech/postiz-self-host-bluesky-python-client-542b</guid>
      <description>&lt;p&gt;This week's news about supply chain vulnerabilities in Microsoft's Agent Framework has sparked renewed interest in secure, self-hosted alternatives for critical infrastructure. As we explore the importance of control and transparency in our tech stack, we're also looking at how to build resilient, self-hosted solutions like Postiz, a self-hosted Bluesky-compatible social platform.&lt;/p&gt;

&lt;p&gt;We've been experimenting with self-hosting Postiz using Docker Compose and driving it from a Python client. This setup allows us to manage our own data, avoid third-party dependencies, and ensure compliance with internal security policies. The Python client communicates with Postiz's API endpoint at &lt;code&gt;/api/public/v1/posts&lt;/code&gt;, which is central to our implementation.&lt;/p&gt;

&lt;p&gt;Our Docker Compose setup includes Postiz, a PostgreSQL database, and a reverse proxy. We use Docker Compose to manage the services, ensuring that all components are version-controlled and easily reproducible. Here's a simplified version of our &lt;code&gt;docker-compose.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.8'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postiz&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz/postiz:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"8080:8080"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DB_HOST&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DB_PORT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5432&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DB_NAME&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DB_USER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DB_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
  &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:14&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres_data:/var/lib/postgresql/data&lt;/span&gt;
  &lt;span class="na"&gt;nginx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"80:80"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./nginx.conf:/etc/nginx/nginx.conf&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres_data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration ensures that all services are running in isolated containers, with clear separation between the application, database, and network layers. The Nginx reverse proxy helps manage incoming traffic and secure the API endpoints.&lt;/p&gt;

&lt;p&gt;When it comes to the Python client, we've implemented a simple HTTP client that sends JSON payloads to the &lt;code&gt;/api/public/v1/posts&lt;/code&gt; endpoint. The client handles authentication via a Bearer token in the Authorization header. Here's a sample of the JSON payload we use for creating a post:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"This is a sample post from our Python client."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"visibility"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"public"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Authorization&lt;/code&gt; header is set as &lt;code&gt;Bearer &amp;lt;token&amp;gt;&lt;/code&gt;, where &lt;code&gt;&amp;lt;token&amp;gt;&lt;/code&gt; is a valid JWT token issued by Postiz's authentication service. On successful requests, Postiz may return either a single object or a list of objects, depending on the context. To handle this, our client checks the response type and processes it accordingly. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:8080/api/public/v1/posts"&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {token}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"visibility"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"public"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach ensures that our client can gracefully handle both response formats and extract the relevant data. We've also implemented retries and error handling to deal with transient failures and unexpected responses.&lt;/p&gt;

&lt;p&gt;One of the key tradeoffs we've made is the complexity of managing the Docker Compose setup and ensuring that all components are correctly configured. While this gives us full control, it also increases the maintenance burden. Additionally, the Python client requires careful handling of authentication and response parsing, which adds to the development time.&lt;/p&gt;

&lt;p&gt;Looking ahead, we're exploring ways to automate the deployment of Postiz and reduce the manual configuration required. We're also looking into integrating more advanced features like media uploads and real-time notifications. What are your thoughts on self-hosted alternatives for social platforms like Bluesky? How do you balance control with complexity in your infrastructure choices?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>python</category>
      <category>socialmedia</category>
      <category>docker</category>
    </item>
    <item>
      <title>Cron Scheduled Ollama Autonomous Agent</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Sun, 22 Nov 2026 15:00:13 +0000</pubDate>
      <link>https://dev.to/apexgridtech/cron-scheduled-ollama-autonomous-agent-1148</link>
      <guid>https://dev.to/apexgridtech/cron-scheduled-ollama-autonomous-agent-1148</guid>
      <description>&lt;p&gt;This week, OVHcloud's announcement of an open-source AI model family has reignited discussions around the accessibility and modularity of AI infrastructure. While the focus was on model training and deployment, we're intrigued by the opportunities these tools create for autonomous agents running on the edge. Here’s how we built one  -  a cron-scheduled Ollama-based social agent that runs on a modest Linux server and interacts with the world through voice, text, and data.&lt;/p&gt;

&lt;p&gt;At Apex Grid, we've been experimenting with autonomous agents that can operate semi-independently, reacting to data and events without constant human oversight. Our current project is a social agent that generates content, checks for controversy, verifies credit, and only publishes if all conditions are met. The agent runs on a cron job, pulling data from various sources, processing it with Ollama models, and then deciding whether to publish.&lt;/p&gt;

&lt;p&gt;The agent's workflow is split into several stages. First, it generates a voice profile for the agent, which is stored as a separate file. This allows for easy updates without retraining the entire model. Next, it runs the content through a "controversy gate"  -  a second Ollama model that checks for potentially harmful or controversial content. If the model flags anything, the content is moved to a quarantine folder for review.&lt;/p&gt;

&lt;p&gt;Before final publication, the agent also checks a "credit gate"  -  a PostgreSQL probe that queries a Postiz DB to ensure the content doesn't violate any licensing or attribution rules. Only if both gates are passed does the content proceed to the final stage: publishing to all channels.&lt;/p&gt;

&lt;p&gt;Here's a simplified version of the &lt;code&gt;publish_to_all_channels&lt;/code&gt; function, which orchestrates the flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;publish_to_all_channels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;voice_profile&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;controversy_gate_model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;credit_gate_model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Step 1: Apply voice profile to content&lt;/span&gt;
    &lt;span class="n"&gt;processed_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;apply_voice_profile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;voice_profile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 2: Run through controversy gate&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;controversy_gate_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processed_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processed_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"controversy_flagged"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 3: Check credit gate&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;credit_gate_model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;processed_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processed_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credit_violation"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 4: Publish to all channels&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;channel&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;get_active_channels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;publish_to_channel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;processed_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function exemplifies our approach to gate order and separation of concerns. By isolating the voice profile, controversy check, and credit verification into distinct steps, we ensure that each component can be updated or replaced independently without affecting the overall system.&lt;/p&gt;

&lt;p&gt;We’ve made tradeoffs along the way. For instance, using cron to schedule the agent means we can’t react to real-time events  -  but our use case doesn’t require that level of responsiveness. Also, storing voice profiles as separate files adds some overhead in management but simplifies deployment and updates.&lt;/p&gt;

&lt;p&gt;Looking ahead, we’re exploring ways to integrate more lightweight event-driven triggers alongside our cron jobs. We're also investigating how to train the controversy gate model on more diverse datasets to reduce false positives. What do you think about the tradeoff between real-time reactivity and the reliability of cron-based scheduling in autonomous agents?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Publishing Pipeline Scheduled vs Immediate</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Mon, 16 Nov 2026 15:00:13 +0000</pubDate>
      <link>https://dev.to/apexgridtech/publishing-pipeline-scheduled-vs-immediate-37hn</link>
      <guid>https://dev.to/apexgridtech/publishing-pipeline-scheduled-vs-immediate-37hn</guid>
      <description>&lt;p&gt;This week’s news about AI model inference and deployment strategies has sparked a broader conversation about control, cost, and complexity in modern software stacks. As we look at the tradeoffs between scheduled and immediate publishing pipelines, we find a similar tension: when do we let the system decide, and when do we take the wheel? At Apex Grid, we’ve built a hybrid approach that balances the need for timely content delivery with the flexibility of scheduling  -  and it’s not without its challenges.&lt;/p&gt;

&lt;p&gt;We run a platform that handles both immediate publishing  -  like real-time analytics dashboards  -  and scheduled content  -  such as social media posts and long-form articles. For the latter, we needed a way to publish content at a specific time, but also ensure that the content remains consistent across all platforms. That’s where the canonical URL problem comes in.&lt;/p&gt;

&lt;p&gt;When a post is scheduled, it’s stored in a draft state, and only published when the cron job fires. However, if a user shares a preview link to the draft before it’s published, that link becomes invalid once the post goes live. This creates a mismatch between the canonical URL (which is the final, published version) and the URL used in the preview. To solve this, we implemented a redirect system that maps draft URLs to their published counterparts once the post is live.&lt;/p&gt;

&lt;p&gt;Here’s a simplified version of how we handle the redirect in our backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# In-memory mapping of draft URLs to published URLs&lt;/span&gt;
&lt;span class="n"&gt;draft_to_published&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"/drafts/2026-04-05-hello-world"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/posts/2026-04-05-hello-world"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# ... more mappings&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;before_request&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_redirects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;draft_to_published&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;draft_to_published&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach works well for small-scale use cases, but it has limitations. The in-memory mapping is not scalable and doesn’t handle edge cases like deleted posts or posts that are moved. To address this, we’re moving toward a more robust solution that uses a database to store and manage the canonical URL mappings. This will allow us to query and update mappings dynamically, and also add features like soft-deletes and versioning.&lt;/p&gt;

&lt;p&gt;The tradeoffs are clear. Using a database adds complexity and latency, but it also provides consistency and reliability. We’ve found that the benefits of a centralized, scalable system outweigh the costs, especially as our platform grows and the number of scheduled posts increases.&lt;/p&gt;

&lt;p&gt;Looking ahead, we’re exploring ways to automate the canonical URL mapping process. One idea is to generate the canonical URL based on the post’s metadata, such as the title and publication date. This would reduce the need for manual mappings and make the system more self-sufficient. We’re also considering integrating with reverse proxies to handle redirects at the network level, which could improve performance and reduce the load on our application servers.&lt;/p&gt;

&lt;p&gt;What do you think about the tradeoffs between manual and automated canonical URL mapping? And how would you handle the problem if you were building a hybrid publishing pipeline for a global audience?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>socialmedia</category>
      <category>python</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Controversy Gate Second Model Check</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Sat, 07 Nov 2026 15:00:15 +0000</pubDate>
      <link>https://dev.to/apexgridtech/controversy-gate-second-model-check-40hg</link>
      <guid>https://dev.to/apexgridtech/controversy-gate-second-model-check-40hg</guid>
      <description>&lt;p&gt;This week’s news about AI model deployment and governance has sparked renewed interest in the challenges of building reliable autonomous systems. As the conversation around model safety and reliability continues to evolve, one pattern has emerged as a promising approach to mitigate the risk of embarrassing or harmful content being auto-published: using two models in a pipeline  -  one for drafting, another for scoring.&lt;/p&gt;

&lt;p&gt;At Apex Grid Technologies, we've been working on systems that autonomously generate and publish social content  -  think of it as AI-powered social media management, but with a strong emphasis on safety and governance. The core idea is simple: draft with a primary model, then score the output using a second, specialized model that evaluates for controversy or risk before deciding whether to publish.&lt;/p&gt;

&lt;p&gt;The problem is clear. When you rely on a single model for both generation and evaluation, you're doubling down on its biases and blind spots. A model might be excellent at generating fluent, engaging content, but it may not be as good at identifying subtle ethical or legal risks. Worse, it might fail to recognize its own limitations  -  a dangerous situation when the output is being auto-published.&lt;/p&gt;

&lt;p&gt;To address this, we designed a two-model architecture. The first model, which we'll call the &lt;strong&gt;content generator&lt;/strong&gt;, is optimized for fluency, engagement, and creativity. The second model, the &lt;strong&gt;risk scorer&lt;/strong&gt;, is trained on a dataset of flagged content, legal rulings, and ethical guidelines. It's not optimized for fluency  -  in fact, it's trained to be blunt and precise in its assessments.&lt;/p&gt;

&lt;p&gt;Here’s a simplified version of the pipeline in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;content_generator&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ContentGenerator&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;risk_scoring&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RiskScorer&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_and_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;generator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ContentGenerator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;primary_model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scorer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RiskScorer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;safety_model&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;draft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scorer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;risk_level&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;publish&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hold&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reason&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;reason&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach has several benefits. It decouples the creative and evaluative functions, reducing the risk of one model’s weaknesses affecting the other. It also allows for more granular control over what gets published  -  a key requirement for systems that operate without human-in-loop oversight.&lt;/p&gt;

&lt;p&gt;But the two-model approach isn’t without its tradeoffs. First, it increases latency. Every generated piece of content must now go through an additional step, which can slow down the pipeline. Second, it introduces a new point of failure  -  what if the risk scorer itself is biased or misconfigured? We’ve mitigated this by training the scorer on a diverse, curated dataset and using ensemble methods to reduce overfitting.&lt;/p&gt;

&lt;p&gt;Another challenge is the alignment of the two models. The content generator might produce content that’s technically safe but still controversial in context  -  a nuance the risk scorer might miss. This is where the human-in-loop becomes valuable, but we’re working on ways to surface these edge cases without requiring manual intervention.&lt;/p&gt;

&lt;p&gt;Looking ahead, we’re experimenting with a third model in the pipeline: a &lt;strong&gt;contextual filter&lt;/strong&gt; that takes into account the broader social, cultural, and temporal context of the content. We’re also exploring how to integrate feedback loops from the scorer back into the generator, allowing it to learn from its own mistakes  -  a kind of adversarial training that could make both models more robust over time.&lt;/p&gt;

&lt;p&gt;What do you think? Could a multi-model pipeline like this help reduce the risk of auto-published content going viral in the wrong way? Or is there a better way to balance creativity and safety in autonomous systems?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>safety</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Data Substrate Versus Vector Db Rag</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Wed, 28 Oct 2026 15:00:15 +0000</pubDate>
      <link>https://dev.to/apexgridtech/data-substrate-versus-vector-db-rag-2g3n</link>
      <guid>https://dev.to/apexgridtech/data-substrate-versus-vector-db-rag-2g3n</guid>
      <description>&lt;p&gt;This week's news about improved OCR capabilities for document images brought to mind a more fundamental question: how do we build systems that can &lt;em&gt;reason&lt;/em&gt; about the data they process? When dealing with AI applications in regulated environments like Nigerian microfinance, the answer hinges on the distinction between a "data substrate" and vector databases used in RAG systems.&lt;/p&gt;

&lt;p&gt;We're building a regtech tool for Nigerian microfinance banks that needs to analyze loan applications, detect fraud, and ensure compliance with evolving financial regulations. The data we work with is not just text  -  it's structured, versioned, and often comes with legal and audit implications. A vector database like Weaviate or Pinecone is useful for retrieving similar documents or answering questions based on unstructured content. But when we need to &lt;em&gt;reason&lt;/em&gt; about the data  -  like verifying that a particular clause in a loan agreement was present in version 1.2 but not 1.3  -  that's where a data substrate shines.&lt;/p&gt;

&lt;p&gt;A data substrate is a versioned, citable, queryable layer that sits beneath the AI application. It's not a replacement for vector DBs, but a complement. For example, in our regtech tool, we use a data substrate to store and version all loan agreements, client data, and regulatory documents. Each version is immutable and can be queried for specific clauses, dates, or jurisdictions. This is crucial when auditors ask, "Was this term in the contract when the loan was approved?"&lt;/p&gt;

&lt;p&gt;Here's how we model our data substrate using a PostgreSQL-based schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;document_versions&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="n"&gt;UUID&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;document_hash&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="n"&gt;JSONB&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="n"&gt;TIMESTAMPTZ&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;version_number&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;document_type&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;metadata&lt;/span&gt; &lt;span class="n"&gt;JSONB&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each document is stored as a JSONB blob, and we track its version number, creation timestamp, and metadata like the jurisdiction or regulation it relates to. This allows us to perform queries like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;document_versions&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;document_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'loan_agreement'&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'jurisdiction'&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Nigeria'&lt;/span&gt;
&lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;'regulation'&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'CBN 2023'&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach gives us full traceability  -  a key requirement in regulated environments. A vector DB would struggle to provide this level of versioning and auditability without significant overhead.&lt;/p&gt;

&lt;p&gt;But there are tradeoffs. A data substrate is not optimized for similarity searches or natural language queries. If we need to find all loan agreements that mention "collateral" in their content, we'd have to query the JSONB content field, which is less efficient than using a vector DB's similarity search. So, we use both: the data substrate for versioning and audit, and a vector DB for content-based retrieval.&lt;/p&gt;

&lt;p&gt;What's next? We're exploring hybrid architectures that combine the best of both worlds  -  using the data substrate for versioned facts and the vector DB for semantic similarity. We're also experimenting with integrating this with on-device AI models, so that microfinance officers in remote parts of Nigeria can run compliance checks without relying on cloud infrastructure. How would you approach this problem if you were building for a similar regulated environment?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>architecture</category>
      <category>regtech</category>
    </item>
    <item>
      <title>GPU Preflight For Cron Agents</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Sun, 25 Oct 2026 15:00:15 +0000</pubDate>
      <link>https://dev.to/apexgridtech/gpu-preflight-for-cron-agents-313f</link>
      <guid>https://dev.to/apexgridtech/gpu-preflight-for-cron-agents-313f</guid>
      <description>&lt;p&gt;This week, the open-source community buzzed with updates on model serving infrastructure, including the latest PRs for vLLM-Omni support. As teams race to deploy more efficient and scalable inference pipelines, one often-overlooked piece of the puzzle remains: ensuring that the hardware is ready before the job even starts. At Apex Grid, we’ve spent the last few months refining a two-stage GPU preflight check that has become a critical part of our cron agent infrastructure.&lt;/p&gt;

&lt;p&gt;When deploying cron jobs that depend on GPU resources, it’s not enough to simply wrap the job in a try/except block. That approach risks silently failing when the underlying issue is not the job itself, but the state of the GPU. For example, another job might be monopolizing the card, or the kernel might be in a state where it’s not responding to requests. Our solution involves a two-stage preflight check that ensures both the GPU and the serving stack are in a healthy state before we even attempt to run the job.&lt;/p&gt;

&lt;p&gt;Our preflight logic hinges on two simple but effective endpoints: one that checks for basic health (&lt;code&gt;/api/tags&lt;/code&gt;) and another that performs a lightweight inference (&lt;code&gt;/api/generate&lt;/code&gt;). The first check ensures that the model server is responsive and can return a list of available tags  -  a quick smoke test. The second check runs a minimal inference task, which helps us detect if the GPU is actually available and not being blocked by another job. We set a warmup timeout for this second check, typically between 3 and 10 seconds, depending on the model size and workload.&lt;/p&gt;

&lt;p&gt;Here’s how our &lt;code&gt;gpu_ready()&lt;/code&gt; helper looks in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;gpu_ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;warmup_timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# First check: basic health
&lt;/span&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;tags_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/api/tags&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tags_response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestException&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="c1"&gt;# Second check: warmup inference
&lt;/span&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;generate_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/api/generate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, world!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max_tokens&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;warmup_timeout&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;generate_response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RequestException&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach has several advantages. It ensures that the GPU is not just available but also in a state where it can handle the job without stalling or timing out. It also allows us to cleanly skip the job if the preflight check fails, rather than letting it fail later and potentially leaving the system in an inconsistent state. This has been particularly useful in environments where multiple cron jobs share the same GPU resource pool.&lt;/p&gt;

&lt;p&gt;Of course, there are tradeoffs. The preflight check adds a small amount of latency to the overall job scheduling process. Additionally, it requires that the model server exposes both the &lt;code&gt;/api/tags&lt;/code&gt; and &lt;code&gt;/api/generate&lt;/code&gt; endpoints, which may not be the case for all serving stacks. We’ve mitigated this by making the preflight logic configurable  -  allowing teams to skip the second stage if needed, or to use a different lightweight inference task.&lt;/p&gt;

&lt;p&gt;Looking ahead, we’re exploring ways to make this preflight logic more adaptive. For example, we’re experimenting with using a lightweight model for the warmup inference that’s specifically tuned for this task, reducing the time it takes to complete the second stage. We’re also looking into integrating this logic more deeply with Kubernetes and other orchestration tools, to make GPU readiness checks part of the broader system health monitoring pipeline. What do you think  -  would you prefer a preflight check that’s even more lightweight, or one that gives more detailed diagnostics when it fails?&lt;/p&gt;

</description>
      <category>python</category>
      <category>devops</category>
      <category>ai</category>
      <category>reliability</category>
    </item>
    <item>
      <title>Ollama v1 OpenAI Compat Drops Think Toggle</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Thu, 22 Oct 2026 15:05:38 +0000</pubDate>
      <link>https://dev.to/apexgridtech/ollama-v1-openai-compat-drops-think-toggle-27ne</link>
      <guid>https://dev.to/apexgridtech/ollama-v1-openai-compat-drops-think-toggle-27ne</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;We recently ran into an issue with the Ollama &lt;code&gt;/v1&lt;/code&gt; endpoint, which is designed to be compatible with OpenAI's API. Our models, particularly those from the Qwen3 family, were returning empty content. This was not the behavior we expected, given the models' capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Noticed
&lt;/h2&gt;

&lt;p&gt;We started by examining the requests and responses to identify what was going wrong. We noticed that the &lt;code&gt;/v1&lt;/code&gt; endpoint was silently dropping the &lt;code&gt;think: false&lt;/code&gt; toggle for the Qwen3-family models. This toggle is crucial as it controls whether the model spends its entire &lt;code&gt;num_predict&lt;/code&gt; budget on internal reasoning or not.&lt;/p&gt;

&lt;p&gt;Here's a snippet of the payload we were sending:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"qwen3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Translate 'hello' to French."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"think"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We expected the model to translate "hello" to French without extensive internal reasoning. However, the model was spending its entire &lt;code&gt;num_predict&lt;/code&gt; budget on reasoning and returning empty content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Approach
&lt;/h2&gt;

&lt;p&gt;To fix this issue, we switched to the native &lt;code&gt;/api/chat&lt;/code&gt; endpoint provided by Ollama. This endpoint allows us to have more control over the model's behavior and ensures that the &lt;code&gt;think&lt;/code&gt; toggle is respected.&lt;/p&gt;

&lt;p&gt;Here's the payload we used with the &lt;code&gt;/api/chat&lt;/code&gt; endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"qwen3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Translate 'hello' to French."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"think"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By switching to the &lt;code&gt;/api/chat&lt;/code&gt; endpoint, we were able to control the model's behavior more effectively and get the expected output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tradeoffs
&lt;/h2&gt;

&lt;p&gt;Switching to the &lt;code&gt;/api/chat&lt;/code&gt; endpoint has its own set of tradeoffs. While it gives us more control over the model's behavior, it also requires us to refactor our code to handle the new endpoint. Additionally, the &lt;code&gt;/api/chat&lt;/code&gt; endpoint may have different rate limits and pricing structures compared to the &lt;code&gt;/v1&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;p&gt;However, the benefits of having more control over the model's behavior and getting the expected output outweigh these tradeoffs for us.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We're Doing Next
&lt;/h2&gt;

&lt;p&gt;We are currently exploring other endpoints and features provided by Ollama to see if they offer any additional benefits for our use case. We are also working on improving our monitoring and alerting systems to catch such issues earlier.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>ollama</category>
      <category>debugging</category>
      <category>python</category>
    </item>
    <item>
      <title>Postiz Self Host Bluesky Python Client</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Mon, 19 Oct 2026 15:00:14 +0000</pubDate>
      <link>https://dev.to/apexgridtech/postiz-self-host-bluesky-python-client-32gn</link>
      <guid>https://dev.to/apexgridtech/postiz-self-host-bluesky-python-client-32gn</guid>
      <description>&lt;p&gt;This week, the conversation around Docker and auto-updating containers has sparked a lot of debate, especially around the tradeoffs between convenience and control. As engineers who've spent time wrestling with container orchestration, we’ve found that sometimes the simplest setups are the most reliable  -  and that includes self-hosting.&lt;/p&gt;

&lt;p&gt;We’re running a self-hosted instance of Postiz, a self-hostable Bluesky client, using Docker Compose. The goal is to have a lightweight, zero-ops setup that can be managed directly from a Python script. This approach avoids the complexity of Kubernetes or managed services while still giving us full control over the deployment and API interactions.&lt;/p&gt;

&lt;p&gt;Our Docker Compose setup is minimal, pulling the latest Postiz image from GitHub Packages and exposing the necessary ports. Here's a simplified version of our &lt;code&gt;docker-compose.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.8'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postiz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/postiz/postiz:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;8080:8080"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTIZ_DATABASE_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;postgres://user:pass@postgres:5432/postiz"&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres&lt;/span&gt;
  &lt;span class="na"&gt;postgres&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pass&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postiz&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres_data:/var/lib/postgresql/data&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres_data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Python client communicates with the Postiz instance via the &lt;code&gt;/api/public/v1/posts&lt;/code&gt; endpoint. This endpoint supports both creating a new post and fetching a list of posts, depending on the HTTP method used. The JSON payload for a new post includes the text, visibility, and optionally a reply to another post. Here's the shape of the request body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"This is a new post from the Python client."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"visibility"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"public"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"reply"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"uri"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"at://example.com/0123456789abcdef0123456789abcdef"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Authorization&lt;/code&gt; header is required and must be a valid Bearer token, typically obtained via the &lt;code&gt;/auth/token&lt;/code&gt; endpoint. This token is scoped to the user and provides access to the &lt;code&gt;/api/public/v1/posts&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;p&gt;One of the quirks we've encountered is that the &lt;code&gt;/api/public/v1/posts&lt;/code&gt; endpoint can return either a single post object or a list of posts, depending on the context of the request. This behavior is not always well-documented, so we've implemented a helper function in our Python client to normalize the response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fetch_posts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/api/public/v1/posts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function ensures that regardless of whether the API returns a single object or a list, our code can handle it consistently.&lt;/p&gt;

&lt;p&gt;We’re currently working on extending the Python client to support more of Postiz’s API endpoints, including user management and moderation tools. We’re also exploring ways to integrate this setup with a local development environment that mirrors production as closely as possible.&lt;/p&gt;

&lt;p&gt;What would you prioritize next if you were building a self-hosted Bluesky client?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>python</category>
      <category>socialmedia</category>
      <category>docker</category>
    </item>
    <item>
      <title>Cron Scheduled Ollama Autonomous Agent</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Tue, 13 Oct 2026 15:00:29 +0000</pubDate>
      <link>https://dev.to/apexgridtech/cron-scheduled-ollama-autonomous-agent-3338</link>
      <guid>https://dev.to/apexgridtech/cron-scheduled-ollama-autonomous-agent-3338</guid>
      <description>&lt;p&gt;This week, the AI infrastructure space saw some eye-opening benchmarks, with modular systems showing dramatic performance gains over alternatives. Amid all the noise, we’ve been quietly iterating on a specific use case that sits at the intersection of autonomous agents and on-device AI: a cron-scheduled Ollama-based social agent that runs on our infrastructure and interacts with users across multiple channels.&lt;/p&gt;

&lt;p&gt;We’re building a system where an autonomous agent generates content at regular intervals, processes it through multiple gates, and only publishes it if it passes all checks. The core of this system is Ollama, which we use for its lightweight footprint and ability to run large language models locally. To make this work, we’ve designed a modular architecture that separates concerns: voice profiles are stored as separate files, controversy is checked by a second model, and credit checks are made by querying a Postgres database. Rejected content is quarantined for later review.&lt;/p&gt;

&lt;p&gt;Here’s how the publish pipeline looks in code. We’ve abstracted the main function as &lt;code&gt;publish_to_all_channels&lt;/code&gt;, which is called by a cron job every 12 hours. The function is responsible for generating content, running it through the gates, and publishing if all checks pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ollama&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Client&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;psycopg2&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;publish_to_all_channels&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# Step 1: Generate content using Ollama
&lt;/span&gt;    &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llama3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Write a social media post about AI ethics&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;generated_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;response&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 2: Run through voice profile check
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;check_voice_profile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;voice_profile_failed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 3: Run through controversy gate using a second model
&lt;/span&gt;    &lt;span class="n"&gt;controversy_client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;controversy-checker&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;controversy_result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;controversy_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;controversy_result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;response&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;controversial&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;high_risk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;controversy_gate_failed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 4: Run through credit gate by querying Postiz DB
&lt;/span&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;psycopg2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;dbname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POSTIZ_DB_NAME&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POSTIZ_DB_USER&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POSTIZ_DB_PASSWORD&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POSTIZ_DB_HOST&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;POSTIZ_DB_PORT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT * FROM credits WHERE content = %s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchone&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;credit_gate_failed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Database error: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;log_to_quarantine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;database_error&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Step 5: Publish the content to all channels
&lt;/span&gt;    &lt;span class="nf"&gt;publish_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;generated_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach lets us keep the system modular and scalable. Each gate is a self-contained function that can be swapped out or updated independently. For example, we could replace the controversy-checker model with a different one if needed, or even switch to a rule-based system for certain use cases. The quarantine system is equally important  -  it allows us to review content that failed any gate, and potentially reprocess it later if conditions change.&lt;/p&gt;

&lt;p&gt;There are tradeoffs, of course. By using cron jobs, we’re introducing a fixed interval between runs, which may not be ideal for real-time use cases. Also, the current setup assumes a single content generation per run, which might not scale well for high-frequency publishing. We’re actively exploring ways to decouple the scheduling from the processing pipeline, and are looking into event-driven architectures that could allow for more dynamic content generation and publishing.&lt;/p&gt;

&lt;p&gt;We’re also working on improving the performance of the controversy gate  -  the second model check is currently a bit slow, and we’re experimenting with model quantization and caching to reduce latency. What do you think is the right balance between accuracy and speed in this kind of gate? We’d love to hear your thoughts in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Publishing Pipeline Scheduled vs Immediate</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Sat, 10 Oct 2026 15:00:28 +0000</pubDate>
      <link>https://dev.to/apexgridtech/publishing-pipeline-scheduled-vs-immediate-2o2n</link>
      <guid>https://dev.to/apexgridtech/publishing-pipeline-scheduled-vs-immediate-2o2n</guid>
      <description>&lt;p&gt;This week, the AI world turned its gaze toward Beam, a new model that's stirring conversations about the next wave of generative AI. But while the world is talking about models, we're talking about the systems that bring them to life  -  specifically, how we balance the immediacy of content delivery with the strategic power of scheduling.&lt;/p&gt;

&lt;p&gt;At Apex Grid, we're building a publishing pipeline that bridges the gap between immediate content delivery and scheduled publishing. Our platform, Postiz, handles both: scheduling social posts to hit user timezones precisely, and publishing long-form content on a cron-fire. The challenge? Ensuring consistency across channels, especially when dealing with canonical URLs.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem: Consistency Across Channels
&lt;/h3&gt;

&lt;p&gt;When content is published immediately, it's straightforward  -  the URL is fixed, and it's shared across all platforms. But when content is scheduled, the URL might not be available until the post is published. This creates a disconnect between the scheduled post (which may be shared on social media with a placeholder URL) and the final published article (which has its own canonical URL). &lt;/p&gt;

&lt;p&gt;The result? A fragmented user experience, broken links, and a lack of trust in the content's integrity. For a technical audience, this is more than a UX issue  -  it's a data integrity problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Our Approach: Hybrid Publishing with Smart Routing
&lt;/h3&gt;

&lt;p&gt;Our solution is a hybrid publishing model that leverages both scheduled and immediate publishing. For social media, we schedule posts based on user timezones using a cron-based system that respects local time zones. For long-form content, we publish immediately using a webhook-driven architecture. &lt;/p&gt;

&lt;p&gt;The key lies in our internal routing system, which maps scheduled posts to their canonical URLs once the content is published. This system uses a lightweight event-driven architecture, where each scheduled post is associated with a content ID that's resolved at publish time.&lt;/p&gt;

&lt;p&gt;Here’s a simplified version of our routing logic in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pytz&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;resolve_canonical_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Fetch the canonical URL from the database based on the post ID
&lt;/span&gt;    &lt;span class="n"&gt;canonical_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT canonical_url FROM posts WHERE id = ?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;canonical_url&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;canonical_url&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;schedule_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone_str&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;tz&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pytz&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scheduled_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;astimezone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tz&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hour&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minute&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;microsecond&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scheduled_time_utc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scheduled_time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;astimezone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Schedule the post to be published at scheduled_time_utc
&lt;/span&gt;    &lt;span class="n"&gt;scheduler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_job&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;publish_post&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;trigger&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;date&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;run_date&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;scheduled_time_utc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;publish_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;canonical_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;resolve_canonical_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;canonical_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Update the scheduled post with the canonical URL
&lt;/span&gt;        &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;UPDATE scheduled_posts SET canonical_url = ? WHERE post_id = ?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canonical_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="c1"&gt;# Trigger the webhook to publish the long-form content
&lt;/span&gt;        &lt;span class="n"&gt;webhook_client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.postiz.com/webhooks/publish/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Handle error: no canonical URL found
&lt;/span&gt;        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Could not find canonical URL for post ID &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tradeoffs: Flexibility vs Complexity
&lt;/h3&gt;

&lt;p&gt;This hybrid approach gives us the flexibility to schedule posts for optimal engagement while ensuring that all content is published with a consistent canonical URL. However, it adds complexity to our system  -  we now have to manage two different publishing workflows and ensure that the mapping between scheduled posts and canonical URLs is always accurate.&lt;/p&gt;

&lt;p&gt;We also have to be careful with time zones and cron scheduling, which can be a pain point for any system that needs to respect local time. Our current solution uses the &lt;code&gt;pytz&lt;/code&gt; library to handle time zone conversions, but we're always on the lookout for more robust, future-proof alternatives.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's Next
&lt;/h3&gt;

&lt;p&gt;We're currently working on a new feature that will allow users to preview scheduled posts with their canonical URLs before they're published. This will help reduce errors and improve the user experience for our content creators. We’re also exploring ways to unify the scheduling and publishing workflows into a single, more intuitive interface.&lt;/p&gt;

&lt;p&gt;What do you think about the tradeoffs between scheduling and immediate publishing in content platforms? Have you faced similar challenges in your projects?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>socialmedia</category>
      <category>python</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Controversy Gate Second Model Check</title>
      <dc:creator>Francis Oyakhire</dc:creator>
      <pubDate>Wed, 07 Oct 2026 15:00:27 +0000</pubDate>
      <link>https://dev.to/apexgridtech/controversy-gate-second-model-check-5aal</link>
      <guid>https://dev.to/apexgridtech/controversy-gate-second-model-check-5aal</guid>
      <description>&lt;p&gt;This week, Cloudflare introduced Clef, a new open-source decision model and fine-tuning platform that shifts the focus from just generating content to evaluating it. As the conversation around AI-generated content and its societal impact grows, we’re seeing a shift toward systems that don’t just create, but also &lt;em&gt;evaluate&lt;/em&gt; what they create. At Apex Grid, we've been exploring a similar pattern in our work on autonomous social posting, where the risk of embarrassment or controversy is high.&lt;/p&gt;

&lt;p&gt;The problem we're solving is straightforward: when an autonomous system generates content for public consumption  -  think social media posts, customer service replies, or even internal communications  -  it must be evaluated for potential risk before publication. The naive approach is to use a single model to both generate and evaluate content. But that’s a bad idea. The same model that’s incentivized to be creative might not be the best judge of its own output. Worse, it might be biased toward its own style, missing real-world nuance.&lt;/p&gt;

&lt;p&gt;Our approach is to split the work between two models: one for &lt;em&gt;drafting&lt;/em&gt; content, and another for &lt;em&gt;scoring&lt;/em&gt; it for controversy or risk. The first model, let’s call it the &lt;em&gt;generator&lt;/em&gt;, is optimized for fluency, creativity, and relevance. The second, the &lt;em&gt;evaluator&lt;/em&gt;, is optimized for detecting offensive, controversial, or high-risk content. The evaluator is trained on a diverse dataset of annotated examples, and it returns a score that the system can use to decide whether to publish, edit, or reject the content.&lt;/p&gt;

&lt;p&gt;Here’s a simplified version of what our system looks like in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;generator&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Generator&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;evaluator&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Evaluator&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;publish_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;generator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;generator-v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;evaluator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Evaluator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;evaluator-v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;draft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;evaluator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# threshold for acceptable risk
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;draft&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content flagged for review&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This two-model architecture has a number of benefits. First, it creates a clear separation of concerns  -  the generator doesn’t need to worry about being a judge, and the evaluator doesn’t need to be a creative writer. Second, it allows us to fine-tune each model independently, with different data and objectives. And third, it opens up the possibility of using specialized models for evaluation, such as those trained on legal, cultural, or ethical datasets.&lt;/p&gt;

&lt;p&gt;But this approach is not without its tradeoffs. One major challenge is ensuring that the evaluator model isn’t too strict or too lenient. If it’s too strict, it might prevent legitimate content from being published. If it’s too lenient, it might allow harmful content to slip through. Balancing this requires careful calibration, and it’s an active area of research for us.&lt;/p&gt;

&lt;p&gt;Another challenge is the computational overhead. Running two models in sequence increases latency and resource usage, which can be a concern in real-time systems. We’ve experimented with various optimizations, like model quantization and caching, to reduce this impact without sacrificing accuracy.&lt;/p&gt;

&lt;p&gt;What’s next? We’re exploring ways to integrate real-time feedback from users into the evaluator model, so it can learn from the actual consequences of its decisions. We’re also looking into hybrid models that can both generate and evaluate content, but with internal mechanisms that prevent self-bias. And finally, we’re considering how to make this pattern more general  -  not just for social posting, but for any system where autonomous agents need to assess the risk of their own output.&lt;/p&gt;

&lt;p&gt;How might you apply this two-model pattern in your own work? Are there use cases where a separate evaluator model is essential, and where it’s not worth the cost?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>safety</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
