-
Notifications
You must be signed in to change notification settings - Fork 97
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 secure-fraud-detection demo #539
Add secure-fraud-detection demo #539
Conversation
Nice! I am guessing that the error you are seeing is due to maven not being configured with to make |
Thanks @geoand, yes, I was wondering how exactly does the translate demo work which has 2 parameters, and now I've found https://github.com/quarkiverse/quarkus-langchain4j/blob/main/samples/cli-translator/pom.xml#L12 :-) |
...e-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/TransactionRepository.java
Outdated
Show resolved
Hide resolved
...s/secure-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/ChatMemoryBean.java
Outdated
Show resolved
Hide resolved
38b3c99
to
162391e
Compare
...e-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/ProvidersConfigSource.java
Outdated
Show resolved
Hide resolved
162391e
to
38e5513
Compare
@geoand @jmartisk |
38e5513
to
0fe8b82
Compare
@geoand I prototyped a custom But the following error is becoming quite persistent:
Can you please, when you have a few mins, have a quick look at |
It is transient though, after some delay, I've restarted and I'm getting an interesting response, |
0fe8b82
to
cf7bfeb
Compare
In any case, I'm moving away from using tools in favor of ContentRetriever, yet to be implemented similarly to how it is done in the csv chatbot demo, since it gives a nice option to use Update: I've followed with a few minor updates and squashed everything, it will be easy to get back to tools if necessary |
dc36dbf
to
ec93506
Compare
Gonna look into this one in a bit! |
samples/secure-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/Setup.java
Outdated
Show resolved
Hide resolved
samples/secure-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/Setup.java
Outdated
Show resolved
Hide resolved
samples/secure-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/Setup.java
Show resolved
Hide resolved
...etection/src/main/java/io/quarkiverse/langchain4j/sample/FraudDetectionContentRetriever.java
Outdated
Show resolved
Hide resolved
ec93506
to
e5eede2
Compare
e9a6a85
to
978b215
Compare
Thanks @jmartisk, makes sense to make it easier for users to register emails, may be with a system property, will have a look next week |
...cure-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/CustomerRepository.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about this some more.
IIUC, the intent here is to show that the AiService can access the logged in user when retreving data, correct?
If so, I think that using the MemoryIdProvider
is the not best abstraction.
Would it not be far easier to inject the logged in user in FraudDetectionRetrievalAugmentor
?
...-fraud-detection/src/main/java/io/quarkiverse/langchain4j/sample/SecureMemoryIdProvider.java
Outdated
Show resolved
Hide resolved
Thanks @geoand,
Yeah, good point, I tried it earlier, to inject it directly to I can try to inject it into a custom retrieval augmentor, but if that works, how would I pass it to the content retriever ? |
You are right, I see why this is the case... Unfortunately I don't have any good solutions for you at the moment, but I do see how we add something to LangChain4j to make this possible. Essentially what I have in mind is to enhance Then your What I don't like about this is that it would force user code (the An alternative approach would be for us to write our own version of WDYT @jmartisk @sberyozkin ? |
Sure, that can definitely do it, some well known key properties like
I'm not sure yet as I don't know much about the mechanics involved, on the basic level having an extra Metadata Map looks like it can work better as the identity may be needed across several pieces where Query is available, not only at the RAG level. I was actually thinking about some workarounds on the way to the office :-) I was still thinking in terms of a custom memory id since the authenticated/logged in user's session lifetime matches the secure memory id lifetime. May be it is a bit hacky, not sure, though it would probably fit closely enough the expectation that the memory id can be any object. I think I also like the idea of the extra metadata map. |
This is the one solution I would like to avoid because MemoryId is really a different concept. It's fine to populate it automatically, but it's not fine to use it's value to do something else. |
@geoand I'm happy enough to pursue adding extra Map to |
Yeah, I think so to, but there also needs to be a way to add metadata, something like the |
@geoand OK, then, it will certainly cover the RAG flow. Can you clarify please, when you get a sec, why RequestContext is not available in the custom augmentor or content retriever, like you said, that would definitely be a simplest solution, if it were available. (I'm also thinking about making the identity visible in other places like custom tools and other custom non-RAG related providers). |
Because the implementation in upstream LangChain4j uses a |
8c11a7e
to
4029ad8
Compare
Actually, it should be possible to do this even now, no changes to LangChain4j needed. |
4029ad8
to
ee23108
Compare
Hi @geoand, I was just dealing with formatting as well as a suggestion from @jmartisk to report something to the user when a customer is missing, and now a customer full name and email must be provided at startup as system properties, as opposed to having to modify Super cool that we can try our own executor, I can test, how do I do it ? Is Quarkus executor injectable or which one do you have in mind ? |
You can inject |
ee23108
to
f1f0df6
Compare
f1f0df6
to
c5df9fa
Compare
c5df9fa
to
58e2662
Compare
@geoand Now I'm really happy, the custom memory id provider has gone :-), secure authenticated access to the content retriever is done, thanks for the ManagedExecutor idea. I think it can probably make sense to doc it separately, I can work a bit later on a doc dedicated to securing various AI service parts... I think this PR is now quite ready to go once yourself and @jmartisk happy enough with it in general |
Very nice! +1 on getting this in - but let's wait for @jmartisk |
Guys I see you were discussing passing some extra metadata around a RAG pipeline, please check langchain4j/langchain4j#1122, that is related |
Thanks for the link, it is interesting, luckily, at least for the security identity, it can be injected into RAG related parts, but I'm not sure yet if it can be injected into Tools, something I can try in the next demo for the secure web socket based sql chatbot one, so that is indeed a very related discussion, thanks |
Draft PR for a secure-fraud-detection demo.
The startup issue described here earlier was resolved as advised by Georgios