Hi,
I’m trying to build an extraction function, here is our data:
I want to find coffee shop in Helsinki
Find: Coffee shop; Location: Helsinki;
---
Looking for pizza near Espoo
Find: Pizza; Location: Espoo;
---
Strawberry smoothie, Vantaa
Find: Strawberry smoothie; Location: Vantaa;
---
We are looking for blackberry salad restaurants to work at Lahti, 500€/week
Find:
It works great on Playground:
But when I generate code, running it will return error: "Invalid Json syntax"
Prediction: undefined
Code generated:
const cohere = require('cohere-ai');
cohere.init('{apiKey}');
(async () => {
const response = await cohere.generate('medium-20220217', {
prompt: 'I want to find coffee shop in Helsinki\nFind: Coffee shop; Location: Helsinki;\n---\nLooking for pizza near Espoo\nFind: Pizza; Location: Espoo;\n---\nStrawberry smoothie, Vantaa\nFind: Strawberry smoothie; Location: Vantaa;\n---\nWe are looking for blackberry salad restaurants to work at Lahti, 500€/week\nFind:',
max_tokens: 30,
temperature: 0.2,
k: 1,
p: 0.9,
frequency_penalty: 0,
presence_penalty: 0,
stop_sequences: ["---"],
return_likelihoods: 'NONE'
});
console.log(`Prediction: ${response.body.generations[0].text}`);
})();
But if I delete the long prompt and replace with something "Short text here"
, it works fine again.
Prediction: [
{
id: '1311cfec-926f-4041-bacd-d45e08ea13ec',
text: ' about the product.\n' +
'Short text here about the product.\n' +
'Short text here about the product.\n' +
'Short text here about the product.\n' +
'Short'
}
]
Please help me, what did I do wrong?