Skip to content

Commit

Permalink
switcharoo + tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisfiregamer1 committed Apr 9, 2024
1 parent 9854186 commit 12efc0c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
38 changes: 28 additions & 10 deletions bots/gpt_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ export const information: types.information = {
env: ["OPENAI_API_KEY"],
functions: true,
functionsData: tools,
multiModal: false,
multiModal: true,
callbackSupport: true,
streamingSupport: false,
id: "gpt4",
name: "GPT-4",
description:
"An upgraded version of ChatGPT (GPT-3.5). Much better at answering questions!",
description: "OpenAI's most powerful model, with vision support.",
highCostLLM: true,
};

Expand Down Expand Up @@ -96,27 +95,46 @@ export async function send(
if (messages.length === 0) {
messages.push({
role: "system",
content: "You are ChatGPT, an LLM by OpenAI.",
content: [{
type: "text",
text: "You are ChatGPT, an LLM by OpenAI.",
}],
});
}

if (prompt) {
messages.push({
role: "user",
content: prompt,
const prompt_data: types.ContentPart[] = [];

if (prompt !== null) {
prompt_data.push({
type: "text",
text: prompt,
});
}

requirements.images?.forEach((image_url) => {
prompt_data.push({
type: "image_url",
image_url: {
url: image_url,
},
});
});

messages.push({
role: "user",
content: prompt_data,
});

const res = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${requirements?.env.OPENAI_API_KEY}`,
},
body: JSON.stringify({
model: "gpt-4-turbo-preview",
model: "gpt-4-turbo",
messages: messages,
tools,
tools
}),
});

Expand Down
41 changes: 12 additions & 29 deletions bots/gpt_4_vision.ts → bots/gpt_4.ts.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export const information: types.information = {
env: ["OPENAI_API_KEY"],
functions: true,
functionsData: tools,
multiModal: true,
multiModal: false,
callbackSupport: true,
streamingSupport: false,
id: "gpt4v",
name: "GPT-4 Vision",
description: "A further upgraded version of GPT-4 with vision capabilities.",
id: "gpt4",
name: "GPT-4",
description:
"An upgraded version of ChatGPT (GPT-3.5). Much better at answering questions!",
highCostLLM: true,
};

Expand Down Expand Up @@ -95,45 +96,27 @@ export async function send(
if (messages.length === 0) {
messages.push({
role: "system",
content: [{
type: "text",
text: "You are ChatGPT, an LLM by OpenAI.",
}],
content: "You are ChatGPT, an LLM by OpenAI.",
});
}

const prompt_data: types.ContentPart[] = [];

if (prompt !== null) {
prompt_data.push({
type: "text",
text: prompt,
if (prompt) {
messages.push({
role: "user",
content: prompt,
});
}

requirements.images?.forEach((image_url) => {
prompt_data.push({
type: "image_url",
image_url: {
url: image_url,
},
});
});

messages.push({
role: "user",
content: prompt_data,
});

const res = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${requirements?.env.OPENAI_API_KEY}`,
},
body: JSON.stringify({
model: "gpt-4-vision-preview",
model: "gpt-4-turbo-preview",
messages: messages,
tools,
}),
});

Expand Down

0 comments on commit 12efc0c

Please sign in to comment.