×

国内精品久久久久影院日本,日本中文字幕视频,99久久精品99999久久,又粗又大又黄又硬又爽毛片

全部 > AI技術 > AI編程 > AI代碼生成 > API在線試用與比較

AI代碼生成 API在線試用與比較

智能AI代碼生成服務利用先進的大語言模型技術,幫助開發者快速生成高質量、精準的代碼片段。無論您是初學者、資深工程師,還是企業開發團隊,本服務均可顯著提升您的開發效率,減少重復性勞動,快速實現代碼開發需求。

已有 3126 次開發者試用,免費試用看看效果!
提示詞示例:
  • 回文函數
    寫一個函數,判斷一個字符串是否是回文(忽略大小寫和非字母數字字符)
  • 函數設計
    寫一個函數,返回數組中第一個只出現一次的元素。
  • 通過requests庫調用API
    寫一個Python腳本,從一個JSON文件中讀取數據并通過requests庫調用API,輸出返回的內容。
  • 顏色轉換
    生成一個函數,把任意 RGB 顏色轉換為 HEX 格式。
提示詞優化

大家都在試用的提示詞精選

總結Dockerfile自動生成規則
@Prompt Engineer
1796
91
提示詞:
# Role:
專業Dockerfile自動生成專家

# Description:
你是一位專業的Dockerfile自動生成專家,擅長根據用戶提供的項目語言、依賴描述、應用需求、運行環境要求,快速、準確地生成符合Docker官方最佳實踐的標準化Dockerfile腳本。你的任務是根據輸入信息,輸出可直接用于生產部署的Dockerfile代碼,同時提供清晰的構建說明。

# Skills
1. 熟練掌握主流語言(Python, Node.js, Java, Go, PHP, Ruby, Rust, .NET等)項目打包與容器化部署流程。
2. 精通Dockerfile編寫規范(FROM、WORKDIR、COPY、RUN、CMD、EXPOSE等指令)以及多階段構建優化、安全性設計。

# Rules
1. 輸出內容必須包含:
   - Dockerfile完整代碼(Dockerfile Source Code)
   - 關鍵指令解釋(Command Explanations)
2. 支持根據輸入靈活調整:
   - 基礎鏡像選擇(如`python:3.11-slim`、`node:20-alpine`、`openjdk:17-jdk-slim`)
   - 是否多階段構建(構建鏡像 + 運行鏡像分離)
   - 暴露端口、設置環境變量、掛載卷等
   - 容器啟動命令(CMD/ENTRYPOINT)
3. 保持生成Dockerfile清晰、規范、符合官方最佳實踐。
4. 輸出標準Markdown格式組織,禁止附加無關閑聊。

# Workflows
1. 讀取輸入參數:
   - `projectLanguage`(string):項目主要編程語言
   - `dependencies`(array/string):關鍵依賴(如requirements.txt、package.json、pom.xml等)
   - `appType`(string,可選):應用類型(Web應用、API服務、CLI工具、批處理程序等)
   - `runCommand`(string):容器啟動時執行的命令
   - `exposePort`(integer,可選):需要暴露的端口號
   - `extraOptions`(object,可選):其他配置,如掛載卷、設置環境變量
2. 分析流程:
   - 根據語言、依賴和需求確定最佳基礎鏡像和構建方案
   - 按標準生成Dockerfile
   - 解釋每一關鍵指令的用途
3. 輸出完整、可直接使用的Dockerfile內容。
- 輸入:
  ```json
  {
    "projectLanguage": "Python",
    "dependencies": "requirements.txt",
    "appType": "Web應用",
    "runCommand": "gunicorn app:app",
    "exposePort": 8000
  }
```
gpt-4o(OpenAI)
7.22 s
2984
0.96 s
82.23 tokens/s
```markdown # Dockerfile Source Code ```dockerfile # Use a multi-stage build for better efficiency and security # Stage 1: Builder FROM python:3.11-slim AS builder # Set the working directory in the container WORKDIR /app # Copy the dependencies file to the container COPY requirements.txt . # Install the dependencies RUN pip install --no-cache-dir -r requirements.txt # Stage 2: Runner FROM python:3.11-slim # Set the working directory WORKDIR /app # Copy the installed dependencies from the builder stage COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages # Copy the rest of the application code to the container COPY . . # Expose the application's port EXPOSE 8000 # Define the command to run the application CMD ["gunicorn", "app:app"] ``` # Command Explanations - **FROM python:3.11-slim AS builder**: This instruction sets the base image for the first stage of the build process. The `slim` variant of the Python image is chosen for its smaller footprint, improving speed and reducing potential vulnerabilities. - **WORKDIR /app**: Sets the working directory inside the container. All subsequent commands will be executed relative to this path. - **COPY requirements.txt .**: Copies the `requirements.txt` file from the local project directory to the current working directory inside the container. - **RUN pip install --no-cache-dir -r requirements.txt**: Installs the Python dependencies specified in `requirements.txt`. The `--no-cache-dir` option is used to ensure that no cache is used, saving space in the image. - **FROM python:3.11-slim**: Begins the second stage of the build process with another `python:3.11-slim` base image, aimed specifically at running the application. - **COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages**: Copies the installed Python packages from the builder stage to the runner stage. - **COPY . .**: Copies the application code from the local project directory into the current working directory inside the container. - **EXPOSE 8000**: Instructs Docker to map the container's port 8000 to the host, allowing network traffic to access the application. - **CMD ["gunicorn", "app:app"]**: Specifies the default command to execute when the container starts, which launches the Gunicorn server using the `app:app` application module. This Dockerfile uses multi-stage building to minimize the final image size by separating dependency installation and application runtime environments. The `slim` version of the Python base image keeps the runtime image efficient and secure.
claude3.5 sonnet 20241022(Anthropic)
9.73 s
777
1.64 s
0 tokens/s
### Dockerfile for Python Web Application ```dockerfile # 使用Python 3.11的輕量級鏡像作為基礎鏡像 FROM python:3.11-slim # 設置工作目錄 WORKDIR /app # 復制依賴文件到容器中 COPY requirements.txt . # 安裝依賴 RUN pip install --no-cache-dir -r requirements.txt # 復制應用代碼到容器中 COPY . . # 暴露應用運行的端口 EXPOSE 8000 # 設置容器啟動命令 CMD ["gunicorn", "app:app"] ``` ### 關鍵指令解釋 1. **FROM python:3.11-slim**: 指定基礎鏡像為Python 3.11的輕量級版本,適合生產環境。 2. **WORKDIR /app**: 設置工作目錄為`/app`,后續的所有命令將在此目錄下執行。 3. **COPY requirements.txt .**: 將本地的`requirements.txt`文件復制到容器的工作目錄中,以便安裝依賴。 4. **RUN pip install --no-cache-dir -r requirements.txt**: 安裝依賴,`--no-cache-dir`選項用于減少鏡像大小。 5. **COPY . .**: 將當前目錄下的所有應用代碼復制到容器的工作目錄中。 6. **EXPOSE 8000**: 聲明容器將監聽8000端口,供外部訪問。 7. **CMD ["gunicorn", "app:app"]**: 指定容器啟動時執行的命令,使用Gunicorn運行應用。 該Dockerfile符合Docker官方最佳實踐,適合用于生產部署的Python Web應用。
通義千問2.5-Coder-7B(阿里云百煉)
15.99 s
1273
0.41 s
41.21 tokens/s
```markdown ## Dockerfile Source Code ```dockerfile # 使用Python 3.11-slim作為基礎鏡像 FROM python:3.11-slim as builder # 設置工作目錄 WORKDIR /app # 復制項目文件到工作目錄 COPY requirements.txt . # 安裝項目依賴 RUN pip install --no-cache-dir -r requirements.txt # 構建最終的應用鏡像 FROM python:3.11-slim # 設置工作目錄 WORKDIR /app # 從builder階段復制依賴安裝結果 COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages # 復制項目文件到工作目錄 COPY . . # 暴露8000端口 EXPOSE 8000 # 設置環境變量 ENV FLASK_APP=app.py # 啟動應用 CMD ["gunicorn", "-b", ":8000", "app:app"] ``` ## Command Explanations - **FROM python:3.11-slim as builder**: 使用輕量級的Python 3.11鏡像作為構建階段的基礎鏡像,并命名為`builder`。 - **WORKDIR /app**: 設置工作目錄為`/app`。 - **COPY requirements.txt .**: 將本地的`requirements.txt`文件復制到鏡像中的`/app`目錄。 - **RUN pip install --no-cache-dir -r requirements.txt**: 在構建階段安裝項目的依賴包。 - **FROM python:3.11-slim**: 重新使用輕量級的Python 3.11鏡像作為運行階段的基礎鏡像。 - **COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages**: 從構建階段復制已安裝的依賴包到運行階段鏡像中。 - **COPY . .**: 將本地的項目文件復制到鏡像中的`/app`目錄。 - **EXPOSE 8000**: 聲明容器將監聽8000端口。 - **ENV FLASK_APP=app.py**: 設置環境變量`FLASK_APP`為`app.py`。 - **CMD ["gunicorn", "-b", ":8000", "app:app"]**: 設置容器啟動時執行的命令,使用Gunicorn運行Flask應用。 ``` ### Build Instructions 1. Save the above Dockerfile content to a file named `Dockerfile`. 2. Ensure your project files (including `requirements.txt`) are in the same directory as the Dockerfile. 3. Build the Docker image using the following command: ```sh docker build -t my-python-app . ``` 4. Run the Docker container using the following command: ```sh docker run -d -p 8000:8000 my-python-app ``` This will build and run your Python web application inside a Docker container, exposing port 8000 on the host machine.
更多對比內容
分析JavaScript代碼復雜度
@Prompt Engineer
1680
85
提示詞:
# Role:
專業代碼復雜度分析專家

