Skip to content

Commit

Permalink
Migrate to GPT-4o.
Browse files Browse the repository at this point in the history
  • Loading branch information
baobabKoodaa committed Jun 18, 2024
1 parent ed89f24 commit 00a3489
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Try it here: [https://future.attejuvonen.fi](https://future.attejuvonen.fi)

### Dev

1. Set up environment variables
1. Set up environment variables (e.g. in /.vscode/launch.json)
- OPENAI_API_KEY
- OPENAI_ORGANIZATION
- LOG_ENDPOINT

2. Run server.js with node v17
2. Run server.js with node v17 (e.g. with VSCode run -> run without debugging)

3. Open http://localhost:3000

Expand Down
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kill_timeout = 5
processes = []

[build]
builder = "heroku/buildpacks:20"
builder = "heroku/builder:24"

[env]
PORT = "8080"
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,9 @@ <h1>
return Math.round(Math.random() * 40)
}
if (['.', '?', '!'].includes(nextChar)) {
return 300 + Math.round(Math.random() * 500)
return 150 + Math.round(Math.random() * 250)
}
return Math.round(Math.random() * 120)
return Math.round(Math.random() * 60)
}

const stopSpinner = () => {
Expand Down
8 changes: 6 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import PROMPT_QA_EXAMPLES from "./prompt-qa-examples.js";

const PROMPT_INSTRUCTIONS = fs.readFileSync('prompt-instructions.txt', 'utf8');

if (!process.env.OPENAI_ORGANIZATION || !process.env.OPENAI_API_KEY) {
throw new Error('Missing env variables for OpenAI authentication!')
}

const configuration = new Configuration({
organization: process.env.OPENAI_ORGANIZATION,
apiKey: process.env.OPENAI_API_KEY
Expand Down Expand Up @@ -100,7 +104,7 @@ const constructPromptChatGPT = (PROMPT_INSTRUCTIONS, PROMPT_QA_EXAMPLES, session

const smokeTestAPI = async () => {
try {
const response = await openai.retrieveModel("text-davinci-003");
const response = await openai.retrieveModel("gpt-4o-2024-05-13");
} catch (error) {
serverStatusGreen = false
const errorMessage = error.response ? (error.response.status + error.response.data) : error.message
Expand All @@ -122,7 +126,7 @@ const getResponse = async (PROMPT_INSTRUCTIONS, PROMPT_QA_EXAMPLES, sessionHisto
}
try {
const response = await openai.createChatCompletion({
model: "gpt-3.5-turbo-0301",
model: "gpt-4o-2024-05-13",
messages: messages,
max_tokens: 256,
temperature: 0.4
Expand Down

0 comments on commit 00a3489

Please sign in to comment.