refactor: remove inter package dependency cycles in spring-ai-model · spring-projects/spring-ai@ebfa5b9 (original) (raw)

`@@ -32,8 +32,8 @@

`

32

32

`import org.springframework.ai.chat.model.ChatModel;

`

33

33

`import org.springframework.ai.chat.model.ToolContext;

`

34

34

`import org.springframework.ai.tool.annotation.Tool;

`

35

``

`-

import org.springframework.ai.tool.definition.ToolDefinition;

`

36

35

`import org.springframework.ai.tool.method.MethodToolCallback;

`

``

36

`+

import org.springframework.ai.tool.support.ToolDefinitions;

`

37

37

`import org.springframework.beans.factory.annotation.Autowired;

`

38

38

`import org.springframework.boot.test.context.SpringBootTest;

`

39

39

`import org.springframework.test.context.ActiveProfiles;

`

`@@ -68,7 +68,7 @@ void methodGetWeatherGeneratedDescription() {

`

68

68

`String response = ChatClient.create(this.chatModel).prompt()

`

69

69

` .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")

`

70

70

` .toolCallbacks(MethodToolCallback.builder()

`

71

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod).build())

`

``

71

`+

.toolDefinition(ToolDefinitions.builder(toolMethod).build())

`

72

72

` .toolMethod(toolMethod)

`

73

73

` .build())

`

74

74

` .call()

`

`@@ -90,7 +90,7 @@ void methodGetWeatherStatic() {

`

90

90

`String response = ChatClient.create(this.chatModel).prompt()

`

91

91

` .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")

`

92

92

` .toolCallbacks(MethodToolCallback.builder()

`

93

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod)

`

``

93

`+

.toolDefinition(ToolDefinitions.builder(toolMethod)

`

94

94

` .description("Get the weather in location")

`

95

95

` .build())

`

96

96

` .toolMethod(toolMethod)

`

`@@ -117,7 +117,7 @@ void methodTurnLightNoResponse() {

`

117

117

`String response = ChatClient.create(this.chatModel).prompt()

`

118

118

` .user("Turn light on in the living room.")

`

119

119

` .toolCallbacks(MethodToolCallback.builder()

`

120

``

`-

.toolDefinition(ToolDefinition.builder(turnLightMethod)

`

``

120

`+

.toolDefinition(ToolDefinitions.builder(turnLightMethod)

`

121

121

` .description("Turn light on in the living room.")

`

122

122

` .build())

`

123

123

` .toolMethod(turnLightMethod)

`

`@@ -145,7 +145,7 @@ void methodGetWeatherNonStatic() {

`

145

145

`String response = ChatClient.create(this.chatModel).prompt()

`

146

146

` .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")

`

147

147

` .toolCallbacks(MethodToolCallback.builder()

`

148

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod)

`

``

148

`+

.toolDefinition(ToolDefinitions.builder(toolMethod)

`

149

149

` .description("Get the weather in location")

`

150

150

` .build())

`

151

151

` .toolMethod(toolMethod)

`

`@@ -172,7 +172,7 @@ void methodGetWeatherToolContext() {

`

172

172

`String response = ChatClient.create(this.chatModel).prompt()

`

173

173

` .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")

`

174

174

` .toolCallbacks(MethodToolCallback.builder()

`

175

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod)

`

``

175

`+

.toolDefinition(ToolDefinitions.builder(toolMethod)

`

176

176

` .description("Get the weather in location")

`

177

177

` .build())

`

178

178

` .toolMethod(toolMethod)

`

`@@ -203,7 +203,7 @@ void methodGetWeatherWithContextMethodButMissingContext() {

`

203

203

`assertThatThrownBy(() -> ChatClient.create(this.chatModel).prompt()

`

204

204

` .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.")

`

205

205

` .toolCallbacks(MethodToolCallback.builder()

`

206

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod)

`

``

206

`+

.toolDefinition(ToolDefinitions.builder(toolMethod)

`

207

207

` .description("Get the weather in location")

`

208

208

` .build())

`

209

209

` .toolMethod(toolMethod)

`

`@@ -229,7 +229,7 @@ void methodNoParameters() {

`

229

229

` .user("Turn light on in the living room.")

`

230

230

` .toolCallbacks(MethodToolCallback.builder()

`

231

231

` .toolMethod(toolMethod)

`

232

``

`-

.toolDefinition(ToolDefinition.builder(toolMethod)

`

``

232

`+

.toolDefinition(ToolDefinitions.builder(toolMethod)

`

233

233

` .description("Can turn lights on in the Living Room")

`

234

234

` .build())

`

235

235

` .toolObject(targetObject)

`