ben-aaron188 / rgpt3 Goto Github PK
View Code? Open in Web Editor NEWMaking requests from R to the GPT models
License: GNU General Public License v3.0
Making requests from R to the GPT models
License: GNU General Public License v3.0
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?
I would like to ask if there are current plans or any plans to support Azure AI. Thank you !
when i try changing model to gpt-4-turbo, it runs fine
but shows the error "The model
is not supported or contains a typo."
I know that the rgpt3 API docs does not show this model in the supported list
But I am assuming this is a pass thru? and the error message is harmless?
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
The ChatGPT API is out - would be very nice to have ChatGPT support :-)
https://openai.com/blog/introducing-chatgpt-and-whisper-apis
I can help you contribute if needed!
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.
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
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```
Hey thanks for this package. I have 2 questions:
thanks.
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’
Many thanks for a great package! Do you plan to add a request function for GPT-4?
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
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.