Created
August 6, 2025 01:10
-
-
Save pulipulichen/299c5d76841a6622c4c614b442ec3b5d to your computer and use it in GitHub Desktop.
Dify,OpenAI,Programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 看看網頁版全文 ⇨ 實作相容OpenAI API,但背後不是OpenAI的API服務 : Implementing OpenAI API-Compatible Services, But Not Powered by OpenAI | |
| https://blog.pulipuli.info/2025/08/implementing-openai-api-compatible-services-but-not-powered-by-openai.html | |
| 我們上次談到了不是背後說用到OpenAI模型的API不見得能相容OpenAI API,那我們這次就來做個能夠相容於OpenAI API的服務,但只會回答「喵」的「喵型語言模型」。 | |
| Last time we talked about how not all APIs that claim to use OpenAI models are necessarily compatible with the OpenAI API. This time, let's create a service compatible with the OpenAI API, but it only responds with "Meow." We'll call it the "Meow Language Model."。 | |
| ---- | |
| # 系統架構 / System Architecture。 | |
| 整個架構會由五個元件所組成: | |
| 1. Python程式碼:不管你傳送什麼資訊,它只會回「喵」。 | |
| 2. Dify:AI應用程式框架的Dify裡面,可以用Code節點讓我們執行這段Python程式碼,然後把它包裝成Chatflow API。 | |
| 3. dify2openai:fatwang2開發的dify2openai將Dify的API模擬成OpenAI API格式。 | |
| 4. Cloudflare Tunnel:將運作在本地的API服務連接到Cloudflare提供的臨時網址上。 | |
| 5. FastGPT:使用自製的OpenAI API。 | |
| # 程式碼 / Source Code | |
| https://github.com/pulipulichen/practice-Dify-OpenAI-API-2025.git。 | |
| 相關程式碼放在「practice-Dify-OpenAI-API-2025」保存庫裡面。 | |
| 這些程式碼是以Linux作業系統為主要環境,需要搭配Docker才能運作。 | |
| 這些程式碼並非給普通使用者執行,而是給開發者作為參考的資料。 | |
| 如果環境設置正確的話,執行 startup.sh 就能完成整個設定。 | |
| 以下概述整個系統中需要設定的關鍵部分。 | |
| ---- | |
| # 1. Python: Dify裡面的聊天流 / Python: The Chatflow in Dify。 | |
| 首先,我們在Dify中建立一個Chatflow,用來實作「喵型語言模型」。 | |
| ---- | |
| 繼續閱讀 ⇨ 實作相容OpenAI API,但背後不是OpenAI的API服務 : Implementing OpenAI API-Compatible Services, But Not Powered by OpenAI | |
| https://blog.pulipuli.info/2025/08/implementing-openai-api-compatible-services-but-not-powered-by-openai.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment