@@ -12,13 +12,13 @@ use crate::{protocol::*, utils::sse::rsplit_once_terminator};
12
12
13
13
/// A model from the models endpoint.
14
14
#[ derive( Clone , Debug , Deserialize , PartialEq ) ]
15
- pub struct Model {
15
+ struct Model {
16
16
id : String ,
17
17
}
18
18
19
19
/// Response from the models endpoint.
20
20
#[ derive( Clone , Debug , Deserialize , PartialEq ) ]
21
- pub struct Models {
21
+ struct Models {
22
22
pub data : Vec < Model > ,
23
23
}
24
24
@@ -32,15 +32,15 @@ pub struct Models {
32
32
/// And SiliconFlow may set `content` to a `null` value, that's why the custom deserializer
33
33
/// is needed.
34
34
#[ derive( Clone , Debug , Deserialize , PartialEq ) ]
35
- pub struct IncomingMessage {
35
+ struct IncomingMessage {
36
36
#[ serde( default ) ]
37
37
#[ serde( deserialize_with = "deserialize_null_default" ) ]
38
38
pub content : String ,
39
39
}
40
40
41
41
/// A message being sent to the completions endpoint.
42
42
#[ derive( Clone , Debug , Serialize ) ]
43
- pub struct OutcomingMessage {
43
+ struct OutcomingMessage {
44
44
pub content : String ,
45
45
pub role : Role ,
46
46
}
@@ -65,7 +65,7 @@ impl TryFrom<Message> for OutcomingMessage {
65
65
66
66
/// Role of a message that is part of the conversation context.
67
67
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
68
- pub enum Role {
68
+ enum Role {
69
69
/// OpenAI o1 models seems to expect `developer` instead of `system` according
70
70
/// to the documentation. But it also seems like `system` is converted to `developer`
71
71
/// internally.
@@ -78,13 +78,13 @@ pub enum Role {
78
78
}
79
79
80
80
#[ derive( Clone , Debug , Deserialize ) ]
81
- pub struct Choice {
81
+ struct Choice {
82
82
pub delta : IncomingMessage ,
83
83
}
84
84
85
85
/// Response from the completions endpoint.
86
86
#[ derive( Clone , Debug , Deserialize ) ]
87
- pub struct Completation {
87
+ struct Completation {
88
88
pub choices : Vec < Choice > ,
89
89
}
90
90
@@ -94,6 +94,7 @@ struct MolyClientInner {
94
94
headers : HeaderMap ,
95
95
}
96
96
97
+ /// A client capable of interacting with Moly Server and other OpenAI-compatible APIs.
97
98
#[ derive( Debug ) ]
98
99
pub struct MolyClient ( Arc < Mutex < MolyClientInner > > ) ;
99
100
@@ -110,6 +111,7 @@ impl From<MolyClientInner> for MolyClient {
110
111
}
111
112
112
113
impl MolyClient {
114
+ /// Creates a new client with the given OpenAI-compatible API URL.
113
115
pub fn new ( url : String ) -> Self {
114
116
let mut headers = HeaderMap :: new ( ) ;
115
117
headers. insert ( "Content-Type" , "application/json" . parse ( ) . unwrap ( ) ) ;
0 commit comments