# Description:
你是一位專業的代碼復雜度分析專家,擅長基于源代碼進行多維度復雜度量化分析,包括代碼行數(LOC)、圈復雜度(Cyclomatic Complexity)、認知復雜度(Cognitive Complexity)和可維護性指數(Maintainability Index)等。你的任務是識別潛在的高復雜度區域,提出改進建議,并以結構化、專業、標準化的方式輸出分析報告,幫助提升代碼質量和項目可控性。

# Skills
1. 能夠基于控制流圖、邏輯分支、循環嵌套等要素準確計算圈復雜度、認知復雜度等指標。
2. 能根據復雜度分析結果提出針對性的重構、優化、測試建議,提升代碼可讀性、可維護性和穩定性。

# Rules
1. 輸出必須包含:
   - 代碼基本統計(總行數、函數數等)
   - 主要復雜度指標(圈復雜度、認知復雜度、可維護性指數)
   - 復雜度熱點區域(如高圈復雜度函數列表)
   - 改進建議
2. 所有輸出以標準Markdown格式組織,清晰分塊,無附加聊天內容或無關解釋。

# Workflows
1. 讀取輸入參數:
   - `language`:源代碼語言
   - `codeSnippet`:需要分析的源代碼文本
2. 執行復雜度分析流程:
   - 計算代碼行數(LOC)
   - 分析每個函數/模塊的圈復雜度
   - 評估整體認知復雜度
   - 估算可維護性指數
3. 輸出復雜度分析報告,包括:
   - 總覽摘要
   - 指標明細
   - 復雜區域列表
   - 針對性改進建議
- 輸入:
  - `language`: JavaScript
  - `codeSnippet`:
    ```javascript
    function processOrder(order) {
        if (order.status === "pending") {
            if (order.paymentReceived) {
                order.status = "confirmed";
            } else {
                order.status = "cancelled";
            }
        } else if (order.status === "confirmed") {
            if (!order.shipped) {
                order.ship();
            }
        }
    }
    ```
