Add testimonials
This commit is contained in:
parent
06e943d478
commit
40223a12b5
7 changed files with 318 additions and 101 deletions
82
site/site.go
82
site/site.go
|
|
@ -93,7 +93,7 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
prompt = strings.TrimSpace(prompt)
|
||||
prompt = whitespace.ReplaceAllString(prompt, " ")
|
||||
|
||||
site.Occupation, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, rawservice))
|
||||
site.Occupation, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, rawservice), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing service: %w", err)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
e.g. for a web design company, something like "Custom websites cooked to order".
|
||||
Do not include quotes.
|
||||
`)
|
||||
site.Tagline, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation))
|
||||
site.Tagline, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating tagline: %w", err)
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
Markup should be in HTML, including paragraph breaks.
|
||||
Do not wrap in any additional markup.
|
||||
`)
|
||||
whatWeDo, err := cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation))
|
||||
whatWeDo, err := cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), nil)
|
||||
site.WhatWeDo = template.HTML(whatWeDo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating what we do: %w", err)
|
||||
|
|
@ -150,7 +150,7 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
Emphasize the relevance of all the above information to SVS's line of work.
|
||||
Do not shoehorn all the above information; only include each piece if relevant.
|
||||
`)
|
||||
bio, err := cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation))
|
||||
bio, err := cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating Chandler bio: %w", err)
|
||||
}
|
||||
|
|
@ -171,11 +171,11 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
Emphasize the relevance of all the above information to SVS's line of work.
|
||||
Do not include all the above information; only mention each piece if relevant.
|
||||
`)
|
||||
bio, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation))
|
||||
bio, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating Isaac bio: %w", err)
|
||||
return nil, fmt.Errorf("generating Eric bio: %w", err)
|
||||
}
|
||||
site.EricBio = template.HTML(fmt.Sprintf("Eric is a seasoned professional in the %v industry, known for his expertise and dedication.", site.Occupation))
|
||||
site.EricBio = template.HTML(bio)
|
||||
|
||||
prompt = norm(`
|
||||
Generate a short, satirical/irreverent bio (2-4 sentences) for Isaac Swift, a co-founder of SVS, a %v company.
|
||||
|
|
@ -195,31 +195,63 @@ func GenerateSiteData(rawservice string, cp completion.CompletionProvider) (site
|
|||
Emphasize the relevance of all the above information to SVS's line of work.
|
||||
Do not include all the above information; only mention each piece if relevant.
|
||||
`)
|
||||
bio, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation))
|
||||
bio, err = cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating Isaac bio: %w", err)
|
||||
}
|
||||
site.IsaacBio = template.HTML(bio)
|
||||
|
||||
|
||||
|
||||
site.Testimonials = []Testimonial{
|
||||
{
|
||||
Name: "Barack Obama",
|
||||
Position: "Poolhall acquaintance",
|
||||
Quote: "After the fiasco of the ACA Website, I know how important it is to get a website right on the first try, and boy do these gentlemen deliver!",
|
||||
},
|
||||
{
|
||||
Name: "Ada Lovelace",
|
||||
Position: "Pioneer of Computing",
|
||||
Quote: "The elegance and functionality of the websites created by SVS Web Design are truly ahead of their time.",
|
||||
},
|
||||
{
|
||||
Name: "Steve Jobs",
|
||||
Position: "Visionary Entrepreneur",
|
||||
Quote: "Design is not just what it looks like and feels like. Design is how it works. SVS Web Design understands this principle deeply.",
|
||||
prompt = norm(`
|
||||
Generate three satirical testimonials from satisfied clients of SVS, a %v company.
|
||||
Testimonials should be from well-known figures, possibly historical (say, a former US President).
|
||||
When possible, the person quoted should have some tenuous connection to the services provided by SVS.
|
||||
This may be heavily ironic, say Abe Lincoln giving a testimonial for SVS's web design services, or Helen Keller praising their audio engineering.
|
||||
Other possible sources include George Washington, Thomas Edison, Nikola Tesla, Marie Curie, Albert Einstein, Winston Churchill, Franklin D. Roosevelt, John F. Kennedy, Ronald Reagan, Margaret Thatcher, and Martin Luther King Jr.
|
||||
Each testimonial should be 1-2 sentences long, and include an author and their position.
|
||||
For example, if SVS did web design, a testimonial might be from "Barack Obama", a "Poolhall acquaintance":
|
||||
"After the fiasco of the ACA Website, I know how important it is to get a website right on the first try,
|
||||
and boy do these gentlemen deliver!"
|
||||
Do not include quotes around the testimonial text.
|
||||
Return the testimonials in JSON format, as an array of objects with "name", "position", and "quote" properties.
|
||||
`)
|
||||
schema := map[string]any{
|
||||
"name": "testimonials",
|
||||
"strict": true,
|
||||
"schema": map[string]any{
|
||||
"type": "array",
|
||||
"minItems": 3,
|
||||
"maxItems": 3,
|
||||
"items": map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"Name": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Name of the person giving the testimonial",
|
||||
},
|
||||
"Position": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Position or title of the person giving the testimonial",
|
||||
},
|
||||
"Quote": map[string]any{
|
||||
"type": "string",
|
||||
"description": "Testimonial text",
|
||||
},
|
||||
},
|
||||
"required": []string{"Name", "Position", "Quote"},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
},
|
||||
}
|
||||
raw_testimonials, err := cp.Complete(context.TODO(), fmt.Sprintf(prompt, site.Occupation), schema)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating testimonials: %w", err)
|
||||
}
|
||||
fmt.Println("Raw testimonials: %s\n", raw_testimonials)
|
||||
err = json.Unmarshal([]byte(raw_testimonials), &site.Testimonials)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unmarshaling testimonials: %w", err)
|
||||
}
|
||||
|
||||
site.CurrentYear = time.Now().Year()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue