11use derive_setters:: Setters ;
2- use forge_domain :: { ContextMessage , Image } ;
2+ use forge_app :: domain :: { ContextMessage , Image } ;
33use serde:: { Deserialize , Serialize } ;
44
55use crate :: error:: Error ;
@@ -38,15 +38,15 @@ pub struct Thinking {
3838 budget_tokens : u64 ,
3939}
4040
41- impl TryFrom < forge_domain :: Context > for Request {
41+ impl TryFrom < forge_app :: domain :: Context > for Request {
4242 type Error = anyhow:: Error ;
43- fn try_from ( request : forge_domain :: Context ) -> std:: result:: Result < Self , Self :: Error > {
43+ fn try_from ( request : forge_app :: domain :: Context ) -> std:: result:: Result < Self , Self :: Error > {
4444 // note: Anthropic only supports 1 system message in context, so from the
4545 // context we pick the first system message available.
4646 // ref: https://docs.anthropic.com/en/api/messages#body-system
4747 let system = request. messages . iter ( ) . find_map ( |message| {
4848 if let ContextMessage :: Text ( chat_message) = message {
49- if chat_message. role == forge_domain :: Role :: System {
49+ if chat_message. role == forge_app :: domain :: Role :: System {
5050 Some ( chat_message. content . clone ( ) )
5151 } else {
5252 None
@@ -63,7 +63,7 @@ impl TryFrom<forge_domain::Context> for Request {
6363 . filter ( |message| {
6464 // note: Anthropic does not support system messages in message field.
6565 if let ContextMessage :: Text ( chat_message) = message {
66- chat_message. role != forge_domain :: Role :: System
66+ chat_message. role != forge_app :: domain :: Role :: System
6767 } else {
6868 true
6969 }
@@ -143,9 +143,11 @@ impl TryFrom<ContextMessage> for Message {
143143 }
144144
145145 match chat_message. role {
146- forge_domain:: Role :: User => Message { role : Role :: User , content } ,
147- forge_domain:: Role :: Assistant => Message { role : Role :: Assistant , content } ,
148- forge_domain:: Role :: System => {
146+ forge_app:: domain:: Role :: User => Message { role : Role :: User , content } ,
147+ forge_app:: domain:: Role :: Assistant => {
148+ Message { role : Role :: Assistant , content }
149+ }
150+ forge_app:: domain:: Role :: System => {
149151 // note: Anthropic doesn't support system role messages and they're already
150152 // filtered out. so this state is unreachable.
151153 return Err ( Error :: UnsupportedRole ( "System" . to_string ( ) ) . into ( ) ) ;
@@ -222,9 +224,9 @@ enum Content {
222224 } ,
223225}
224226
225- impl TryFrom < forge_domain :: ToolCallFull > for Content {
227+ impl TryFrom < forge_app :: domain :: ToolCallFull > for Content {
226228 type Error = anyhow:: Error ;
227- fn try_from ( value : forge_domain :: ToolCallFull ) -> std:: result:: Result < Self , Self :: Error > {
229+ fn try_from ( value : forge_app :: domain :: ToolCallFull ) -> std:: result:: Result < Self , Self :: Error > {
228230 let call_id = value. call_id . as_ref ( ) . ok_or ( Error :: ToolCallMissingId ) ?;
229231
230232 Ok ( Content :: ToolUse {
@@ -236,9 +238,9 @@ impl TryFrom<forge_domain::ToolCallFull> for Content {
236238 }
237239}
238240
239- impl TryFrom < forge_domain :: ToolResult > for Content {
241+ impl TryFrom < forge_app :: domain :: ToolResult > for Content {
240242 type Error = anyhow:: Error ;
241- fn try_from ( value : forge_domain :: ToolResult ) -> std:: result:: Result < Self , Self :: Error > {
243+ fn try_from ( value : forge_app :: domain :: ToolResult ) -> std:: result:: Result < Self , Self :: Error > {
242244 let call_id = value. call_id . as_ref ( ) . ok_or ( Error :: ToolCallMissingId ) ?;
243245 Ok ( Content :: ToolResult {
244246 tool_use_id : call_id. as_str ( ) . to_string ( ) ,
@@ -287,17 +289,21 @@ pub enum ToolChoice {
287289}
288290
289291// To understand the mappings refer: https://docs.anthropic.com/en/docs/build-with-claude/tool-use#controlling-claudes-output
290- impl From < forge_domain :: ToolChoice > for ToolChoice {
291- fn from ( value : forge_domain :: ToolChoice ) -> Self {
292+ impl From < forge_app :: domain :: ToolChoice > for ToolChoice {
293+ fn from ( value : forge_app :: domain :: ToolChoice ) -> Self {
292294 match value {
293- forge_domain:: ToolChoice :: Auto => ToolChoice :: Auto { disable_parallel_tool_use : None } ,
294- forge_domain:: ToolChoice :: Call ( tool_name) => {
295+ forge_app:: domain:: ToolChoice :: Auto => {
296+ ToolChoice :: Auto { disable_parallel_tool_use : None }
297+ }
298+ forge_app:: domain:: ToolChoice :: Call ( tool_name) => {
295299 ToolChoice :: Tool { name : tool_name. to_string ( ) , disable_parallel_tool_use : None }
296300 }
297- forge_domain :: ToolChoice :: Required => {
301+ forge_app :: domain :: ToolChoice :: Required => {
298302 ToolChoice :: Any { disable_parallel_tool_use : None }
299303 }
300- forge_domain:: ToolChoice :: None => ToolChoice :: Auto { disable_parallel_tool_use : None } ,
304+ forge_app:: domain:: ToolChoice :: None => {
305+ ToolChoice :: Auto { disable_parallel_tool_use : None }
306+ }
301307 }
302308 }
303309}
@@ -312,9 +318,11 @@ pub struct ToolDefinition {
312318 input_schema : serde_json:: Value ,
313319}
314320
315- impl TryFrom < forge_domain :: ToolDefinition > for ToolDefinition {
321+ impl TryFrom < forge_app :: domain :: ToolDefinition > for ToolDefinition {
316322 type Error = anyhow:: Error ;
317- fn try_from ( value : forge_domain:: ToolDefinition ) -> std:: result:: Result < Self , Self :: Error > {
323+ fn try_from (
324+ value : forge_app:: domain:: ToolDefinition ,
325+ ) -> std:: result:: Result < Self , Self :: Error > {
318326 Ok ( ToolDefinition {
319327 name : value. name . to_string ( ) ,
320328 description : Some ( value. description ) ,
0 commit comments