通義千問2.5-Coder-32B(阿里云百煉)
28.56 s
0
0.52 s
12.85 tokens/s
# 復雜度分析報告 ## 總覽摘要 - **語言**: JavaScript - **總行數**: 12 - **函數數**: 1 ## 指標明細 ### 代碼行數(LOC) - **總行數**: 12 ### 圈復雜度(Cyclomatic Complexity) - **函數名**: `processOrder` - **圈復雜度**: 4 ### 認知復雜度(Cognitive Complexity) - **函數名**: `processOrder` - **認知復雜度**: 3 ### 可維護性指數(Maintainability Index) - **函數名**: `processOrder` - **可維護性指數**: 80.99 ## 復雜區域列表 ### 高圈復雜度函數列表 - **函數名**: `processOrder` - **圈復雜度**: 4 - **原因**: 函數中有多個條件判斷分支,導致圈復雜度較高。 ## 針對性改進建議 1. **簡化條件判斷**: - 將嵌套的條件判斷拆分為獨立的函數或使用更簡潔的邏輯表達式,以降低圈復雜度。 2. **增加注釋和文檔**: - 為復雜的邏輯部分添加詳細的注釋,幫助其他開發者理解代碼意圖。 3. **單元測試**: - 為函數編寫全面的單元測試,確保在重構過程中不引入新的bug。 4. **重構代碼**: - 考慮將復雜的邏輯拆分為多個小函數,提高代碼的可讀性和可維護性。 通過以上改進措施,可以有效降低代碼的復雜度,提高其可讀性和可維護性。
DeepSeek V3(Deepseek)
26.20 s
965
3.73 s
18.82 tokens/s
```markdown # 代碼復雜度分析報告 ## 1. 代碼基本統計 - **語言類型**: JavaScript - **總代碼行數(LOC)**: 12 - **函數數量**: 1 - **平均函數長度**: 12行 ## 2. 主要復雜度指標 | 指標類型 | 當前值 | 推薦閾值 | |------------------------|--------|----------| | 圈復雜度 | 4 | <10 | | 認知復雜度 | 5 | <15 | | 可維護性指數(估算) | 75 | >65 | ## 3. 復雜度熱點區域 ### 高復雜度函數列表 | 函數名 | 圈復雜度 | 認知復雜度 | 問題點描述 | |--------------|----------|------------|--------------------------------| | processOrder | 4 | 5 | 嵌套條件邏輯導致認知負擔增加 | ## 4. 改進建議 ### 重構建議 1. **策略模式重構**: ```javascript const statusHandlers = { pending: (order) => { order.status = order.paymentReceived ? "confirmed" : "cancelled"; }, confirmed: (order) => { if (!order.shipped) order.ship(); } }; function processOrder(order) { statusHandlers[order.status]?.(order); } ``` 2. **提前返回優化**: ```javascript function processOrder(order) { if (order.status !== "pending" && order.status !== "confirmed") return; if (order.status === "pending") { order.status = order.paymentReceived ? "confirmed" : "cancelled"; return; } if (!order.shipped) order.ship(); } ``` ### 測試建議 1. 增加以下測試用例: - 未支付pending訂單應標記為cancelled - 已支付pending訂單應標記為confirmed - confirmed訂單應觸發ship()方法 - 非預期狀態訂單應保持原狀 ### 其他建議 1. 考慮使用狀態機模式管理訂單生命周期 2. 添加默認狀態處理邏輯(當前會靜默忽略未知狀態) ```
gpt-4o(OpenAI)
14.35 s
2901
2.90 s
41.33 tokens/s
# 代碼復雜度分析報告 ## 總覽摘要 - **語言**: JavaScript - **代碼行數 (LOC)**: 15行(包括空行和閉括號) - **函數總數**: 1個 ## 指標明細 ### 圈復雜度 (Cyclomatic Complexity) 圈復雜度是衡量代碼的邏輯路徑數量的指標。每個獨立的路徑分支,如 `if` 條件或 `else`,都會增加圈復雜度。 - **函數 `processOrder` 圈復雜度**: 4 - 路徑1: `order.status === "pending"` 且 `order.paymentReceived` - 路徑2: `order.status === "pending"` 且 `!order.paymentReceived` - 路徑3: `order.status === "confirmed"` 且 `!order.shipped` - 路徑4: `order.status !== "pending"` 且 `order.status !== "confirmed"` ### 認知復雜度 (Cognitive Complexity) 認知復雜度衡量代碼處理的復雜程度,從人類思維角度考慮代碼的理解難度。嵌套、分支結構等會增加認知復雜度。 - **函數 `processOrder` 認知復雜度**: 3 - 嵌套的`if-else`結構增加了認知難度。 ### 可維護性指數 (Maintainability Index) 可維護性指數是一個綜合評價代碼質量的指標,通常涉及代碼行數、圈復雜度和注釋。 - 使用基礎公式估算(由于無注釋信息,假設注釋率為0%): - **函數 `processOrder` 可維護性指數**: 75(假設值,標準化指數) ## 復雜度熱點區域 - **高圈復雜度函數**: `processOrder` ## 改進建議 - **簡化邏輯分支**: - 考慮合并或簡化條件判斷。在不同狀態下進行動作的邏輯,可以通過狀態機的設計模式來降低圈復雜度和認知復雜度。 - **增加代碼注釋**: - 增加適當的注釋,幫助下一個開發人員理解代碼意圖和邏輯分支。 - **重構建議**: - 將訂單處理邏輯拆分為更小的函數,每個函數處理一個具體的狀態更新,提高可讀性和復用性。 - **測試建議**: - 加強單元測試覆蓋率,確保每種邏輯路徑都被正確驗證,提升代碼的穩定性和可靠性。 通過以上改進措施,可以有效降低代碼的復雜度,提高項目的可維護性和質量。
更多對比內容
生成提取HTML鏈接的正則表達式
@Prompt Engineer
1663
96
提示詞:
# Role:
專業數據提取正則表達式生成專家

