匯入 LangGraph 應用程式
本逐步說明會匯入 LangGraph 應用程式的設定——一個回答客戶訂單問題的圖——並為 Docker Compose 建置該應用程式。匯入會草擬建置所讀取的每個檔案:圖、其檢查點器保存狀態所用的 PostgreSQL 資料庫、它所呼叫的模型、以變數參照表示的密碼與金鑰,以及各自的實現。它只詢問一次沒有任何設定保存的兩個值:圖的程式碼所呼叫的模型,以及應用程式執行所用的映像檔。下方的每個檔案與每段輸出都來自真實執行;該設定與逐步說明的每個階段都在 import-langgraph 範例中,其中的檢查指令碼會再次執行匯入,將其寫出的內容、印出的內容,以及本頁引用的區塊與該處保存的檔案比對,並驗證與建置匯入所寫出的內容。
草擬範例
你可以用本頁的命令執行這個匯入,或是讓你的 AI 助理替你執行。
把範例寫入一個以它命名的新資料夾:
aggrega draft --example import-langgraph接著它會印出下一步要執行的命令。第一個切換到新資料夾;其後的那一個(見下方)切換到它的 source 資料夾,其中存放本頁所匯入的內容,也是匯入執行的位置:
cd import-langgraph
專案
LangGraph 應用程式將其圖保存在程式碼中,並在 langgraph.json(LangGraph 命令列工具的設定檔)中宣告它們。這個為本逐步說明撰寫的檔案,宣告了一個圖 support,以該圖在應用程式程式碼中的匯入路徑與一段說明表示:
{ "$schema": "https://langgra.ph/schema.json", "dependencies": ["."], "python_version": "3.12", "graphs": { "support": { "path": "./src/support_agent/graph.py:graph", "description": "Answers a question from a customer about their order, and hands it to a person when it cannot." } }}匯入會讀取 langgraph.json,而從不讀取應用程式的程式碼,所以範例只保存設定。它旁邊的 .aggrega-config.yaml 讓該資料夾成為工作區:
# The workspace key marks this directory as the workspace root, so an import run# here writes its drafts beside langgraph.json.workspace: {}# The registry the importer is fetched from the first time an import needs it.default_registry: hub.aggrega.ai匯入會參照目錄的 LangGraph 代理程式、PostgreSQL 與 OpenAI 模型 Components,而 --target 會從其 Recipes 草擬 Manifest。工作區沒有指定目錄資料夾,所以匯入會從它取得匯入器的登錄庫讀取標準程式庫目錄:那是已發布目錄的簽署快照,由第一次匯入取得、驗證並保存在工作區的內容快取中,並以其摘要記載於匯入寫在草稿旁的記錄中。若工作區在 AGGREGA_CATALOG_DIRS 或 workspace.catalog_dirs 之下指定了自己的目錄資料夾,則會先讀取那些資料夾,再讀取其後的已發布快照。
匯入要詢問什麼
LangGraph 設定沒有指名模型,因為由圖的程式碼選擇它,也沒有指名映像檔,因為該映像檔是你從專案建置的。所以匯入兩者都會詢問:圖所呼叫之模型的名稱,用於它所草擬的 OpenAI 模型,以及應用程式執行所用的映像檔。在終端機中它會詢問,並將答案寫入草稿,以及寫入它所匯入之目錄內的答案檔 import-answers.yaml——這裡是專案的根目錄 .——所以下一次匯入會從那裡讀取它們而不再詢問。沒有終端機時——在持續整合中,或透過管線——它不會詢問任何東西:它會寫出鍵為空白的該檔案,並停止:
2 values the drafts leave empty are still owed, listed in the answers file <workspace>/import-answers.yaml: write each beside its key there, then run the import again範例已經保存了該檔案,並已回答:圖呼叫 OpenAI 的 gpt-4o-mini,而 ghcr.io/example/support-agent:1.0.0 代表你所建置的映像檔:
# Values the import could not draft from the source, keyed by the drafted file and the key path inside# it. Write each one beside its key; an import of the same source, and a sync, read them from here and# ask nothing. A secret is never written here: its key asks where the secret comes from — a variable# name, ${NAME}, or the name of a Kubernetes Secret.aggregate.yaml: # Left for the author, since the configuration names no model: values.model, the name of the model # core/ai-model/openai serves. spec.components.model.values.model: "gpt-4o-mini"release.yaml: # Container image running the LangGraph application code. The Docker Compose Recipe runs the catalog's # quickstart agent when it is unset. spec.components.support.infra.image: "ghcr.io/example/support-agent:1.0.0" # The origin of the secret value, written by the operator in the Release. Read exactly as # values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes # from, never the value. spec.components.support.uses.checkpointer_db.postgres.features.credential.infra.origin: "support-db-password" # The origin of the secret value, written by the operator in the Release. Read exactly as # values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes # from, never the value. spec.components.support.uses.model.model.features.credential.infra.origin: "openai-api-key" # The origin of the secret value, written by the operator in the Release. Read exactly as # values.origin is. Write it here or in values.origin, never in both. A secret: name where it comes # from, never the value. spec.components.postgres.features.password.infra.origin: "support-db-password"三個 origin 答案用於 Kubernetes 的建置,使用 --target helm:在那裡資料庫的密碼與 OpenAI 金鑰是從 Kubernetes Secret 讀取,而每個答案都是 Secret 的名稱——資料庫的密碼來自 support-db-password,兩端皆然,金鑰來自 openai-api-key——絕不是密碼或金鑰本身。Docker Compose 的建置改為從你的 shell 讀取它們,所以這次匯入不使用那些答案。匯入答案檔說明了該檔案、問題,以及機密答案的規則。
aggrega import 列出該命令接受的每個旗標,其中包括 --answers,它可指名保存在別處的答案檔。
切換到 source:
cd source執行匯入
指名應用程式的目錄。匯入會讀取其 langgraph.json,而不讀取它的其他任何檔案:
aggrega import . --target compose在標準輸出上,它會列出所寫出的內容:
wrote aggregate.yamlwrote release.yamlwrote manifest.yamlwrote .aggrega-import.json在標準錯誤上,其中 <workspace> 代表你執行它所在的資料夾:
[… omitted: a warning that the importer runs unverified, printed where its module is read from beside its Plugin entity in a catalog folder rather than fetched]read as the langgraph format, with drafted paths relative to <workspace>info: the answers file <workspace>/import-answers.yaml also answers spec.components.postgres.features.password.infra.origin in release.yaml, spec.components.support.uses.checkpointer_db.postgres.features.credential.infra.origin in release.yaml, spec.components.support.uses.model.model.features.credential.infra.origin in release.yaml, which these drafts do not leave empty; those answers are kept there and not appliedmapped support (graph) to core/ai-agent/langgraph as a reference, NONEmapped checkpointer (checkpointer) to core/datastore/postgres as a reference, NONEmapped model (model) to core/ai-model/openai as a reference, NONEPull complete: <workspace>/release.lock (entities=10, source_artifacts=0, external_inputs=0)
info那一行指出 Docker Compose 草稿不使用的答案,它們被保存在答案檔中,供針對 Kubernetes 的建置使用。mapped行說明圖是標準程式庫 LangGraph 代理程式core/ai-agent/langgraph的一個實例;其檢查點器,也就是 LangGraph 保存每個圖之狀態的地方,是core/datastore/postgres的一個實例,因為設定沒有指名檢查點器,而 LangGraph 此時會將狀態保存在 PostgreSQL 中;而每個圖所呼叫的模型是core/ai-model/openai的一個實例。它們的階層顯示為NONE:LangGraph 匯入是依設定所宣告的內容參照這些 Components,而不是將每個與目錄比對權衡。checkpointer.backend為mongo的設定,會以core/datastore/ferretdb草擬,它使用 MongoDB 的通訊協定,位於core/datastore/documentdb之上,兩者的連接方式與目錄的 FerretDB Aggregate 連接它們的方式相同,兩者使用同一個密碼。Pull complete那一行是匯入在擷取草擬 Release 所依賴的內容,就像aggrega pull所做的那樣,寫入release.lock,讓草稿立即就能驗證與建置。在--offline下,匯入不拉取任何東西,並指出該執行的aggrega pull。
它寫出什麼
Aggregate、Release 與 Manifest 都命名為 imported/support,取自 langgraph.json 所提供的那一個圖 support,因為設定本身不帶名稱——提供多個圖的設定則以其檔案命名,或在如此處匯入被給予其目錄時,以其目錄命名——位於匯入器的 target_namespace 設定所指定的命名空間之下,除非你另行設定,否則為 imported(Settings)。
aggregate.yaml——圖、它保存狀態的資料庫與它所呼叫的模型,每個連線都宣告它所出示的認證,開頭的註解說明了讀取了什麼與沒有讀取什麼:
# LangGraph configurations read:# - langgraph.json# Not read: the application's code, which defines each graph; it runs in the image the Release names for each graph.# Not carried, since they configure the server image langgraph build builds, and the image the Release names is the application's own: dependencies, python_version.apiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: imported/support version: 0.1.0 description: Draft Aggregate imported from a source in the langgraph format.spec: components: support: type: core/ai-agent/langgraph values: graph_entrypoint: "./src/support_agent/graph.py:graph" description: "Answers a question from a customer about their order, and hands it to a person when it cannot." uses: checkpointer_db: postgres: target: postgres # For the compose target, the lines below declare credential on postgres: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none. features: credential: type: core/secret-value values: key: POSTGRES_PASSWORD model: model: target: model # For the compose target, the lines below declare credential on model: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none. features: credential: type: core/secret-value values: key: OPENAI_API_KEY # The database the configuration's checkpointer keeps each graph's state in, PostgreSQL. postgres: type: core/datastore/postgres features: # For the compose target, the lines below declare password on postgres: a secret the Release alone attaches arrives under the key value, so each is declared with a key of its own and no two arrive under one; the Release attaches its origin, naming this type or none. password: type: core/secret-value values: key: POSTGRES_PASSWORD # The model every graph calls, which the configuration does not name. model: type: core/ai-model/openai values: # Left for the author, since the configuration names no model: values.model, the name of the model core/ai-model/openai serves. model: "gpt-4o-mini"graph_entrypoint 是設定所寫的圖的匯入路徑。其 checkpointer_db 連線連接到資料庫,其 model 連線連接到模型,模型名稱是匯入從 import-answers.yaml 讀取的答案。recursion_limit 沒有寫出,所以沿用 Component 的預設值 25。資料庫取得一個密碼,所以 PostgreSQL Recipe 不會自行寫入任何密碼,而圖在其對資料庫的連線上出示同一個密碼。
release.yaml——環境、映像檔、發布的連接埠,以及金鑰與密碼的來源,圖上方的註解說明它的映像檔是什麼,以及交給它的內容:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: imported/support # environment is a drafted default, since no source names the environment this Release deploys to; change it to name the one it deploys to. environment: development version: 0.1.0 description: Draft Release imported from a source in the langgraph format.spec: aggregate: imported/support manifest: imported/support components: # Each graph's image is the application's own, not the server image langgraph build builds: its code, with LangGraph installed. # It is handed, for its code to read, the graph to run as LANGGRAPH_GRAPH_ENTRYPOINT, the model's name as OPENAI_MODEL, the checkpointer store's host and port as LANGGRAPH_CHECKPOINTER_HOST and LANGGRAPH_CHECKPOINTER_PORT, its user and database, where the store publishes them, as LANGGRAPH_CHECKPOINTER_USER and LANGGRAPH_CHECKPOINTER_DATABASE, and a password attached on the checkpointer_db connection as LANGGRAPH_CHECKPOINTER_PASSWORD. # It is also handed the model's address as OPENAI_BASE_URL and a key attached on the model connection as OPENAI_API_KEY, which the OpenAI client library reads, and recursion_limit as LANGGRAPH_DEFAULT_RECURSION_LIMIT, which LangGraph reads. # An inject: block on the graph's own instance, through an entry reading graph_entrypoint alone, replaces LANGGRAPH_GRAPH_ENTRYPOINT with the name it writes; one on the model connection replaces OPENAI_MODEL, and one on the checkpointer_db connection the store's host, port, user and database, with the names it writes. support: infra: # Left for the Release, since the source cannot supply it: infra.image, the container image running the application image: "ghcr.io/example/support-agent:1.0.0" # Published on this machine's loopback address, 127.0.0.1: reachable from this machine only, by any process running on it. Delete this line to keep the service internal. published_port: 8000 uses: checkpointer_db: postgres: features: credential: type: core/secret-value infra: # Attached by reference, never as a value: the credential support presents to postgres on its checkpointer_db connection, the password of postgres (the configuration names no variable for it), read from the variable POSTGRES_PASSWORD, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value. origin: "${POSTGRES_PASSWORD}" model: model: features: credential: type: core/secret-value infra: # Attached by reference, never as a value: the credential support presents to model on its model connection (the source names no variable for it, so it is read from the one OpenAI's client libraries read the API key from), read from the variable OPENAI_API_KEY, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value. origin: "${OPENAI_API_KEY}" postgres: features: password: type: core/secret-value infra: # Attached by reference, never as a value: the password of postgres (the configuration names no variable for it), read from the variable POSTGRES_PASSWORD, which a target substituting variable references, as Docker Compose does when the stack starts, reads from the environment, so no file carries the value. origin: "${POSTGRES_PASSWORD}" model: {}環境 development 是匯入寫入的預設值,因為沒有任何設定指名環境;若 Release 部署到其他地方,請變更它。映像檔是匯入從 import-answers.yaml 讀取的答案。圖發布在你機器的回送位址上,連接埠 8000,轉送到其程式監聽的連接埠 infra.port,除非你另行設定,否則為 8000。金鑰與密碼是變數參照 ${OPENAI_API_KEY} 與 ${POSTGRES_PASSWORD},絕不是值。
manifest.yaml——每個型別的 Compose Recipe,以及將每個變數參照依原樣寫入 Compose 檔案的實現:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: imported/support version: 0.1.0spec: mappings: components: type: core/ai-agent/langgraph: compose/langgraph core/datastore/postgres: compose/postgres core/ai-model/openai: compose/openai features: type: core/secret-value: compose/dotenv-secretrelease.lock 以摘要記錄 Release 所解析到的目錄實體,而 .aggrega-import.json 是匯入所寫內容的記錄,之後的 aggrega import --sync 會讀取它。
驗證並建置
aggrega validate --release release.yamlaggrega build --release release.yaml

