pocketsizefund / tyrell

more human than human
MIT License
0 stars 0 forks source link

Responses to Structs #11

Open chrisaddy opened 1 month ago

chrisaddy commented 1 month ago

Having an issue with returning ClaudeResponse, it is expecing

thread 'main' panicked at examples/extraction.rs:57:38:
called `Result::unwrap()` on an `Err` value: Failed to deserialize ClaudeResponse

Caused by:
    missing field `type` at line 1 column 323

Stack backtrace:
   0: <E as anyhow::context::ext::StdError>::ext_context
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.89/src/backtrace.rs:27:14
   1: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::context
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.89/src/context.rs:54:31
   2: tyrell::ClaudeRequest::call::{{closure}}
             at ./src/lib.rs:446:17
   3: extraction::main::{{closure}}
             at ./examples/extraction.rs:57:32
   4: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:63
   5: tokio::runtime::coop::with_budget
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5
   6: tokio::runtime::coop::budget
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5
   7: tokio::runtime::park::CachedParkThread::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:31
   8: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/blocking.rs:66:9
   9: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  10: tokio::runtime::context::runtime::enter_runtime
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
  11: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  12: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:363:45
  13: tokio::runtime::runtime::Runtime::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:335:13
  14: extraction::main
             at ./examples/extraction.rs:62:5
  15: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
  16: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
  17: std::rt::lang_start::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:162:18
  18: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:284:13
  19: std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
  20: std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
  21: std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
  22: std::rt::lang_start_internal::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:48
  23: std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
  24: std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
  25: std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
  26: std::rt::lang_start_internal
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:20
  27: std::rt::lang_start
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:161:17
  28: main
  29: __libc_start_call_main
  30: __libc_start_main@GLIBC_2.2.5
  31: _start
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
   2: core::result::unwrap_failed
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1679:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1102:23
   4: extraction::main::{{closure}}
             at ./examples/extraction.rs:57:20
   5: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:63
   6: tokio::runtime::coop::with_budget
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5
   7: tokio::runtime::coop::budget
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5
   8: tokio::runtime::park::CachedParkThread::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:31
   9: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/blocking.rs:66:9
  10: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  11: tokio::runtime::context::runtime::enter_runtime
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
  12: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  13: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:363:45
  14: tokio::runtime::runtime::Runtime::block_on
             at /home/chrisaddy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:335:13
  15: extraction::main
             at ./examples/extraction.rs:62:5
  16: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Error: nu::shell::non_zero_exit_code

  × External command had a non-zero exit code

I'm thinking this might be an issue with the fact that the tool use or non-tool use responses have different ContentType so maybe we should look at that struct?

{"id": "msg_01RhY4TxxRHM2b3N81ijdJms",
"role": "assistant",
"content": [
    {
      "type": "tool_use",
      "id": "toolu_01CQ1Yq17jrrMpF5uiAMt4bU",
      "name": "extract_super_bowl_info",
      "input": {
        "winner": "Green Bay Packers",
        "winner_score": 31, "loser": "Miami Dolphins",
        "loser_score": 10, "year": 1982
      }
    }
  ],
}

{
  "type": "message",
  "content": [
   {"type": "text",
  "text": "The 16th President of the United States was Abraham Lincoln. He served as the nation's president from March 4, 1861, until his assassination for"
  }
],
}