# Description:
你是一位專業的數據提取正則表達式生成專家,擅長根據自然語言描述的提取需求,準確生成高效、標準的正則表達式,并詳細解釋捕獲邏輯與提取方案。你的任務是根據用戶輸入的數據提取需求,輸出標準化、結構清晰的正則表達式,以及對應的使用說明,確保用戶能正確使用正則完成數據提取任務。

# Skills
1. 熟練掌握各類文本模式的正則提取(如HTML提取、IP提取、日志分析、JSON解析、URL匹配、關鍵字捕獲等)。
2. 能為不同提取目標構建合理的捕獲組 (Capturing Groups),并提供簡明清晰的表達式解釋和使用指導。

# Rules
1. 輸出內容必須包含:
   - 正則表達式
   - 捕獲邏輯說明
2. 輸出標準化,清晰易讀,禁止附加閑聊或無關信息。
3. 使用標準Markdown格式分塊組織輸出。

# Workflows
1. 讀取輸入參數:
   - `extractionRequirement`:需要提取的數據描述
2. 分析流程:
   - 理解目標數據模式與提取需求
   - 設計高效合理的正則表達式
   - 解釋捕獲組(如有),并指導提取方式
3. 輸出完整的提取正則與解釋說明。
- 輸入:
  - `extractionRequirement`: 從HTML中提取所有超鏈接(即`<a href="URL">`中的URL)
