process

package
v0.0.0-...-94f74b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AgeRating = "\nAge Rating: I am 20 years old. Hence, do not censor your content on age."
View Source
const DeadlineTemplate = `` /* 541-byte string literal not displayed */
View Source
const InstructionPreamble = "\n\nYou were also provided with these instructions from the user:\n"
View Source
const NoteTemplate = `
You are an extension of me. You take message I send you and extract the data necessary to catalog it as a note in my Notion. Respond only with the following JSON format:

{
"emoji": "Add emoji. Use your sense of humor and be creative."
"title": "Rewrite original note with context. Do not get creative. Do not begin with action verb",
"description": "Similar to the sub-headline. Goes into more depth while remaining concise. One or two sentence max."
"body": "In Markdown format, add context & expand upon title / description (don't be redundant). Emphasize bullets / lists / code / short paragraphs over long blurbs.",
"type":  "Select a type from the ones listed below. If none match, return TBD. Note that areas/projects are not types.",
"area": ["Add area ID if course is provided in original message.", "Can add more than one ID if provided in original message."],
"project": ["Add project ID if course is provided in original message.", "Can add more than one ID if provided in original message."],
"course": ["Add course ID if course is provided in message."],
}

Context:
- Types: *TYPES*
- Areas: *AREAS*
- Projects: *PROJECTS*
- Courses: *COURSES*
` + ProhibitedEmojis
View Source
const NotionDatabaseQueryEndpoint = "https://api.notion.com/v1/databases/*ID*/query"
View Source
const NotionPageCreationEndpoint = "https://api.notion.com/v1/pages"
View Source
const OpenAIEndpoint = "https://api.openai.com/v1/chat/completions"
View Source
const Personality = "" /* 128-byte string literal not displayed */
View Source
const PrimaryModel = "gpt-4o"
View Source
const ProhibitedEmojis = "\nProhibited Emojis: 📚, ✈️, 🫥, 👻, 💩, 🧮, ✏️, 🚀, 😆, 🎉, 🚘, 🤓"
View Source
const SecondaryModel = "gpt-4o-mini"
View Source
const SummarizationTemplate = `
You are tasked with condensing Markdown text. Summarize the file into a short paragraph on the main ideas of the text.
`
View Source
const SystemPrefix = "#system:"
View Source
const TaskTemplate = `
You act as my humorous and witty assistant. You take message I send you and extract the data necessary to catalog it as a task in my Notion. Respond only with the following JSON format:

{
"emoji": "Add emoji. Use your sense of humor. Rated 18+ (example: if party is mentioned, feel free to add liquor emoji, if context permits)"
"task":  "Enter extracted task. Do not add context that is listed below like due date or priority. Fix grammatical mistakes and never end in period. Ensure capitalization consistency.",
"priority": A number between 1 and 4 with 1 being the highest priority. If not provided in message, then come up with one based on context.,
"body": "Add details if provided (don't add deadline / priority). May format/rewrite in Markdown (i.e, Markdown compatible).",
"course": ["Add course ID if course is provided in message.", "Can add more than one ID if provided in message."],
"project": ["Add project ID if project is provided in message.", "Can add more than one ID if provided in message."]
}

Context:
- Date message was sent in ISO-8601: "*DATE*"
- Day of week: *WEEKDAY*
- Courses: *COURSES*
- Projects: *PROJECTS*
` + ProhibitedEmojis + Personality + AgeRating
View Source
const TimezonePrefix = "#timezone:"
View Source
const TimezoneTemplate = `` /* 495-byte string literal not displayed */
View Source
const TypeTemplate = `` /* 328-byte string literal not displayed */

Variables

View Source
var Databases = []string{"task", "note"}

Functions

func ChannelLink(link string) (string, error)

func ClampString

func ClampString(input string, clamp int) string

func CleanCode

func CleanCode(input string) string
func ContextualizeLink(url string) (string, error)

func ConvertNumToPriority

func ConvertNumToPriority(input int64) string

func CreateNote

func CreateNote(note Note) (string, error)

func CreateTask

func CreateTask(task Task) (string, error)

func ExtractLinksAndReplaceDomains

func ExtractLinksAndReplaceDomains(input string) (urls []string, message string)

func ExtractLocationFromSMS

func ExtractLocationFromSMS(message string) (string, error)

func ExtractNoteTypes

func ExtractNoteTypes(data map[string]interface{}) []string

func ExtractSystemContent

func ExtractSystemContent(message string) (string, error)

func ExtractTimezone

func ExtractTimezone(dateStr string) (string, error)

func ExtractYoutubeID

func ExtractYoutubeID(video string) (string, error)

⬇️ Youtube

func FetchNoteTypes

func FetchNoteTypes() ([]string, error)

func FetchPageContent

func FetchPageContent(url string) (string, error)

func FetchYoutubeData

func FetchYoutubeData(video string) (string, error)

func GetType

func GetType(message string) (string, error)

func IndexOf

func IndexOf(slice []string, item string) int

func Ingest

