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 OpenAI (LLM) procedures #3575

Merged
merged 9 commits into from May 17, 2023
Merged

Add OpenAI (LLM) procedures #3575

merged 9 commits into from May 17, 2023

Conversation

jexp
Copy link
Member

@jexp jexp commented May 15, 2023

Fixes #3574

One sentence summary of the change.

Proposed Changes (Mandatory)

Similar to the NLP procedures, we can provide a number of procedures that make working with LLM easier

Starting with OpenAI API, possibly extending it to other providers

  • generate embeddings
  • text & chat completions

Thanks to @tomasonjo for the initial PR

@jexp jexp mentioned this pull request May 15, 2023
@jexp
Copy link
Member Author

jexp commented May 16, 2023

Want to change the procedure results

columns for completion:

created, model, id,completion_tokens, prompt_tokens total_tokens, object->type

not sure how to handle: choices=[{finish_reason="stop", index=0, text="Blue", logprobs=null}]
perhaps we can turn that into one row per choice? and then add the columns for finish_reason, index, text, logprobs

(not sure what logprobs is)

same for chat-completion

@conker84
Copy link
Contributor

created, model, id,completion_tokens, prompt_tokens total_tokens, object->type

I would leave it as is as currently we don't have a clear view about how the developer will use it; @tomasonjo wdyt?

@tomasonjo
Copy link
Contributor

I would also leave it as we return full responses and allow users to do whatever they want.

I am guessing in 98%, the developer usage will be:

YIELD value
WITH value.choices[0].text AS response
do something

@jexp
Copy link
Member Author

jexp commented May 16, 2023

Ok then we can release it as is.

Copy link
Contributor

@conker84 conker84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jexp @tomasonjo thank you so much, I just have one question

"model": "text-embedding-ada-002",
"usage": { "prompt_tokens": 8, "total_tokens": 8 } }
*/
Stream<Object> resultStream = executeRequest(apiKey, configuration, "embeddings", "text-embedding-ada-002", "input", texts, "$.data");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jexp @tomasonjo does make sense to make this and the other models configurable, via configuration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure exactly if I understand what you mean, but we could add model parameter under the configuration map. I would leave the prompts as a separate parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model is something important, so it cannot be missed. For the user it's already in the configuration. But internally I think we should make it explicit.

Copy link
Contributor

@conker84 conker84 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I mean something like this

Suggested change
Stream<Object> resultStream = executeRequest(apiKey, configuration, "embeddings", "text-embedding-ada-002", "input", texts, "$.data");
String model = configuration.getOrDefault("model", "text-embedding-ada-002");
Stream<Object> resultStream = executeRequest(apiKey, configuration, "embeddings", model, "input", texts, "$.data");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to do this on every call, as it's already done inside of executeRequest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@conker84 conker84 merged commit edb4e6d into dev May 17, 2023
3 of 4 checks passed
@conker84 conker84 deleted the openai-procedures branch May 17, 2023 14:54
@conker84
Copy link
Contributor

@jexp @tomasonjo thank you!

vga91 pushed a commit that referenced this pull request May 17, 2023
* 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 <bratanic.tomaz@gmail.com>
vga91 pushed a commit that referenced this pull request May 23, 2023
* 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 <bratanic.tomaz@gmail.com>
vga91 added a commit that referenced this pull request May 23, 2023
* 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 <bratanic.tomaz@gmail.com>

* Removed unused deps after OpenAI procedures addition (#3585)

* Updated extended.txt to fix checkCoreWithExtraDependenciesJars failure after Open AI procedures

---------

Co-authored-by: Michael Hunger <github@jexp.de>
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com>
vga91 added a commit that referenced this pull request Jul 27, 2023
* 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 <bratanic.tomaz@gmail.com>

* Removed unused deps after OpenAI procedures addition (#3585)

* Updated extended.txt to fix checkCoreWithExtraDependenciesJars failure after Open AI procedures

---------

Co-authored-by: Michael Hunger <github@jexp.de>
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com>
vga91 added a commit that referenced this pull request Jul 27, 2023
* 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 <bratanic.tomaz@gmail.com>

* Removed unused deps after OpenAI procedures addition (#3585)

* Updated extended.txt to fix checkCoreWithExtraDependenciesJars failure after Open AI procedures

---------

Co-authored-by: Michael Hunger <github@jexp.de>
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com>
vga91 added a commit that referenced this pull request Aug 3, 2023
* [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 <bratanic.tomaz@gmail.com>

* Removed unused deps after OpenAI procedures addition (#3585)

* Updated extended.txt to fix checkCoreWithExtraDependenciesJars failure after Open AI procedures

---------

Co-authored-by: Michael Hunger <github@jexp.de>
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com>

* [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 <santand@gmail.com>

---------

Co-authored-by: Michael Hunger <github@jexp.de>
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com>
Co-authored-by: Andrea Santurbano <santand@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OpenAI (LLM) procedures
3 participants