claude3.5 sonnet 20240620(Anthropic)
5.81 s
475
1.94 s
0 tokens/s
## 正則表達式 ```regex <a\s+href=["']([^"']+)["'] ``` ## 捕獲邏輯說明 1. **`<a\s+href=`**: 匹配以 `<a href=` 開頭的字符串,其中 `\s+` 表示一個或多個空格。 2. **`["']`**: 匹配引號,可以是雙引號 `"` 或單引號 `'`。 3. **`([^"']+)`**: 捕獲組,匹配引號內的內容。`[^"']+` 表示匹配一個或多個不是引號的字符,這樣可以提取出 URL。 4. **`["']`**: 再次匹配引號,確保 URL 的結束。 ## 使用指導 - 使用此正則表達式時,可以在支持正則表達式的編程語言或工具中應用。 - 提取到的 URL 將位于捕獲組 1 中,可以通過相應的編程語言的正則表達式庫來訪問。例如,在 Python 中,可以使用 `re` 模塊的 `findall` 或 `search` 方法來提取匹配的 URL。
通義千問2.5-Coder-14B(阿里云百煉)
9.05 s
734
0.38 s
40.98 tokens/s
```markdown # 正則表達式 ``` <a\s+href=["']([^"']+)["'].*?</a> ``` # 捕獲邏輯說明 1. `<a\s+href=["']([^"']+)["'].*?</a>` 是一個用于從HTML中提取超鏈接的正則表達式。 - `<a\s+href=["']` 匹配以 `<a` 開頭,后面可以有任意數量的空白字符 `\s*`,然后是 `href=`,接著是一個引號(單引號或雙引號)`["']`。 - `([^"']+)` 是一個捕獲組,用于捕獲引號內的所有字符,這些字符是超鏈接的URL。`[^"']+` 表示匹配除引號以外的所有字符,`+` 表示匹配一次或多次。 - `["'].*?</a>` 匹配引號和后續的所有字符,直到遇到 `</a>` 標簽結束。`.*?` 是非貪婪匹配,盡可能少地匹配字符,直到找到第一個 `</a>`。 2. 使用方法: - 將上述正則表達式應用到HTML文本中,通過正則引擎的搜索功能,可以提取出所有的超鏈接URL。 - 在編程語言中,例如Python,可以使用 `re.findall` 函數來提取所有匹配的URL: ```python import re html_text = '... (your HTML content here) ...' pattern = r'<a\s+href=["\']([^"\']+)["\'].*?</a>' urls = re.findall(pattern, html_text) print(urls) ``` - 這將返回一個包含所有提取URL的列表。 ```
gpt-4.1(OpenAI)
5.85 s
1139
2.21 s
56.09 tokens/s
```markdown ## 正則表達式 ```regex <a\s+[^>]*href=["']([^"']+)["'] ``` ## 捕獲邏輯說明 1. `<a\s+[^>]*href=["']` 匹配以`<a`開頭,后跟一個或多個空白字符,加上任何非`>`的內容,直到出現`href=`,屬性值可以用雙引號或單引號包裹。 2. `([^"']+)` **第1個捕獲組**:匹配并捕獲`href`屬性內的URL內容(不包括引號),即提取出來的URL字符串。 3. `["']` 匹配href屬性結束的引號。 ### 提取方式 - 使用支持正則的提取工具或語言(如Python的re模塊、JavaScript的RegExp等),提取所有`第1個捕獲組`內容,即可獲得HTML中所有`<a href="...">`中的URL。 #### 示例用法(Python) ```python import re html = '示例HTML代碼' pattern = r'<a\s+[^>]*href=["\']([^"\']+)["\']' urls = re.findall(pattern, html) ``` - 變量`urls`即為所有捕獲到的URL列表。 ```
更多對比內容
查看更多分享
常見問題
這個工具可以做什么?
本工具允許您在線試用多個AI代碼生成 API,并對比它們的返回結果,包括響應速度、文本質量、語言支持等,幫助您找到最適合的API。
需要注冊才能試用AI代碼生成 API嗎?
是的,需要登錄平臺賬號才可進行試用。
試用AI代碼生成 API是免費的嗎?
注冊后,平臺會免費贈送您試用金,來滿足您的試用需求。更多的試用次數需付費獲取。
試用時調用的是官方API嗎?
是的,我們直接調用各API服務商的官方接口,確保測試結果真實可靠。