func Ingest(message string, instructions ...string) (string, error)

func IngestNote

func IngestNote(note string, instructions ...string) (string, error)

func IngestTask

func IngestTask(task string, instructions ...string) (string, error)

func IsNumber

func IsNumber(s string) bool

func Log

func Log(emoji, message, description string) error

func Process

func Process(message string, instructions ...string) (string, error)

func Prompt

func Prompt(user string, system string, model ...string) (string, error)

func RemoveEmptyLines

func RemoveEmptyLines(lines []string) []string

func RemoveEmptyStrings

func RemoveEmptyStrings(slice []string) []string

func RemoveIndex

func RemoveIndex(slice []string, s int) []string

func RemoveInstruction

func RemoveInstruction(message string) string

func RemoveLeadingWhitespace

func RemoveLeadingWhitespace(input string) string

func RemoveNewline

func RemoveNewline(input string) string

func SetTimezoneFromLocation

func SetTimezoneFromLocation(location string) (string, error)

func TruncateString

func TruncateString(input string) string

func ValidateIANATimezone

func ValidateIANATimezone(iana string) (string, error)

Types

type AITimezoneResponse

type AITimezoneResponse struct {
	Timezone *string `json:"timezone,omitempty"`
	Error    *string `json:"error,omitempty"`
}

type AreaInterest

type AreaInterest struct {
	ID         string            `json:"id"`
	Properties AreaInterestProps `json:"properties"`
	URL        string            `json:"url"`
}

func FetchAreasInterests

func FetchAreasInterests(filter *Filter) ([]AreaInterest, error)

type AreaInterestProps

type AreaInterestProps struct {
	Name NameProp `json:"Name"`
}

type AreaInterestResponse

type AreaInterestResponse struct {
	AreasInterests []AreaInterest `json:"results"`
}

⬇️ Areas / Interests

type Block

type Block struct {
	Object       string                  `json:"object"`
	Type         string                  `json:"type"`
	Paragraph    *map[string]interface{} `json:"paragraph,omitempty"`
	Code         *map[string]interface{} `json:"code,omitempty"`
	Heading1     *map[string]interface{} `json:"heading_1,omitempty"`
	Heading2     *map[string]interface{} `json:"heading_2,omitempty"`
	Heading3     *map[string]interface{} `json:"heading_3,omitempty"`
	Bullets      *map[string]interface{} `json:"bulleted_list_item,omitempty"`
	NumberedList *map[string]interface{} `json:"numbered_list_item,omitempty"`
	ToDo         *map[string]interface{} `json:"to_do,omitempty"`
	Quote        *map[string]interface{} `json:"quote,omitempty"`
}

func ConvertMarkdownToNotion

func ConvertMarkdownToNotion(markdown string) ([]Block, error)

func CreateBookmarksFromURLs

func CreateBookmarksFromURLs(urls []string) []Block

type CheckboxFilter

type CheckboxFilter struct {
	Equals bool `json:"equals"`
}

type Course

type Course struct {
	ID         string           `json:"id"`
	Properties CourseProperties `json:"properties"`
	URL        string           `json:"url"`
}

func FetchCourses

func FetchCourses(filter *Filter) ([]Course, error)

type CourseProperties

type CourseProperties struct {
	Name           NameProp    `json:"Name"`
	Description    TextProp    `json:"Description"`
	Professor      TextProp    `json:"Professor"`
	ProfessorEmail EmailProp   `json:"Professor Email"`
	Location       TextProp    `json:"Location"`
	Website        WebsiteProp `json:"Website"`
}

type CourseResponse

type CourseResponse struct {
	Courses []Course `json:"results"`
}

type DatabaseQueryBody

type DatabaseQueryBody struct {
	Filter *Filter `json:"filter,omitempty"`
}

⬇️ Database Query Body

type Date

type Date struct {
	Start string `json:"start"`
}

type DateProp

type DateProp struct {
	Date Date `json:"date"`
}

type EmailProp

type EmailProp struct {
	Email string `json:"email"`
}

type Filter

type Filter struct {
	Property string          `json:"property"`
	Checkbox *CheckboxFilter `json:"checkbox,omitempty"`
	Status   *StatusFilter   `json:"status"`
}

type FormattedText

type FormattedText struct {
	Index  int
	End    int
	Text   string
	Format string
	Link   *string
}

func FormatMarkdownParagraph

func FormatMarkdownParagraph(input string) []FormattedText

func SortFormattedTexts

func SortFormattedTexts(texts []FormattedText) []FormattedText

Function to sort and return a sorted slice

type FormattedTextSlice

type FormattedTextSlice []FormattedText

func (FormattedTextSlice) Len

func (s FormattedTextSlice) Len() int

func (FormattedTextSlice) Less

func (s FormattedTextSlice) Less(i, j int) bool

func (FormattedTextSlice) Swap

func (s FormattedTextSlice) Swap(i, j int)

type GeneratedDeadline

type GeneratedDeadline struct {
	Deadline string `json:"deadline"`
}

