...
準備你的 python code
儲存 id, names, descriptions 以及對應的 python code 放到 plugin.json 中
程式碼區塊 language pyjson { "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": "print('Hello World')" } } }
內建 global variable
global variable | 用途 | 使用範例 |
---|---|---|
PLUGIN_USER_COOKIE | 用來辨識使用者身分 | |
CURRENT_CONVERSATION | 單一對話中的所有訊息 | |
SELECTED_MODEL_TOKEN_LIMIT | 當下 Model 的對應 token limit | 可和 count_token function 一併使用,確保對話過程不會超出 Model 限制 |
SELECTED_FILES | 對話中所選取的對應 DVCx 檔資訊 |
讀取第 1 個 DVCx 檔案的 subject 資訊
SELETED_FILES 包含以下參數:
假如需要讀取檔案內容,您可以透過以下實作取得:
| |||||||
CUSTOMIZED_PARAMS | 如果你是從 assistants-api + plugin-api 使用 python plugin 的話,可以使用這參數讀取 plugin-api 傳進來的客製化參數 |
|
內建 Function
Function name | 用途 | 使用範例 |
---|---|---|
chat | 使用 DaVinci 內建的 Model 送出 prompt | |
count_token | 計算文字會使用多少 token | 可和 SELECTED_MODEL_TOKEN_LIMIT 一併使用,確保對話過程不會超出 Model 限制 |
emb | 使用 DaVinci 內建的 embedding 功能針對文字進行 embedding 操作 |