Podにキーを渡す実装
This commit is contained in:
@@ -21,7 +21,6 @@ name = "hello-pod"
|
||||
[provider]
|
||||
kind = "anthropic"
|
||||
model = "claude-sonnet-4-20250514"
|
||||
api_key_env = "ANTHROPIC_API_KEY"
|
||||
|
||||
[worker]
|
||||
system_prompt = "You are a concise assistant. Reply in one or two sentences."
|
||||
@@ -41,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let store = FsStore::new(tmp.path()).await?;
|
||||
|
||||
// 3. Build the Pod from manifest
|
||||
let mut pod = Pod::from_manifest(manifest, store, None).await?;
|
||||
let mut pod = Pod::from_manifest(manifest, store, None, None).await?;
|
||||
println!("Session: {}", pod.session_id());
|
||||
|
||||
// 4. Run a prompt
|
||||
|
||||
@@ -15,7 +15,6 @@ name = "protocol-demo"
|
||||
[provider]
|
||||
kind = "anthropic"
|
||||
model = "claude-sonnet-4-20250514"
|
||||
api_key_env = "ANTHROPIC_API_KEY"
|
||||
|
||||
[worker]
|
||||
system_prompt = "You are a concise assistant. Reply in one or two sentences."
|
||||
@@ -29,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let manifest = PodManifest::from_toml(MANIFEST_TOML)?;
|
||||
let tmp = tempfile::tempdir()?;
|
||||
let store = FsStore::new(tmp.path()).await?;
|
||||
let pod = pod::Pod::from_manifest(manifest, store, None).await?;
|
||||
let pod = pod::Pod::from_manifest(manifest, store, None, None).await?;
|
||||
|
||||
let runtime_tmp = tempfile::tempdir()?;
|
||||
let handle = PodController::spawn(pod, runtime_tmp.path()).await?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitCode;
|
||||
|
||||
use clap::Parser;
|
||||
@@ -84,7 +84,10 @@ async fn main() -> ExitCode {
|
||||
};
|
||||
|
||||
// Build the Pod
|
||||
let pod = match Pod::from_manifest(manifest, store, scope).await {
|
||||
let manifest_dir = std::fs::canonicalize(&cli.manifest)
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(Path::to_path_buf));
|
||||
let pod = match Pod::from_manifest(manifest, store, scope, manifest_dir).await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("error: failed to create pod: {e}");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_worker::llm_client::client::LlmClient;
|
||||
@@ -173,8 +174,9 @@ impl<St: Store> Pod<Box<dyn LlmClient>, St> {
|
||||
manifest: PodManifest,
|
||||
store: St,
|
||||
scope: Option<Scope>,
|
||||
manifest_dir: Option<PathBuf>,
|
||||
) -> Result<Self, PodError> {
|
||||
let client = provider::build_client(&manifest.provider)?;
|
||||
let client = provider::build_client(&manifest.provider, manifest_dir.as_deref())?;
|
||||
let mut worker = Worker::new(client);
|
||||
apply_worker_manifest(&mut worker, &manifest.worker);
|
||||
let session = Session::new(worker, store, SessionConfig::default()).await?;
|
||||
|
||||
Reference in New Issue
Block a user