已比較的版本

索引鍵

  • 此行已新增。
  • 此行已移除。
  • 格式已變更。

...

global variable

用途

使用範例

PLUGIN_USER_COOKIE

用來辨識使用者身分

image-20240204-164357.png

CURRENT_CONVERSATION

單一對話中的所有訊息

image-20240204-164738.png

SELECTED_MODEL_TOKEN_LIMIT

當下 Model 的對應 token limit

可和 count_token function 一併使用,確保對話過程不會超出 Model 限制

image-20240204-170841.png

SELECTED_FILES

對話中所選取的對應 DVCx 檔資訊

SELETED_FILES 包含以下參數:

  1. "title": 檔案名稱

  2. "type": 檔案的副檔名

  3. "subject": 檔案路徑

假如需要讀取檔案內容,您可以透過以下實作取得:

程式碼區塊
languagepy
with open(SELECTED_FILES[i]['subject']) as f:
  print(f.read())
  • 請注意:這裡的 index i 代表的是在Plugin 使用者的達哥中,所有勾選檔案中排序的第一個,您可以以此類推至其他 index

CUSTOMIZED_PARAMS

如果你是從 assistants-api + pluugin-api 使用 python plugin 的話,可以使用這參數讀取 plugin-api 傳進來的客製化參數

程式碼區塊
languagejson
{
    "id": "HelloWorld",
    "schema_version": "v1",
    "name_for_human": "HelloWorld",
    "name_for_model": "HelloWorld",
    "description_for_human": "HelloWorld",
    "description_for_model": "Say hello",
    "auth": {
        "type": "none"
    },
    "api": {
        "type": "python",
        "python": {
            "source": "import json\nprint(f'Hello developer, here is your param: {CUSTOMIZED_PARAMS}')"
        }
    }
}

內建 Function

Function name

用途

使用範例

chat

使用 DaVinci 內建的 Model 送出 prompt

image-20240204-165154.png

count_token

計算文字會使用多少 token

可和 SELECTED_MODEL_TOKEN_LIMIT 一併使用,確保對話過程不會超出 Model 限制

image-20240204-170841.png

emb

使用 DaVinci 內建的 embedding 功能針對文字進行 embedding 操作

image-20240204-165728.png

...