fix: add derive to serde

This commit is contained in:
0xMRTT 2023-06-17 15:34:55 +02:00
parent 20adf75890
commit 74c4825dd4
Signed by: 0xMRTT
GPG Key ID: 910B287304120902
2 changed files with 3 additions and 4 deletions

View File

@ -9,6 +9,6 @@ edition = "2021"
ratmom = "0.1.0"
reqwest = { version = "0.11.18", features = ["json"] }
reqwest-eventsource = "0.4.0"
serde = "1.0.164"
serde = {"1.0.164", features = ["derive"] }
serde_json = "1.0.97"
tokio = { version = "1", features = ["full"] }

View File

@ -1,7 +1,6 @@
use ratmom::{prelude::*, Request};
use serde::{Serialize, Deserialize};
// {"role":"assistant","id":"chatcmpl-7SQEOvjjNeoy4D4IZnohylUEbnkyJ","parentMessageId":"c57a0ed4-2a1a-40b4-b57d-050fa167287a","text":"Hello","delta":"Hello","detail":{"id":"chatcmpl-7SQEOvjjNeoy4D4IZnohylUEbnkyJ","object":"chat.completion.chunk","created":1687008372,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}}
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Delta {
@ -61,7 +60,7 @@ pub async fn ask(prompt: &str) -> Result<String, Box<dyn std::error::Error>> {
let mut deltas: Vec<Delta> = Vec::new();
for line in result.lines() {
let delta: Delta = serde_json::from_str(&line)?;
let delta: Delta = serde_json::from_str(&line).unwrap();
deltas.push(delta);
}