Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AiServiceRegisteredEvent #77

Conversation

catofdestruction
Copy link
Contributor

Publish a Spring Event after registering the AiService Bean in AiServicesAutoConfig.
This event contains the AiService class and its corresponding tools description information.

Once a user implements the AiServiceRegisteredEventListener to listen for this event, they can receive the event during the Spring Boot startup phase and handle their business logic as needed.

Issues link: langchain4j/langchain4j#2112

@langchain4j
Copy link
Owner

@catofdestruction thanks a lot! I will review it asap during this week

@catofdestruction
Copy link
Contributor Author

@catofdestruction thanks a lot! I will review it asap during this week

It seems there is a conflict with another branch’s commits. How should I handle this conflict?

@langchain4j
Copy link
Owner

@catofdestruction could you please try to resolve the conflict? You will probably need to manually merge changes from both branches.

@catofdestruction
Copy link
Contributor Author

@catofdestruction could you please try to resolve the conflict? You will probably need to manually merge changes from both branches.

I tried to perform the merge in the browser, but I’m not sure if it can compile successfully, and whether the unit tests can run properly.

#80
Additionally, has this commit been correctly merged into the main branch?
If it has been completed, can I sync my fork from the main branch again and submit a new PR?

@catofdestruction
Copy link
Contributor Author

@catofdestruction could you please try to resolve the conflict? You will probably need to manually merge changes from both branches.

Additionally, I also found these errors, but I don’t know how to resolve them :(

image

image

@langchain4j
Copy link
Owner

Additionally, has this commit been correctly merged into the main branch?
If it has been completed, can I sync my fork from the main branch again and submit a new PR?

You can try, but if you merge main into your branch, you will need to resolve the conflict anyway. Alternatively, you can also create a new branch from the updated main and apply your changes again.

@langchain4j
Copy link
Owner

Oh nvm, I see that you resolved it already :)

@langchain4j
Copy link
Owner

Please ignore those failures in the CI build, they happen because API keys do not propagate to your branch.

But should_receive_ai_service_registered_event is failing, could you pelase check?

[AiServiceWithTools]: [Tool-1]: ToolSpecification { name = "getCurrentDate", description = null, parameters = null, toolParameters = null }
[AiServiceWithTools]: [Tool-2]: ToolSpecification { name = "getCurrentTime", description = null, parameters = null, toolParameters = null }
[AiServiceWithTools]: [Tool-3]: ToolSpecification { name = "getToolObserverKey", description = "Find the key name of @ToolObserver", parameters = null, toolParameters = null }

org.opentest4j.AssertionFailedError:
Expected :2
Actual :3

at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531)
at dev.langchain4j.service.spring.mode.automatic.withTools.AiServicesAutoConfigIT.lambda$should_receive_ai_service_registered_event$2(AiServicesAutoConfigIT.java:94)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.accept(AbstractApplicationContextRunner.java:434)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.consumeAssertableContext(AbstractApplicationContextRunner.java:363)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$0(AbstractApplicationContextRunner.java:341)
at org.springframework.boot.test.util.TestPropertyValues.lambda$applyToSystemProperties$1(TestPropertyValues.java:174)
at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:188)
at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:173)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$1(AbstractApplicationContextRunner.java:341)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.withContextClassLoader(AbstractApplicationContextRunner.java:369)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.run(AbstractApplicationContextRunner.java:340)
at dev.langchain4j.service.spring.mode.automatic.withTools.AiServicesAutoConfigIT.should_receive_ai_service_registered_event(AiServicesAutoConfigIT.java:82)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

catofdestruction added a commit to catofdestruction/langchain4j-spring that referenced this pull request Nov 26, 2024
…icesAutoConfig.

This event contains the AiService class and its corresponding tools description information.

Once a user implements the AiServiceRegisteredEventListener to listen for this event, they can receive the event during the Spring Boot startup phase and handle their business logic as needed.

original PR link: langchain4j#77
Issues link: langchain4j/langchain4j#2112
@catofdestruction
Copy link
Contributor Author

Please ignore those failures in the CI build, they happen because API keys do not propagate to your branch.

But should_receive_ai_service_registered_event is failing, could you pelase check?

[AiServiceWithTools]: [Tool-1]: ToolSpecification { name = "getCurrentDate", description = null, parameters = null, toolParameters = null }
[AiServiceWithTools]: [Tool-2]: ToolSpecification { name = "getCurrentTime", description = null, parameters = null, toolParameters = null }
[AiServiceWithTools]: [Tool-3]: ToolSpecification { name = "getToolObserverKey", description = "Find the key name of @ToolObserver", parameters = null, toolParameters = null }
org.opentest4j.AssertionFailedError:
Expected :2
Actual :3

at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:145)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:531)
at dev.langchain4j.service.spring.mode.automatic.withTools.AiServicesAutoConfigIT.lambda$should_receive_ai_service_registered_event$2(AiServicesAutoConfigIT.java:94)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.accept(AbstractApplicationContextRunner.java:434)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.consumeAssertableContext(AbstractApplicationContextRunner.java:363)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$0(AbstractApplicationContextRunner.java:341)
at org.springframework.boot.test.util.TestPropertyValues.lambda$applyToSystemProperties$1(TestPropertyValues.java:174)
at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:188)
at org.springframework.boot.test.util.TestPropertyValues.applyToSystemProperties(TestPropertyValues.java:173)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.lambda$run$1(AbstractApplicationContextRunner.java:341)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.withContextClassLoader(AbstractApplicationContextRunner.java:369)
at org.springframework.boot.test.context.runner.AbstractApplicationContextRunner.run(AbstractApplicationContextRunner.java:340)
at dev.langchain4j.service.spring.mode.automatic.withTools.AiServicesAutoConfigIT.should_receive_ai_service_registered_event(AiServicesAutoConfigIT.java:82)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

I found a bug in the previous PR, and I have submitted a new PR.

links here:
#89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants