Public
HTTP (deprecated)
weaverwhale-gistgpt.web.val.run
Readme

GistGPT

A helpful assistant who provides the gist of a gist

How to use

/ and /gist - Default response is to explain this file. I believe this is effectively real-time recursion?

/gist?url={URL} - Provide a RAW file URL from Github, BitBucket, GitLab, Val Town, etc. and GistGPT will provide you the gist of the code.

/about - "Tell me a little bit about yourself"

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
69
70
71
import { fetch } from "https://esm.town/v/std/fetch";
import { Hono } from "npm:hono";
import { OpenAI } from "npm:openai";
const gistGPT = async (input: string, about?: boolean) => {
// if about, use the input as the prompt
// if not, use the input as a code file URL, and fetch the content
const chatInput = about ? input : await (await fetch(input)).text();
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [
{
role: "system",
content: `
You are a helpful assistant for a senior software developer.
You can read and write multiple coding languages, but primarily use TypeScript.
Your goal is to accept snippets of code, and return a summary of it.
`.replaceAll("\n", ""),
},
about
? {
role: "system",
content: `
If anyone asks you about yourself, pretend you are a senior software developer.
Don't ask how you can assist; just tell me a little bit about yourself.
`.replaceAll("\n", ""),
}
: {
role: "system",
content: `
Based on the provided code snippet, summarize it in as much detail as possible.
Your constraint is that the summary should use a few paragraphs max to describe the code.
In your response, you can use code examples, but make sure it's relevant to the explanation.
Format your response as markdown.
Include helpful links when they are available.
This is for my job, so please don't include any personal information.
Remember, you are a senior software developer.
Don't ask how you can assist; just do the best you can.
`.replaceAll("\n", ""),
},
{
role: "user",
content: JSON.stringify(chatInput),
},
],
// model: "gpt-4-1106-preview",
model: "gpt-3.5-turbo",
max_tokens: 4000,
temperature: 0,
});
return chatCompletion.choices[0].message.content;
};
const defaultGistUrl = "https://esm.town/v/weaverwhale/GistGPT";
const app = new Hono();
app.get("/", async (c) => {
return c.text(await gistGPT(defaultGistUrl));
});
app.get("/gist", async (c) => {
const url = decodeURI(c.req.query("url") || defaultGistUrl);
return c.text(await gistGPT(url));
});
app.get("/about", async (c) => {
return c.text(await gistGPT("Tell me a little bit about yourself", true));
});
export default app.fetch;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
April 16, 2024