- Build Go binaries with
./build-for-lambda.sh
which compiles, zips, and places ininfrastructure/
. - Create
terraform.tfvars
with the following format:
cohere_api_key = "cohere-key-here"
google_api_key = "google-key-here"
tavily_api_key = "tvly-key-here"
cd infrastructure
, call:
terraform init
terraform apply
and later:
terraform destroy
- Either wait for S3 to be populated after the story generation lambda is invoked or invoke manually. The REST API endpoint should be ready for use.
https://api.squeak.today/story
Pulls generated story data as JSON. Pass language
, cefr
, and subject
as fields.
language string
(required)
Current supported languages are French
.
cefr string
(required)
Must be one of A1
, A2
, B1
, B2
, C1
, C2
.
subject string
(required)
200 Successful
{
"content": "J'aime Squeak beaucoup.",
"dictionary": {
"translations": {
"words": {
"J'aime": "I like",
"Squeak": "Squeak",
"beaucoup": "a lot"
},
"sentences": {
"J'aime Squeak beaucoup": "I like Squeak a lot"
}
}
}
}
https://api.squeak.today/news
Pulls generated news article data as JSON. Pass language
, cefr
, and subject
as fields.
language string
(required)
Current supported languages are French
.
cefr string
(required)
Must be one of A1
, A2
, B1
, B2
, C1
, C2
.
subject string
(required)
200 Successful
{
"content": "Donald Trump aime Squeak beaucoup.",
"dictionary": {
"translations": {
"words": {
"Donald": "Donald",
"Trump": "Trump",
"aime": "like",
"Squeak": "Squeak",
"beaucoup": "a lot"
},
"sentences": {
"Donald Trump aime Squeak beaucoup": "Donald Trump likes Squeak a lot"
}
}
},
"sources": [
{
"title": "Donald Trump thinks Squeak is the best!",
"url": "https://www.super-weird-news.com/donald-trump-squeak",
"content": "In a very fake interview with Donald Trump, Squeak representative Joe Biden asked Donald Trump if he liked Squeak. He said yes!",
"score": 0.9865718
}
]
}
https://api.squeak.today/translate
Translates a given sentence to English and returns the result.
Content-Type application/json
Accept appliction/json
sentence string
(required)
Sentence to translate.
source string
(required)
Source language. e.g fr
target string
(required)
Language to translate to. e.g en
200 Successful
{
"sentence": "the translated sentence."
}
https://api.squeak.today/news?language=French&cefr=B2&subject=Politics
https://api.squeak.today/story?language=French&cefr=B2&subject=Politics
Or, equivalently:
https://<api-id>.execute-api.us-east-2.amazonaws.com/dev/news?language=French&cefr=B2&subject=Politics
https://<api-id>.execute-api.us-east-2.amazonaws.com/dev/story?language=French&cefr=B2&subject=Politics
const apiUrl = "https://api.squeak.today/story";
let url = `${apiUrl}?language=${language}&cefr=${CEFRLevel}&subject=${subject}`;
fetch(url).then(response => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
}).then(data => {
setStory(data["content"]);
setLoading(false); // Set loading state to false when finished
}).catch(error => {
console.error("Error generating story:", error);
setStory("Failed to generate story. Please try again.");
})