驗證會印出:
notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)release dependency validation passed: release.yaml (schema-pillar + dependency pillars)而建置(其中 <workspace> 代表你執行它所在的資料夾)會印出:
notice: LINT: Feature "core/secret-value" at core/secret-value:1.0.0 declares property "origin" in both values: and infra: pillars (path: origin)[… omitted: a total build time, which differs per run]Build completed: 1 file written to <workspace>/distnotice 那一行僅供參考:機密 Feature 從 Aggregate 的 values 或 Release 的 infra 接受它的 origin,而該通知回報有一個葉節點同時在兩者中宣告。它不改變任何裁定。
建置會寫出 dist/compose/docker-compose.yaml,其中有圖的一個服務、資料庫的一個服務,以及等待資料庫的一個服務。圖的服務:
support: image: ghcr.io/example/support-agent:1.0.0 environment: LANGGRAPH_DEFAULT_RECURSION_LIMIT: "25" OPENAI_BASE_URL: https://api.openai.com/v1 OPENAI_MODEL: gpt-4o-mini LANGGRAPH_CHECKPOINTER_HOST: postgres LANGGRAPH_CHECKPOINTER_PORT: "5432" LANGGRAPH_CHECKPOINTER_USER: appuser LANGGRAPH_CHECKPOINTER_DATABASE: appdb LANGGRAPH_GRAPH_ENTRYPOINT: ./src/support_agent/graph.py:graph OPENAI_API_KEY: ${OPENAI_API_KEY} LANGGRAPH_CHECKPOINTER_PASSWORD: ${POSTGRES_PASSWORD} ports: - 127.0.0.1:8000:8000 [… omitted: the labels the build writes on every service, naming the Aggregate, the component, the environment and the compiler's version] networks: - compose depends_on: support--wait-for-store: condition: service_completed_successfully postgres: condition: service_started圖會接收模型的位址、其名稱與其金鑰、資料庫的主機、連接埠、使用者、資料庫名稱與密碼,以及它自己的圖進入點。使用者與資料庫名稱是 PostgreSQL Component 的預設值 appuser 與 appdb,下方資料庫的服務就是以它們建立的;圖會被給予它們,是因為 PostgreSQL Recipe 兩者都發布,而兩者都不發布的儲存區,如 Valkey,則兩者都不會被給予。模型的名稱、資料庫的主機、連接埠、使用者與資料庫名稱,以及圖進入點,是以 LangGraph Component 預設送達的名稱到達,而連線上的 inject: 區塊,或元件本身自有值上的該區塊,會將它們取代為你的程式碼所讀取的名稱。模型的位址、其金鑰與資料庫的密碼則依區塊所指名的名稱為準,LANGGRAPH_DEFAULT_RECURSION_LIMIT 也是如此,LangGraph 會自行將它讀取為設定未設定步驟上限之執行的步驟上限。資料庫自己的服務使用同一個密碼:
postgres: image: postgres:16 environment: POSTGRES_USER: appuser POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: appdb [… omitted: the labels the build writes on every service, the network, and a health check running PostgreSQL's pg_isready]圖的服務只有在第三個服務完成後才會啟動。它只執行一次,在目錄的快速入門代理程式映像檔中而非圖自己的映像檔中,並等到資料庫的位址接受 TCP 連線,每 2 s 嘗試一次,最長 300 s;到那時仍沒有連線,它會結束並指名該位址,而圖不會啟動。它只被給予資料庫的主機與連接埠,沒有其他東西:
support--wait-for-store: image: hub.aggrega.ai/tools/quickstart-agent:1.0.1@sha256:a5f8dcfbb670d86a0cae0aadd2844bec93221a651238f8be3863873e261ee168 [… omitted: the command and the entrypoint, a bash loop that opens a connection to the address] environment: STORE_HOST: postgres STORE_PORT: "5432" [… omitted: the labels the build writes on every service, and the network] restart: "no"金鑰與密碼是變數參照,在堆疊啟動時從你的 shell 填入。模型沒有自己的服務:圖會在 OpenAI API 自己的位址連到它。圖的服務僅在 127.0.0.1 上發布其連接埠,而資料庫自己的連接埠則在堆疊的網路上連到,沒有發布任何東西。
搭配 AI 助理
設定了 Aggrega 工具的 AI 助理也能做同樣的事:把這段提示貼給它。
只使用 Aggrega 工具,且不要自行建立任何資料夾。如果 Workspace 資料夾中還沒有 `import-langgraph` 資料夾,請呼叫一次 `draft` 工具,將 `example` 設為 `import-langgraph`,且不帶 `dir`:它會將範例寫入新的 `import-langgraph` 資料夾,其 `source` 資料夾保存本頁所匯入的內容。接著呼叫 `import` 工具,將 `workspace_root` 設為 `import-langgraph/source`、`source` 設為 `.`、`target` 設為 `compose`:它會從 `langgraph.json` 旁的 `import-answers.yaml` 讀取所需的答案,將草稿寫入 `import-langgraph/source`,並拉取它們所需的內容。接著呼叫 `validate` 工具,將 `workspace_root` 設為 `import-langgraph/source`、`release` 設為 `release.yaml`,並呼叫 `build` 工具,將 `workspace_root` 設為 `import-langgraph/source`、`release` 設為 `release.yaml`、`write` 設為 true。告訴我建置寫出了哪些檔案;它們位於 `import-langgraph/source/dist/` 之下。在 VS Code 中開啟
安裝 Aggrega extension for Visual Studio Code 後,在 VS Code 中開啟資料夾 import-langgraph/source,匯入就是把草稿寫在那裡。該資料夾保存一個 Release,即草稿的 release.yaml,所以編輯器會替你選取它,並在你編輯草稿時依該 Release 檢查它們,在檔案與 Problems 面板中標示所發現的問題。命令選擇區中的 Aggrega: Show topology graph 會繪出該 Release 的元件以及它們之間的連線。Aggrega: Build、Aggrega: Preview build 與 Aggrega: Pull 都作用於同一個 Release,而且每一個也是活動列中 Aggrega 檢視的 Commands 面板上的按鈕;Build 會將其檔案寫入該資料夾的 dist/。其餘內容請見 Use Aggrega in Visual Studio Code。
執行
你以專案建置映像檔,並使用你自己的 Dockerfile:圖的程式碼,加上已安裝的 LangGraph。Docker Compose 會把映像檔本身的命令當作圖的服務來執行,因為 Recipe 沒有設定任何命令,所以該命令必須持續執行,而且若你想連到這張圖,它必須能處理請求。它透過上述變數找到圖、模型與資料庫。位址、路由與回覆由你的程式決定。
以下的執行使用了這樣一個映像檔:圖位於 langgraph.json 所指名的路徑 src/support_agent/graph.py,一個節點透過 OPENAI_MODEL 所指名的模型作答,而映像檔的命令是程式自己的一個小型 HTTP 伺服器,位於連接埠 8000。映像檔在其工作目錄保留專案的配置,因此 LANGGRAPH_GRAPH_ENTRYPOINT 所指名的路徑(相對於該目錄)能找到圖。伺服器載入該圖,透過 LangGraph 的 PostgreSQL 檢查點器把每段對話的狀態保存在資料庫中,檢查點器以資料庫的主機、連接埠、使用者、資料庫名稱與密碼開啟,各自讀自它送達時所用的 LANGGRAPH_CHECKPOINTER_ 變數,所以程式本身不寫入其中任何一項,並對每個 POST /threads/<thread>/runs 各執行一次圖。圖的服務會在資料庫接受連線後啟動,因此在啟動時開啟檢查點器的伺服器會發現資料庫正在接受連線。請在專案根目錄建置你的映像檔,把它的名稱寫在 import-answers.yaml 中 ghcr.io/example/support-agent:1.0.0 的位置,然後以 --sync 再次匯入,它會把新的答案寫入草稿並再次拉取;接著建置:
docker build -t order-support:local .aggrega import . --syncaggrega build --release release.yaml接著在你的 shell 中設定金鑰與資料庫密碼,並啟動堆疊:
export OPENAI_API_KEY='your OpenAI key'export POSTGRES_PASSWORD='a password of your own'docker compose -p order-support -f dist/compose/docker-compose.yaml up -d --wait-p 指定專案名稱,如 匯入如何執行 的執行步驟所說明。--wait 會在資料庫回報健康後返回,此時對它的等待已完成,圖的服務正在執行。
測試
以下的請求會送到本逐步說明的映像檔所執行的程式:位於連接埠 8000 的小型 HTTP 伺服器後方的圖,回應 POST /threads/<thread>/runs。你自己的程式會自行決定路由與回覆。把請求送到 http://127.0.0.1:8000,也就是 published_port 所發布的位址:
curl -sS -X POST http://127.0.0.1:8000/threads/order-1234/runs -H 'Content-Type: application/json' \ -d '{"message": "Where is my order 1234? It has not arrived yet."}'{ "thread": "order-1234", "error": "the run failed: OpenAIAuthenticationError: Error code: 401 - Incorrect API key provided: sk-place************-key. [… omitted: where to find an API key]"}這次執行把 OPENAI_API_KEY 設為預留位置,因此回覆是 OpenAI 對它的拒絕,由程式轉傳。圖的請求帶著建置所交付的金鑰到達 OpenAI API,而發出請求的程式,已用建置所交付的認證在資料庫中開啟了它的檢查點器。
以下列命令停止堆疊:
docker compose -p order-support -f dist/compose/docker-compose.yaml down -v-v 會移除資料庫保存其資料的磁碟區,連同其中的對話。
在 Kubernetes 上,以 --target helm 匯入,並把映像檔推送到你的叢集可拉取的登錄庫,在 import-answers.yaml 中指名它。接著建立 Secret openai-api-key 與 support-db-password,並套用建置結果,如 匯入如何執行 的執行步驟所述。圖的 Deployment 沒有 Service。它的 pod 會不斷重新啟動,直到資料庫接受連線,因為程式在啟動時就開啟它的檢查點器。將本機連接埠轉送到它;該命令會一直執行到你停止為止:
kubectl port-forward deploy/support 8000:8000Forwarding from 127.0.0.1:8000 -> 8000Forwarding from [::1]:8000 -> 8000從另一個終端機,把相同的請求傳送到轉送的連接埠:
curl -sS -X POST http://127.0.0.1:8000/threads/order-1234/runs -H 'Content-Type: application/json' \ -d '{"message": "Where is my order 1234? It has not arrived yet."}'{ "thread": "order-1234", "error": "the run failed: OpenAIAuthenticationError: Error code: 401 - Incorrect API key provided: sk-place************-key. [… omitted: where to find an API key]"}