MCPcopy Create free account
hub / github.com/evilsocket/cake / generate_text

Function generate_text

cake-core/src/cake/sharding/api/text.rs:101–119  ·  view source on GitHub ↗
(
    state: web::Data<Arc<RwLock<Master<M>>>>,
    req: HttpRequest,
    body: web::Json<ChatRequest>,
)

Source from the content-addressed store, hash-verified

99}
100
101pub async fn generate_text<M: Model>(
102 state: web::Data<Arc<RwLock<Master<M>>>>,
103 req: HttpRequest,
104 body: web::Json<ChatRequest>,
105) -> impl Responder {
106 let client = req
107 .peer_addr()
108 .map(|a| a.to_string())
109 .unwrap_or_else(|| "unknown".to_string());
110 let stream = body.0.stream.unwrap_or(false);
111
112 log::info!("starting chat for {} (stream={}) ...", &client, stream);
113
114 if stream {
115 generate_text_stream(state, body.0).await
116 } else {
117 generate_text_blocking(state, body.0).await
118 }
119}
120
121async fn generate_text_blocking<M: Model>(
122 state: web::Data<Arc<RwLock<Master<M>>>>,

Callers

nothing calls this directly

Calls 2

generate_text_streamFunction · 0.85
generate_text_blockingFunction · 0.85

Tested by

no test coverage detected