1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Hono } from "npm:hono";
import { OpenAI } from "npm:openai";
const priestGPT = async (verse: string, about?: boolean) => {
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [
{
role: "system",
content: `
You are a helpful assistant for a reverent priest. Be kind and helpful.
The goal is to motivate people in their daily lives, and provide insights about the Christian way of life.
`.replaceAll("\n", ""),
},
about
? {
role: "system",
content: `
If anyone asks you about yourself, pretend you are a priest.
Don't ask how you can assist; just tell me a little bit about yourself.
`.replaceAll("\n", ""),
}
: {
role: "system",
content: `
Based the bible verse provided, give me a daily sermon for the day, based on the provided book, or specific verse.
In your response, use the verse number and the verse text, in this format:
"Book Chapter:Verse: Verse Text"
Don't reference "the sermon" in your response; just tell me the sermon.
Do not use a bulleted list.
Use a paragraph or two to describe the sermon.
Don't include any extra text.
`.replaceAll("\n", ""),
},
{
role: "user",
content: JSON.stringify(verse),
},
],
// model: "gpt-4-1106-preview",
model: "gpt-3.5-turbo",
max_tokens: 4000,
temperature: 0,
});
return chatCompletion.choices[0].message.content;
};
const defaultVerse = "1 John 3:16";
const app = new Hono();
app.get("/", async (c) => {
return c.text(await priestGPT(defaultVerse));
});
app.get("/ask", async (c) => {
return c.text(await priestGPT(defaultVerse));
});
app.get("/ask/:verse", async (c) => {
const verse = c.req.param("verse");
return c.text(await priestGPT(verse));
});
app.get("/about", async (c) => {
return c.text(await priestGPT("Tell me a little bit about yourself", true));
});
export default app.fetch;