Giter Club home page Giter Club logo

rgpt3's Issues

Error in core_output$chatgpt_role[i] <- request_content$choices[[i]]$message$role : replacement has length zero

dt_prompts = data.table::data.table('prompts_content' = chatPrompts$ChatGPT_Prompt, 'prompts_role' = chatPrompts$prompts_role,'prompt_id' = chatPrompts$PromptId)
  gptResponse <- chatgpt(prompt_role_var = dt_prompts$prompts_role
          , prompt_content_var = dt_prompts$prompts_content
          , id_var = dt_prompts$prompt_id, param_max_tokens=10000, param_n=5)

when I try to run the above code, it gives this error

Error in core_output$chatgpt_role[i] <- request_content$choices[[i]]$message$role : 
replacement has length zero

GPT-4

Many thanks for a great package! Do you plan to add a request function for GPT-4?

No text returned from API

First-off, thank you for the library.

When I execute core for one request, I am not getting any feedback, it looks empty or am I missing something.

My code:

example_1 = gpt3_single_completion(prompt_input = "Write a cynical text about human nature"
                                   , temperature = 0.7
                                   , max_tokens = 25,
                                   , n = 1)

This is the when I get in return

> example_1
[[1]]
   n                                  prompt
1: 1 Write a cynical text about human nature

[[2]]
                              param_prompt      param_model param_max_tokens param_temperature param_top_p
1: Write a cynical text about human nature text-davinci-003               25               0.7           1
   param_n param_presence_penalty param_frequency_penalty param_best_of
1:       1                      0                       0             1

support Azure AI?

I would like to ask if there are current plans or any plans to support Azure AI. Thank you !

First example doesn't work

The first example gpt3_single_completion throws the following error:

To avoid an `invalid_request_error`, `best_of` was set to equal `n`
Error in core_output$gpt3[i] <- request_content$choices[[i]]$text : 
  replacement has length zero

Maintaining session/context?

Hey thanks for this package. I have 2 questions:

  1. I think this is an API limitation but I'm wondering is there a way to maintain the state/context for each API call, like how the actualy chatgpt can keep each session so that we don't have to repeat what was prompted previously? Basically maintaining historical context.
  2. I notice that for each function call there is a model parameter; I'm assuming we can just input something like gpt4 or whatever model and it should work?

thanks.

Install error

Install error using R 4.1.3

devtools::install_github("ben-aaron188/rgpt3")
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘memoise’

Chatlog/history

Is there a way to pass in history with rgpt3? It seems like you can only pass in a single prompt at a time without inputting previous messages. Thanks!

Attachment support?

Thanks for your contribution with the package. I'm using chatgpt for a research and I need to upload pdf. Any plans in extending the R port with attachments?

Keep getting Error code: 401

When I do

> gpt3_authenticate("./access_key.txt")

I get two rows in the output

[1] "Will use --> sk-xxxxxx for authentication."
[2] "Will use -->  for authentication."   

And when I try and run the chatgpt function, I get this error:

Request completed with error. Code: 401, message: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.

I think somewhere it is setting the key to empty string.

Limited to just 10 responses?

I've tried playing with various parameters, but I seem to be limited to just 10 responses. Is this a limitation or am I doing something stupid?

tweets <- c(
  "Just spilled coffee on myself, not off to a great start",
  "Feeling productive and motivated today!",
  "Got stuck in traffic this morning, already stressed out",
  "Excited to try that new lunch spot everyone's been talking about",
  "Woke up feeling refreshed and ready to take on the day",
  "Feeling overwhelmed with work and deadlines",
  "Finally finished that big project I've been working on for weeks!",
  "Forgot my lunch at home, having a hungry day",
  "Had a great meeting with my boss this morning, feeling appreciated",
  "Feeling under the weather, hoping to get some rest later",
  "Just got a promotion, feeling on top of the world!",
  "Feeling discouraged after getting some negative feedback at work",
  "Met up with an old friend for lunch, feeling grateful for good company",
  "Feeling tired and unmotivated today, need some coffee ASAP",
  "Spent the morning in back-to-back meetings, feeling drained",
  "Received some good news today, feeling optimistic",
  "Feeling stressed about upcoming deadlines, but trying to stay focused",
  "Having a great day so far, feeling productive and energized",
  "Feeling disappointed after not getting that job I applied for",
  "Celebrating a coworker's birthday today, feeling festive"
)

# create a data frame with one column called "tweets"
tweet_data <- data.frame(tweets)

# add a column called "promptID" that contains the row number

tweet_data <- tweet_data %>%
  mutate(promptID = paste0(row_number()))

# Create the root prompt for GPT to apply to each data point
the_prompt_prefix <- "Categorise this tweet whether the tweeter would be happy or not. 
                      Respond with just [positive/negative/neutral] ["
the_prompt_postfix <- "]"

# Make the API request, using the prompts from the data frame
# Note that we are using a different model here, text-ada-001
# Different models cost different amounts of API credits!!!
GPT_tweet_sentiment <- gpt3_completions(prompt_var = paste0(the_prompt_prefix, our_date_data$Date, the_prompt_postfix),
                              id_var = our_date_data$promptID,
                              param_model = 'text-davinci-003',
                              param_max_tokens = 100,
                              param_n = 1,
                              param_temperature = 0.4,
                              )

# use dplyr mutate to add the GPT-3 responses to the data frame
tweet_data <- tweet_data %>%
  mutate(GPT_tweet_sentiment = GPT_tweet_sentiment[[1]]$gpt3)

# Print the data frame
tweet_data```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.