Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
madprops committed Apr 22, 2024
1 parent e73e3f9 commit c46e3b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 39 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,6 @@ airc only recognizes certain models, it doesn't have access to the full extent o

As of now, they are: `turbo_instruct` and `turbo` (3.5 models).

airc has internal methods to interface with openai.

The method it uses depends on the model.

Some models get deprecated and are to be removed.

Some might get added over time as they appear and become useful.
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
],
"port": 6667,
"nickname": "airc-bot",
"model": "turbo_instruct",
"model": "turbo",
"max_tokens": 200,
"max_prompt": 350,
"max_rules": 350,
Expand Down
44 changes: 10 additions & 34 deletions modules/openai.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
module.exports = (App) => {
App.models = {
turbo_instruct: {
name: `gpt-3.5-turbo-instruct`,
method: 1,
},
turbo: {
name: `gpt-3.5-turbo`,
method: 2,
},
gpt_4: {
name: `gpt-4`,
method: 2,
},
gpt_4_turbo: {
name: `gpt-4-turbo-preview`,
method: 2,
},
}

Expand All @@ -31,37 +24,20 @@ module.exports = (App) => {

App.ask_openai = async (prompt, callback) => {
let model = App.models[App.config.model]
App.log(`Model: ${model.name} | Method: ${model.method}`)
App.log(`Model: ${model.name}`)

try {
if (model.method === 1) {
let ans = await App.openai_client.chat.completions.create({
model: model.name,
prompt: prompt,
max_tokens: App.config.max_tokens,
})

if (ans.status === 200) {
let text = ans.data.choices[0].text.trim()

if (text) {
callback(text)
}
}
}
else if (model.method === 2) {
let ans = await App.openai_client.chat.completions.create({
model: model.name,
messages: [{role: `user`, content: prompt}],
max_tokens: App.config.max_tokens,
})
let ans = await App.openai_client.chat.completions.create({
model: model.name,
messages: [{role: `user`, content: prompt}],
max_tokens: App.config.max_tokens,
})

if (ans && ans.choices) {
let text = ans.choices[0].message.content.trim()
if (ans && ans.choices) {
let text = ans.choices[0].message.content.trim()

if (text) {
callback(text)
}
if (text) {
callback(text)
}
}
}
Expand Down

0 comments on commit c46e3b9

Please sign in to comment.