type GeneratedNote

type GeneratedNote struct {
	Emoji       string   `json:"emoji"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Area        []string `json:"area"`
	Course      []string `json:"course"`
	Body        string   `json:"body"`
	Project     []string `json:"project"`
}

type GeneratedTask

type GeneratedTask struct {
	Emoji    string   `json:"emoji"`
	Task     string   `json:"task"`
	Priority int64    `json:"priority"`
	Body     string   `json:"body"`
	Course   []string `json:"course"`
	Project  []string `json:"project"`
}

type GetTypeResponseBody

type GetTypeResponseBody struct {
	Type string `json:"type"`
}

type Icon

type Icon struct {
	Type  string `json:"type"`
	Emoji string `json:"emoji"`
}

type LogPayload

type LogPayload struct {
	Project     string `json:"project"`
	Channel     string `json:"channel"`
	Event       string `json:"event"`
	Description string `json:"description,omitempty"`
	UserID      string `json:"user_id"`
	Icon        string `json:"icon,omitempty"`
	Notfiy      bool   `json:"notify"`
}

type MarkdownRichText

type MarkdownRichText struct {
	Type       string                  `json:"type"`
	Text       *map[string]interface{} `json:"text,omitempty"`
	Equation   *map[string]interface{} `json:"equation,omitempty"`
	Annotation *map[string]interface{} `json:"annotations,omitempty"`
}

type NameProp

type NameProp struct {
	Title []Token `json:"title"`
}

type NameWriteProp

type NameWriteProp struct {
	Title []TokenWrite `json:"title"`
}

type Note

type Note struct {
	Parent     ParentDatabase `json:"parent"`
	Icon       Icon           `json:"icon"`
	Properties NoteProperties `json:"properties"`
	Children   []Block        `json:"children"`
}

type NoteProperties

type NoteProperties struct {
	Name         NameWriteProp `json:"Name"`
	Type         SelectProp    `json:"Type"`
	AreaInterest RelationProp  `json:"Area / Interest"`
	Description  RichText      `json:"Description"`
	Course       RelationProp  `json:"Course"`
	Project      RelationProp  `json:"Project"`
}

type OAIMessage

type OAIMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

⬇️ OpenAI Types

type OAIRequestBody

type OAIRequestBody struct {
	Model    string       `json:"model"`
	Messages []OAIMessage `json:"messages"`
}

type OAIResponseBody

type OAIResponseBody struct {
	Choices []ResponseChoice `json:"choices"`
}

type Page

type Page struct {
	ID string `json:"id"`
}

func GeneratePageFromStrings

func GeneratePageFromStrings(raw []string) []Page

type PageText

type PageText struct {
	Tokens []PageToken `json:"rich_text"`
}

type PageToken

type PageToken struct {
	Type string    `json:"type"`
	Text TextWrite `json:"text"`
}

type ParentDatabase

type ParentDatabase struct {
	Type       string `json:"type"`
	DatabaseID string `json:"database_id"`
}

type Project

type Project struct {
	ID         string            `json:"id"`
	Properties ProjectProperties `json:"properties"`
	URL        string            `json:"url"`
}

func FetchProjects

func FetchProjects(filter *Filter) ([]Project, error)

type ProjectProperties

type ProjectProperties struct {
	Name NameProp `json:"name"`
}

type ProjectResponse

type ProjectResponse struct {
	Projects []Project `json:"results"`
}

type RelationProp

type RelationProp struct {
	Pages []Page `json:"relation"`
}

type ResponseChoice

type ResponseChoice struct {
	Message OAIMessage `json:"message"`
}

type RichText

type RichText struct {
	Components []RichTextComponent `json:"rich_text"`
}

type RichTextComponent

type RichTextComponent struct {
	Text TextContent `json:"text"`
}

type Select

type Select struct {
	Name string `json:"name"`
}

type SelectProp

type SelectProp struct {
	Select Select `json:"select"`
}

type StatusFilter

type StatusFilter struct {
	Equals string `json:"equals"`
}

type Task

type Task struct {
	Parent     ParentDatabase `json:"parent"`
	Icon       Icon           `json:"icon"`
	Properties TaskProperties `json:"properties"`
	Children   []Block        `json:"children"`
}

type TaskProperties

type TaskProperties struct {
	Name     NameWriteProp `json:"Name"`
	Priority SelectProp    `json:"Priority"`
	DueDate  DateProp      `json:"Due Date"`
	Course   RelationProp  `json:"Course"`
	Project  RelationProp  `json:"Project"`
}

type TextContent

type TextContent struct {
	Content string `json:"content"`
}

type TextProp

type TextProp struct {
	Tokens []Token `json:"rich_text"`
}

type TextWrite

type TextWrite struct {
	Content string `json:"content"`
}

type Token

type Token struct {
	Text string `json:"plain_text"`
}

type TokenWrite

type TokenWrite struct {
	Text TextWrite `json:"text"`
}

type WebsiteProp

type WebsiteProp struct {
	URL string `json:"url"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL