AppBuilder低代碼體驗:構建雅思大作文組件


Ai technology

前言

AppBuilder上線了低代碼製作組件功能,可以通過工作流的方式構建自定義組件,完成簡單Agent無法完成的複雜功能,使得生成的文本更加定製化,根據開發者制定的規則完成任務。

本次我嘗試了利用工作流組件,創作一個雅思大作文寫作助手,可以根據用戶要求,完成特定格式的雅思大作文。


Ai technology

設計思路

雅思大作文一般都是議論文,往往是給出一個話題,可能是有關環境、文化或某種社會現象的闡述,讓考生依據這個現象給出自己的觀點,完成一篇不少於250詞的英語議論文。

雅思寫作的思路一般如下:

1.根據話題,提取關鍵詞,給出總觀點。

2.根據總觀點,分解成3、4個分論點。

3.根據總觀點,撰寫開頭段。

4.根據分論點,撰寫2到3個展開段。

5.撰寫結尾段。

根據以上邏輯,便可撰寫出一篇雅思大作文,而這樣的邏輯性正好適合工作流組件的編排,於是選擇創建一個雅思大作文助手的工作流組件。


Ai technology

AppBuilder 組件功能介紹

AppBuilder 組件工作流中,除了開始和結束節點以外,目前一共有5個基礎節點,分別爲大模型、知識庫、API、分支器與代碼節點。



Ai technology

大模型節點

大模型節點可調用大語言模型,根據輸入參數和提示詞生成回覆。大模型節點中可以配置:

大模型配置模板:提供預製的示例模板,快速填寫節點配置信息。

模型配置:支持選擇模型和多樣性參數。目前支持 ERNIE-4.0-8K 、ERNIE-3.5-8K 、ERNIE Speed-AppBuilder 3種模型,其中 ERNIE Speed-AppBuilder 不支持多輸出。

輸入:可以引用前序節點的參數,作爲輸入。此處的輸入可以插入提示詞中,作爲變量。

提示詞:編寫大模型的提示詞,使大模型實現對應功能。通過插入花括號的方式,如 {{input}} ,可以引用對應的參數值。此處也可以在輸出定義參數,並在提示詞中引用,如 {{output1}},指定大模型將對應信息按照參數的格式輸出。

輸出:通過參數輸出大模型的結果。有多個輸出參數時,需要準確填寫參數描述,並在提示詞中指定每個參數的輸出內容。

其中,右側大模型配置模版中,給出了一些特定需求的案例,目前有 客戶相似問題生成 ,標籤抽取 ,複雜問題拆解 ,問答對挖取 4種,每種都有官方提供的提示詞模版,方便大家在此基礎上編寫提示詞。


下面給出具體提示詞內容:

一.客戶相似問題生成

針對客服問答場景,對提供的原始問題進行改寫,生成3個相似的問題。要求:1.生成的問題之間文字不能相同,改寫方式要有多樣性2.對於原始問題中涉及到公司名稱、品牌、地點等信息時相似問中對應信息不能變更3.生成的問題要與原始問題保持提問內容上的一致性 示例原始問題:冰激凌5G套餐資費是多少? 可參考的改寫方法與示例:增加不影響語義的疑問詞-請問冰激凌5G套餐的資費是多少呢?對原始問題的詞語進行同義改寫-冰激凌5G套餐的價格是多少?增加不影響問題內容的描述-能告訴我冰激凌5G套餐的收費標準嗎?改變提問的句式-我想了解一下冰激凌5G套餐的資費情況,可以嗎?綜合多種改寫方法-你們冰激凌5G套餐的費用是怎麼計算的,能告訴我嗎? 原始問題:{{query}}請按照嚴格按照以下格式輸出相似問題:{ "output1":"(相似問題1)", "output2":"(相似問題2)", "output3":"(相似問題3)" }

二.標籤抽取

從以下文本中歸納主題標籤,每個標籤儘可能不超過7字,標籤需要在全文中完整的出現,不能生成沒有見過的字符,輸出3個結果,用數字編號:
文本:{{query}}
主題標籤: 標籤1: output1 標籤2: output2 標籤3: output3


三.複雜問題拆解

你是問題拆解專家,擅長將複雜問題拆解爲若干簡單問題。複雜問題的定義:複雜問題通常是需要多個步驟的簡單問題回答才能解決的,相對簡單問題而言需要對較多的知識進行綜合、分析、對比等思維活動。簡單問題的定義:簡單問題通常只需要簡單的步驟就能回答,問題的答案通常是事實、數字、概念的解釋等。 請按照複雜問題和簡單問題的定義,對如下複雜問題進行簡單問題拆解,使得拆解後的3個子問題對應的答案能夠更好的回答原始的複雜問題。  複雜問題:{{query}} 拆解後的簡單問題: 子問題1: output1 子問題2: output2 子問題3: output3

4.問題對挖掘

從以下輸入文本中生成多個問題,並且給出問題的答案。下面是生成問題和答案的具體要求: 問題不可脫離文本,符合常見的中文語言習慣,問題應該適當總結文本或變換文本描述,使問題語言 風格貼近人類,而不是對文本內容的重複敘述; 問題的答案能夠通過輸入文本中的信息回答,且需要保證文本的主題、關鍵信息都在答案中; 文本的非關鍵信息、非主題信息不要生成問題,空洞、無主題、語言混亂無邏輯的文本不要生成問題。  輸入文本: {{query}}  問題和答案如下, 問題1:output_q1 答案1:output_a1 問題2:output_q2 答案2:output_a2



Ai technology

知識庫節點

知識庫節點支持根據輸入的query,在選定的知識庫中檢索相關片段並召回,返回切片列表。你可以上傳文件並建立知識庫,在知識庫節點中勾選想要使用的知識庫進行檢索。

輸入參數:參數名不可修改,參數類型爲string,上級節點的輸出參數會強制轉換爲string類型作爲知識庫節點的輸入,輸入參數有兩種類型:1)引用類型爲引用上一個節點的輸出變量,2)常量類型,可以輸入一個string類型的入參。

選擇知識庫:選擇需要檢索的知識庫,支持選擇多個知識庫。

檢索策略:按照指定的檢索策略從知識庫中尋找匹配的片段,不同的檢索策略可以更有效地找到正確的信息,提高最終生成的答案的準確性和可用性。

召回數量:設置從知識庫中召回與輸入Query匹配的知識片段的個數,設定的數量越大,召回的片段越多

匹配分:在檢索過程中,用來計算輸入Query和知識庫片段的相似度,高於匹配分數的片段將會被檢索召

輸出參數:在知識庫中檢索輸出的變量信息及變量類型



Ai technology

API節點

API節點是基礎節點類型之一,您可以通過該節點,將已有服務註冊爲組件,幫助擴展應用能力邊界。

比如您有一個可以查詢教育信息的接口,通過在API節點中註冊接口信息,併發布爲組件,就可以在應用配置的【組件】中選擇該組件,那麼該應用將按照要求查詢對應信息。

當前API節點可支持標準的HTTP請求。


使用說明:

1.添加API節點,編輯API節點的基本信息,包括:請求方式、訪問資源URL、Headers信息、鑑權信息、請求參數信息、返回參數信息。您可以只填寫必需的輸入參數和返回參數。比如在返回參數配置中,若需輸出返回數據中某個對象的完整內容,僅需設置最頂層參數信息並選擇適當的參數類型。

2.在API調試環節,可以通過表單或JSON方式填寫輸入參數並點擊運行,運行成功後點擊【保存】。

3.繼續在右側面板中對輸入參數進行值配置,您可以引用前序節點輸出,或手動輸入對應參數值。需要確保引用類型與設置類型一致。

4.在整體流程調試前,API節點需要爲調試通過狀態。

5.點擊調試,您可以對整個流程進行調試,查看每個節點的運行情況和最終輸出結果。



Ai technology

分支器節點

分支器節點可以連接兩個下游節點。設定的條件成立則運行”如果"分支,不成立則運行“否則"分支。在如果分支中,可以選擇條件關係,以及添加多個條件。

複雜的條件關係可以通過串聯多個分支器節點實現。



Ai technology

代碼節點

在代碼節點中,可通過編寫代碼實現自定義的處理功能。引入代碼節點到畫布中,可在編輯器(IDE)內看到默認的示例代碼。

編輯器的使用:

引用輸入:配置了輸入參數名和參數值後,可以在編輯器中引用輸入參數。編輯器引入輸入參數時,需要通過字典變量 params 引入代碼節點的輸入參數。

返回輸出:需要在編輯器中定義一個字典變量,作爲編輯器中函數的輸出。代碼節點的輸出參數是該字典變量的鍵(key)。

運行時環境:編輯器支持的運行時環境爲 Python 3 運行環境預製了 NumPy 包。 

編輯器測試功能:

輸入測試:在輸入測試區域可以輸入測試數據,並進行調試運行。“自動填入” 功能可以根據當前輸入參數類型,生成輸入數據。

輸出測試:測試數據的運行結果會展示在輸出測試區域中。運行成功後可以使用 “更新節點 Schema” 功能。使用後,代碼節點的輸出配置信息將被輸出測試的 schema 自動覆蓋。



Ai technology

雅思大作文應用設計

3.1 雅思大作文助手組件設計

根據第 1 節的設計思路,設計雅思大作文助手組件,下面介紹具體流程。


1.創建組件 進入百度智能雲千帆AppBuilder的 組件廣場,點擊創建組件,進入組件創建界面

填寫組件名稱、英文名稱與組件描述,其中大模型將根據 組件描述 識別並調用該組件。可以選擇用AI生成頭像,選擇空畫布,創建組件。

2.開始節點 包含兩個輸入參數,String 類型接收雅思大作文的題目的 topic 和 Number 類型接收用戶期待雅思得分的 expected_score 。

3.撰寫總觀點節點

模型:選擇模型爲 ERNIE-3.5-8K ,多樣性爲 0.1 

輸入:大作文題幹 topic 。

提示詞:提示詞分爲兩部分撰寫,首先給出節點任務目標,需要調用的參數用 {{}} 來表示;然後給出範例輸入輸出。

輸出:String 類型 大作文總觀點 參數 general_view


你是一個雅思作文寫作助手,請根據雅思大作文題目{{topic}},用中文給出一句話的雅思大作文總觀點。
範例:
大作文題目:Children are the target of a large amount of advertising today. Some people believe that this should be prohibited since it may harm children. To what extent do you agree or disagree?
總觀點輸出:我認爲,廣告對兒童有害,我們應該禁止針對兒童的廣告。

4.撰寫分論點節點

模型:選擇模型爲 ERNIE-3.5-8K ,多樣性爲 0.1 

輸入:大作文題幹topic,大作文總觀點general_view


提示詞:

你是一個雅思作文寫作助手,根據雅思大作文題目{{topic}},與總觀點{{general_view}}生成2個分論點。要求:1. 用中文生成分論點,用一句話表述。2. 生成的分論點之間文字不能相同。3. 分論點是根據總觀點{{general_view}}延伸出來的,可以根據主觀點的特點、分類、結果分解出分論點。
示例:
大作文題目:Children are the target of a large amount of advertising today. Some people believe that this should be prohibited since it may harm children. To what extent do you agree or disagree?
總觀點:我認爲,廣告對兒童有害,我們應該禁止針對兒童的廣告。
分論點1:我認爲,兒童會被廣告所左右,因爲他們還不成熟。
分論點2:在我看來,廣告會損害兒童的健康成長環境。

輸出:String 類型的分論點1 viewpoint1 和分論點2 viewpoint2。

5.撰寫起始段

模型:選擇模型爲 ERNIE-3.5-8K ,多樣性爲 0.1 。

輸入:大作文題幹topic大作文總觀點general_view ,期望的分數expected_score 。


提示詞:

你是一個雅思作文寫作助手,請根據話題{{topic}}和大作文總觀點{{general_view}},撰寫大作文起始段。要求:1. 用英文撰寫起始段,英文用詞符合預期雅思得分{{expected_score}}。2. 起始段寫兩句話,第一句複述話題,第二句闡述總觀點。3. 複述話題不能和{{topic}}完全一樣。
範例:話題:Children are the target of a large amount of advertising today. Some people believe that this should be prohibited since it may harm children. To what extent do you agree or disagree?
總觀點:我認爲,廣告對兒童有害,我們應該禁止針對兒童的廣告。
起始段:Our life is saturated with various advertisements nowadays.However, I don't think that children should be the focus of marketing campaigns

6.撰寫展開段

模型:展開段輸出內容最多,選擇性能最好的模型 ERNIE-4.0-8K ,多樣性爲 0.4 。

輸入:大作文題幹 topic ,大作文總點general_view ,期望的分數 expected_score 。


提示詞:因爲展開段詞數要求較多,本節點提示詞未採用範例內容。

你是一個雅思作文寫作助手,請根據話題{{topic}}和大作文總觀點{{general_view}},撰寫大作文兩段展開段。要求:1. 用英文撰寫展開段,展開段每段寫100詞,英文用詞符合預期雅思得分{{expected_score}}。2. 每段寫兩個論證模塊,每段一個分論點,兩個分支子論點3. 展開段開頭闡述分論點,後續要包含論述、舉例、細節等元素,符合雅思作文標準。

輸出:

String 類型的展開段1 detail_paragraph1 和展開段2 detail_paragraph2 。

7.撰寫結尾段節點

模型:選擇模型爲 ERNIE-3.5-8K ,多樣性爲 0.1 。

輸入:大作文題幹 topic ,大作文總觀點general_view 期望的分數 expected_score 。


提示詞:

你是一個雅思作文寫作助手,請根據話題{{topic}}和大作文總觀點{{general_view}},撰寫大作文結尾段。要求:1. 用英文撰寫結尾段,英文用詞符合預期雅思得分{{expected_score}}。2. 結尾段寫一到兩句話,總結分論點,再次點明總觀點。範例:話題:Children are the target of a large amount of advertising today. Some people believe that this should be prohibited since it may harm children. To what extent do you agree or disagree?
總觀點:我認爲,廣告對兒童有害,我們應該禁止針對兒童的廣告。
分論點1:我認爲,兒童會被廣告所左右,因爲他們還不成熟。
分論點2:在我看來,廣告會損害兒童的健康成長環境。
結尾段:To conclude, it is important to ban advertising to children since it has a negative impacton both children's behavior and the environment in which they will grow.

輸出:String 類型的起始段 end_paragraph 。

8.結束節點

輸出:起始段節點 head_paragraph,展開段節點 detail_paragraph1 和 detail_paragraph2 ,結尾段節點 end_paragraph。

回覆模板:

開頭段:{{head_paragraph}}
展開段1:{{detail_paragraph1}}
展開段2:{{detail_paragraph2}}
結尾段:{{end_paragraph}}


整體節點流程圖如下:




Ai technology

雅思大作文助手組件調試

點擊調試,對整個流程圖進行調試驗證。

題幹 topic :

It is important for people to take risks, bothin their professional lives and their personal lives.Do you think the advantages of taking risks outweigh the disadvantages?

期望分數 expected_score:7

2.開始運行

撰寫總觀點:運行時間 2.155s;Token 消耗 143 Tokens。

{    "general_view": "總觀點輸出:我認爲,儘管承擔風險可能帶來一些不利因素,但其在個人和職業生活中的優勢明顯超過其劣勢。"}


撰寫分論點:運行時間 3.937s;Token 消耗 430 Tokens。

