File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ impl LlmGenerationClient for Client {
7676 . send ( )
7777 . await
7878 . context ( "HTTP error" ) ?;
79+ if !resp. status ( ) . is_success ( ) {
80+ bail ! (
81+ "Anthropic API error: {:?}\n {}\n " ,
82+ resp. status( ) ,
83+ resp. text( ) . await ?
84+ ) ;
85+ }
7986 let mut resp_json: Value = resp. json ( ) . await . context ( "Invalid JSON" ) ?;
8087 if let Some ( error) = resp_json. get ( "error" ) {
8188 bail ! ( "Anthropic API error: {:?}" , error) ;
Original file line number Diff line number Diff line change 1+ use crate :: prelude:: * ;
2+
13use super :: LlmGenerationClient ;
2- use anyhow:: Result ;
3- use async_trait:: async_trait;
44use schemars:: schema:: SchemaObject ;
5- use serde:: { Deserialize , Serialize } ;
65
76pub struct Client {
87 generate_url : String ,
@@ -67,8 +66,14 @@ impl LlmGenerationClient for Client {
6766 . json ( & req)
6867 . send ( )
6968 . await ?;
70- let body = res. text ( ) . await ?;
71- let json: OllamaResponse = serde_json:: from_str ( & body) ?;
69+ if !res. status ( ) . is_success ( ) {
70+ bail ! (
71+ "Ollama API error: {:?}\n {}\n " ,
72+ res. status( ) ,
73+ res. text( ) . await ?
74+ ) ;
75+ }
76+ let json: OllamaResponse = res. json ( ) . await ?;
7277 Ok ( super :: LlmGenerateResponse {
7378 text : json. response ,
7479 } )
You can’t perform that action at this time.
0 commit comments