From f438fb73411c0ed3b5a72a46e594ef4f820fafa3 Mon Sep 17 00:00:00 2001 From: Alex Page Date: Wed, 29 Mar 2023 00:12:42 -0400 Subject: [PATCH] =?UTF-8?q?Upgrade=20to=20GPT-4=20=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- src/main.rs | 3 +++ src/personality.rs | 7 ++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3bdcc68..95b242d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ parking_lot = "0.12.1" poise = "0.5.2" tracing = "0.1.37" tracing-futures = "0.2.5" -openai = "1.0.0-alpha.6" +openai = "1.0.0-alpha.8" rand = "0.8.5" thiserror = "1.0.39" diff --git a/src/main.rs b/src/main.rs index e1640a3..3b171b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod personality; mod queue; use commands::*; +use openai::set_key; use tracing_subscriber::{fmt, prelude::*, EnvFilter}; use std::{env, sync::Arc}; @@ -48,6 +49,8 @@ async fn main() -> Result<()> { .with(EnvFilter::from_default_env()) .init(); + set_key(env::var("OPENAI_KEY").expect("Expected an OpenAI key in the environment: OPENAI_KEY")); + let token = env::var("DISCORD_TOKEN").expect("Expected a bot token in the environment: DISCORD_TOKEN"); diff --git a/src/personality.rs b/src/personality.rs index f95b634..8f2203c 100644 --- a/src/personality.rs +++ b/src/personality.rs @@ -1,8 +1,5 @@ use anyhow::{Context, Result}; -use openai::{ - chat::{ChatCompletion, ChatCompletionMessage}, - models::ModelID, -}; +use openai::chat::{ChatCompletion, ChatCompletionMessage}; use rand::seq::SliceRandom; const LOADING_MESSAGES: [&str; 20] = [ @@ -57,7 +54,7 @@ pub async fn get_sassy_commentary(title: &str) -> Result { let prompt = format!("Play \"{title}\""); let completion = ChatCompletion::builder( - ModelID::Gpt3_5Turbo, + "gpt-4", [ system .into_iter()