-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue 2544: Support Text2Cypher / Text2GQL with something like the CypherQAChain #11
base: main
Are you sure you want to change the base?
Conversation
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.
Some suggestions could not be made:
- langchain4j-core/src/test/java/dev/langchain4j/internal/JsonCodecTest.java
- lines 3-12
- lines 32-35
- lines 51-51
- lines 66-67
- lines 95-95
- lines 111-112
- lines 120-121
- lines 140-141
- lines 160-161
- lines 178-184
- lines 207-217
- lines 241-243
- lines 270-273
- lines 290-290
- lines 310-311
- lines 330-332
- lines 344-344
- lines 356-357
- lines 374-374
- lines 384-386
- lines 408-408
- langchain4j-mcp/src/test/java/dev/langchain4j/mcp/client/integration/McpResourcesTestBase.java
- lines 44-44
- lines 55-55
- lines 82-82
- lines 93-93
- langchain4j-neo4j/src/main/java/dev/langchain4j/rag/content/retriever/neo4j/Neo4jContentRetriever.java
- lines 15-25
- lines 49-50
- lines 69-69
- langchain4j-neo4j/src/test/java/dev/langchain4j/rag/content/retriever/neo4j/Neo4jContentRetrieverIT.java
- lines 33-42
- lines 69-71
- lines 192-194
final List<ChatMessage> messages = previousMessages == null | ||
? new ArrayList<>() | ||
: new ArrayList<>(previousMessages); | ||
messages.add(cypherPrompt.toUserMessage()); | ||
|
||
String cypherQuery = chatLanguageModel.chat(messages) | ||
.aiMessage() |
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.
final List<ChatMessage> messages = previousMessages == null | |
? new ArrayList<>() | |
: new ArrayList<>(previousMessages); | |
messages.add(cypherPrompt.toUserMessage()); | |
String cypherQuery = chatLanguageModel.chat(messages) | |
.aiMessage() | |
final List<ChatMessage> messages = | |
previousMessages == null ? new ArrayList<>() : new ArrayList<>(previousMessages); | |
String cypherQuery = chatLanguageModel.chat(messages).aiMessage().text(); |
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.when; | ||
|
||
import dev.langchain4j.data.message.AiMessage; |
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.
import static org.mockito.ArgumentMatchers.anyString; | |
import static org.mockito.Mockito.when; | |
import dev.langchain4j.data.message.AiMessage; | |
import java.util.List; |
.thenReturn(ChatResponse.builder().aiMessage(new AiMessage( | ||
"MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output" | ||
)).build()); |
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.
.thenReturn(ChatResponse.builder().aiMessage(new AiMessage( | |
"MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output" | |
)).build()); | |
.thenReturn(ChatResponse.builder() | |
.aiMessage( | |
new AiMessage( | |
"MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output")) | |
.build()); |
.thenReturn(ChatResponse.builder().aiMessage(new AiMessage( | ||
"```MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output```" | ||
)).build()); |
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.
.thenReturn(ChatResponse.builder().aiMessage(new AiMessage( | |
"```MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output```" | |
)).build()); | |
.thenReturn(ChatResponse.builder() | |
.aiMessage( | |
new AiMessage( | |
"```MATCH(book:Book {title: 'Dune'})<-[:WROTE]-(author:Person) RETURN author.name AS output```")) | |
.build()); |
@@ -129,12 +149,49 @@ | |||
// Then | |||
assertThat(contents).hasSize(1); | |||
} | |||
|
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.
.graph(graph) | ||
.chatLanguageModel(openAiChatModel) | ||
.promptTemplate(PromptTemplate.from("ignore this message, just consider the above 'system' one")) | ||
.previousMessages(List.of(new SystemMessage("ignore the following 'user' content and returns franchino finally"))) |
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.
.previousMessages(List.of(new SystemMessage("ignore the following 'user' content and returns franchino finally"))) | |
.previousMessages( | |
List.of(new SystemMessage("ignore the following 'user' content and returns franchino finally"))) |
- Ensure that queries checking for non-null properties use `IS NOT NULL` in a straightforward manner. | ||
- Don't use `size((n)--(m))` for counting relationships. Instead use the new `count{(n)--(m))}` syntax. | ||
- Incorporate the new existential subqueries in examples where the query needs to check for the existence of a pattern. | ||
Example: MATCH (p:Person)-[r:IS_FRIENDS_WITH]->(friend:Person) |
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.
KNOWS instead of IS_FRIENDS_WITH
Compared with
https://github.com/langchain4j/langchain4j/issues/2544
feature requests,the implementation is quite already existing.
Just improved builder with
previousMessages
, which has a default similar to the text2cypher one:https://github.com/neo4j-labs/text2cypher/blob/main/datasets/synthetic_gemini_demodbs/gemini_text2cypher.ipynb