<?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: Ma Zl</title>
    <description>The latest articles on DEV Community by Ma Zl (@mzltest).</description>
    <link>https://dev.to/mzltest</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3372030%2Fccfcc0f6-d108-4d9a-b27f-b9de7aa7777c.jpeg</url>
      <title>DEV Community: Ma Zl</title>
      <link>https://dev.to/mzltest</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mzltest"/>
    <language>en</language>
    <item>
      <title>Build a AI survey system on Tencent Edgeone</title>
      <dc:creator>Ma Zl</dc:creator>
      <pubDate>Mon, 04 Aug 2025 04:00:00 +0000</pubDate>
      <link>https://dev.to/mzltest/build-a-ai-survey-system-on-tencent-edgeone-54jn</link>
      <guid>https://dev.to/mzltest/build-a-ai-survey-system-on-tencent-edgeone-54jn</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foyyeremv42itz45thc61.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foyyeremv42itz45thc61.jpg" alt=" " width="720" height="1600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI Survey system based on EdgeOne Pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Multilingual (Chinese/English)&lt;/li&gt;
&lt;li&gt;AI-supported survey crafting / results analysis&lt;/li&gt;
&lt;li&gt;Multiple question types&lt;/li&gt;
&lt;li&gt;WYSIWYG survey editor with live preview&lt;/li&gt;
&lt;li&gt;Advanced question condition editor&lt;/li&gt;
&lt;li&gt;one entry per IP&lt;/li&gt;
&lt;li&gt;mobile optimized&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Edgeone Pages functionality used:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pages KV&lt;/li&gt;
&lt;li&gt;Pages AI&lt;/li&gt;
&lt;li&gt;Pages Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Design considerations:
&lt;/h2&gt;

&lt;p&gt;This is AI-assisted project with classic frontend/backend separation.&lt;/p&gt;

&lt;p&gt;Frontend uses font-awesome for icons and AI homemade css &amp;amp;js , not referencing other libraries but it looks perfectly professional and good so I kept the design.&lt;/p&gt;

&lt;p&gt;Backend uses Pages functions , since frontend does all the heavy lift, backend apis are relatively simple.Some challenges exists though:&lt;/p&gt;

&lt;h3&gt;
  
  
  How to save responses
&lt;/h3&gt;

&lt;p&gt;Pages KV is a simple key-value database , it's not designed to be powerful for a survey system. How to save responses and view them later rather efficiently?&lt;/p&gt;

&lt;p&gt;My solution is to provide two saving modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single: Responses are saved in a single document, providing best speed ,and since a document can be as large as 25MB,this is a pretty decent choice for most surveys.&lt;/li&gt;
&lt;li&gt;Multi: Responses are saved one document per response.This provides better reliability and better support in more responses.Key for these documents follow a specific pattern with surveyid as a prefix to take advantage of kv.list prefix parameter,speeding up data query by filtering surveyid first.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to make sure AI responses are valid
&lt;/h3&gt;

&lt;p&gt;My AI capabilities require LLM to generate JSONs following a specific schema. LLMs tend to generate broken data or ignore instructions,causing data to be unusable, however, mine method prevents them:&lt;/p&gt;

&lt;p&gt;1.Use a system prompt that instruct LLM to generate correct schema by deliberately asking to generate JSON only.This works better than user prompts&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clean the LLM response first before actually using. Extract JSON first(LLM tend to explain code generated, this is to delete their explanations.),do a &lt;a href="https://www.npmjs.com/package/jsonrepair" rel="noopener noreferrer"&gt;jsonrepair&lt;/a&gt;, regenerate ids by LLM(they are bad at unique IDs)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;doing the steps above eliminated LLM errors and able to keep workflow smooth.&lt;/p&gt;

&lt;h3&gt;
  
  
  Products I used to make this project
&lt;/h3&gt;

&lt;p&gt;Frontend: websim(Sonnet 4)&lt;/p&gt;

&lt;p&gt;Backend: Gemini 2.5 Pro(google AI studio)&lt;/p&gt;

&lt;p&gt;I make frontend first, then make backend , finally ask frontend to integrate with backend&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;1.Apply for Pages KV first,this project depends on this function.&lt;/p&gt;

&lt;p&gt;2.&lt;a href="https://edgeone.ai/pages/new?repository-url=https%3A%2F%2Fgithub.com%2Fmzltest%2Feoq" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdnstatic.tencentcs.com%2Fedgeone%2Fpages%2Fdeploy.svg" alt="使用 EdgeOne Pages 部署" width="153" height="32"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.Create a KV namesapace,use &lt;code&gt;mykv&lt;/code&gt; to bind to the newly created Pages KV&lt;/p&gt;

</description>
      <category>edgeonepages</category>
    </item>
  </channel>
</rss>
