-
Notifications
You must be signed in to change notification settings - Fork 495
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
First LLM prompt for cypher, query and schema in APOC #3649
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.
thank you so much @jexp just a couple of nit pick for discussion
if (userQuestion != null && !userQuestion.isBlank()) prompt.add(Map.of("role", "user", "content", userQuestion)); | ||
if (assistantPrompt != null && !assistantPrompt.isBlank()) prompt.add(Map.of("role", "assistant", "content", assistantPrompt)); | ||
String result = OpenAI.executeRequest(apiKey, Map.of(), "chat/completions", | ||
"gpt-3.5-turbo", "messages", prompt, "$", apocConfig) |
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.
the model is hardcoded, and as GPT-4 is now in GA maybe we can think about having it as a configuration parameter, as we did in OpenAI
class
Result result = tx.execute(query); | ||
AtomicReference<String> ref = new AtomicReference<>(query); | ||
return result.stream() | ||
.map(row -> new PromptMapResult(row, ref.getAndSet(null))) |
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.
maybe instead of doing this we can use the ProcedureCallContext and return the query
every time but only if requested from the developer
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC (#3649) * First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]> * Removed unused imports and fixed StartupExtendedTest --------- Co-authored-by: Michael Hunger <[email protected]> Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]>
* [NOID] Add OpenAI (LLM) procedures (#3575) (#3582) * Add OpenAI (LLM) procedures (#3575) * WIP * Add completion API * add chatCompletion * prettificiation * WIP * prettify * Refactoring, todo docs & tests * Added Tests & Docs for OpenAI procs (WIP) * Update openai.adoc From @tomasonjo --------- Co-authored-by: Tomaz Bratanic <[email protected]> * Removed unused deps after OpenAI procedures addition (#3585) * Updated extended.txt to fix checkCoreWithExtraDependenciesJars failure after Open AI procedures --------- Co-authored-by: Michael Hunger <[email protected]> Co-authored-by: Tomaz Bratanic <[email protected]> * [NOID] First LLM prompt for cypher, query and schema in APOC (#3649) * First LLM prompt for cypher, query and schema in APOC * Added integration tests * enable open.ai key management globally * Added tests * added docs * added configuration map to procs --------- Co-authored-by: Andrea Santurbano <[email protected]> --------- Co-authored-by: Michael Hunger <[email protected]> Co-authored-by: Tomaz Bratanic <[email protected]> Co-authored-by: Andrea Santurbano <[email protected]>
For review
Uses OpenAI with a potentially configured API (
apoc.openai.key
) inapoc.conf
(e.g. for Sandbox)Extracts the database schema using
apoc.meta.data
apoc.ml.schema
for describing the schema of the databaseapoc.ml.cypher
for generating N cypher queries for the user questionapoc.ml.query
for generating and executing cypher queries (with generation-retries (3 by default) if the query failed)