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

Enable OpenAI functions in chat completion #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nhardtskim
Copy link

Enabled OpenAI function calling, and added the example from the cookbook (https://platform.openai.com/docs/guides/gpt/function-calling).

I haven't added any parsing of the output yet, because I am not sure that is desirable or straightforward.

@nhardtskim
Copy link
Author

I guess if there is a message.function_call.arguments, one could automatically invoke jsonlite::fromJSON() since jsonlite is a dependency anyway, but up to you.

@statzhero
Copy link

statzhero commented Sep 27, 2023

This looks good to me, although I'm not sure why the original code formatting is screwed up. I look forward to the merge.

Possibly add the test

  if (!is.null(functions)) {
    assertthat::assert_that(
      is.list(functions)
    )
  }

@mpr1255
Copy link

mpr1255 commented Nov 4, 2023

@irudnyts can you merge? This would be really really great.

@irudnyts
Copy link
Owner

irudnyts commented Nov 7, 2023

@irudnyts can you merge? This would be really really great.

@mpr1255 I am really sorry for the delay. I quickly reviewed several PRs. The problem is that there is a certain idea behind this package (i.e., mimic arguments from the official Python package) + certain code style. Rather than modifying someone else's code, for me, it is faster to quickly write my own.

Good news is there are plenty of new endpoints have been introduced and many functions must be depricated. So, I'll do my best to get back on the track and maintain it properly.

If you need those functionality now, you can always use remotes::install_github() and specify @nhardtskim's commit from their fork.

@nhardtskim
Copy link
Author

I do appreciate consistency with openai's python package as an objective, and tried to be close. However, @irudnyts, be careful that, because version 1.0.0 of openai's python package had some breaking changes, and it's a bit of a headache.

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.

4 participants