{    "viewpoint1": "承擔風險有助於個人成長和突破自我,提升個人能力和自信心。",

撰寫起始段:運行時間 3.526s;Token 消耗 290 Tokens。

{    "head_paragraph": "In today's world, individuals are frequently confronted with the need to take risks, whether in their professional pursuits or personal endeavors. However, I firmly believe that the benefits of embracing risk far outweigh the potential drawbacks."}

撰寫展開段:運行時間 18.548s;Token 消耗 778 Tokens。

{    "detail_paragraph1": "In the professional realm, taking risks often leads to innovation and creativity. When individuals are willing to stepout of their comfort zones, they are more likely to explore uncharted territories, which can result in groundbreaking ideas and solutions. For instance, entrepreneurs who take the leap to start their own businesses, despite the potential for failure, often reap the rewards of success and create job opportunities for others. Moreover, risk-taking encourages a culture of experimentation and learning, where failures are seen asvaluable lessons rather than setbacks.",    "detail_paragraph2": "On a personal level, embracing risks leads to personal growth and development. By pushing our boundaries, we gain new experiences and insights that enrich our lives. For example, traveling to a foreign country where one is not familiar with the language or culture can be initially daunting,butit ultimately broadens one's horizons and fosters a greater understanding of diversity. Similarly, taking risks in relationships, such as being vulnerable and open, can lead to deeper, more meaningful connections. While there is always a chance of disappointment or failure, the potentialfor personal transformation and fulfillment makes the risks worthwhile."}

撰寫結束段:運行時間 3.407s;Token 消耗 303 Tokens。

{    "end_paragraph": "In conclusion, while acknowledging the potentialdrawbacks of taking risks, it is evident that the benefits far outweighthese disadvantages. Encouraging individuals to embrace risk in both theirprofessional and personal lives fosters growth, innovation, and personaldevelopment, ultimately leading to a more fulfilling and successfulexistence."}

結束輸出:

{    "end_output": "開頭段:\nIn today's world, individuals are frequentlyconfronted with the need to take risks, whether in their professional pursuits or personal endeavors. However, I firmly believe that thebenefits of embracing risk far outweigh the potential drawbacks.\n\n展開段1:\nIn the professional realm, taking risks often leads to innovation andcreativity. When individuals are willing to step out of their comfortzones, they are more likely to explore uncharted territories, which canresult in groundbreaking ideas and solutions. For instance, entrepreneurswho take the leap to start their own businesses, despite the potential forfailure, often reap the rewards of success and create job opportunitiesfor others. Moreover, risk-taking encourages a culture of experimentationand learning, where failures are seen as valuable lessons rather thansetbacks.\n\n展開段2:\nOn a personal level, embracing risks leads topersonal growth and development. By pushing our boundaries, we gain newexperiences and insights that enrich our lives. For example, traveling toa foreign country where one is not familiar with the language or culturecan be initially daunting, but it ultimately broadens one'shorizons andfosters a greater understanding of diversity. Similarly, taking risks inrelationships, such as being vulnerable and open, can lead to deeper, moremeaningful connections. While there is always a chance of disappointmentor failure, the potential for personal transformation and fulfillmentmakes the risks worthwhile.\n\n結尾段:\nIn conclusion, while acknowledgingthe potential drawbacks of taking risks, it is evident that the benefitsfar outweigh these disadvantages. Encouraging individuals to embrace riskin both their professional and personal lives fosters growth, innovation, andpersonal development, ultimately leading to a more fulfilling and successful existence."}

3.發佈組件

點擊右上角發佈組件。



Ai technology

創建雅思大作文助手應用

1.AI自動生成配置 利用AI自動生成雅思大作文助手。

自動生成的雅思大作文助手如下:

2.應用調試

使用AI自動配置的內容,在對話框令應用生成雅思大作文,結果如下:

發現出現了點問題,輸出的內容爲中文,修改提示詞如下,再次提問輸出內容如下:

 可以看到輸出內容如下:

In today's world, individuals are frequently faced with the choice ofwhether to embrace risks in both their professional and personal pursuits.However, I firmly believe that the benefits of taking risks significantlyoutweigh the potential drawbacks, thus encouraging people to embrace aspirit of adventure.
Firstly, in the professional realm, risk-taking often leads to innovationand progress. When individuals are willing to venture outside theircomfort zones, they are more likely to stumble upon new ideas andsolutions that can revolutionize their fields. Entrepreneurs, forinstance, who take the plunge and start their own businesses, not onlystand to reap significant financial rewards but also contribute to jobcreation and economic growth. Additionally, risk-taking in one's careercan foster personal growth and development, enhancing their skill set andmarketability.
Moreover, in personal life, taking risks can yield profound benefits.Pursuing passions and dreams, often hindered by fear of the unknown, canlead to a more fulfilling and satisfying life. Traveling the world, forexample, can provide invaluable experiences and memories. Furthermore,risk-taking fosters resilience and strengthens one'character, teachingindividuals how to adapt and bounce back from adversity.
In conclusion, while acknowledging the existence of potential drawbacks,it is evident that the advantages of taking risks far outweigh thedisadvantages. Encouraging individuals to embrace risk in both theirprofessional and personal lives fosters growth, innovation, and personalfulfillment, ultimately leading to a more fulfilling and successfulexistence.


雅思大作文基本符合要求,雖然沒有直接輸出大作文組件內容,但是也能不錯的完成雅思大作文寫作要求。

3.發佈軟件 我在百度智能雲千帆AppBuilder開發了一款AI原生應用,快來使用吧!


「雅思大作文智能助手」掃碼快速體驗



Ai technology

總結

本次體驗了通過百度千帆 AppBuilder 的低代碼模式,通過工作流構建組件,創建應用。整體體驗下來,工作流模式的組件,能夠完成更強大、更有邏輯的工作。本次應用創建,只採用了大模型節點,沒有用到其他節點,實現的功能也是比較單一,之後還有優化空間。

實踐中也遇到了一些小問題,希望研發大大能夠改進一下:

每次創建節點時,都是從開始節點上方添加,而不是添加到當前畫面裏面或者自由放置,每次都得從前面拖過來,體驗不太好。可以改成點擊放置比較好。

希望輸入的參數名就是值,但是每次都得重新敲一遍,值那裏無法複製,有點麻煩。如果可以自動配置參數命就是值,後續可以修改就更好一點。


本文分享自微信公衆號 - 百度開發者中心(baidudev)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章