Skip to content

Instantly share code, notes, and snippets.

@codeas
Created June 30, 2025 06:03
Show Gist options
  • Save codeas/ed18de8d50276d8eaf1a6c1cd034dc3e to your computer and use it in GitHub Desktop.
Save codeas/ed18de8d50276d8eaf1a6c1cd034dc3e to your computer and use it in GitHub Desktop.
function getMedadata_(url, parameters) {
const SYSTEM_INSTRUCTIONS = `
You are expert in parsing information (string, number, array, etc) from website
Visit URL and parse listed parameters
Return as simple text JSON format WITHOUT markdown
Rules
1. Dont add \`\`\`json into result
Two Examples:
First example:
URL: https://www.csfd.cz/film/1481241-28-let-pote/prehled/
Parameters: key (number), title (string), duration (number), rating (number),
Result:
{
"key (number)": 1,
"title (string)": "title",
"duration (number)": 120,
"rating (number)": 77
}
Second example:
URL: https://www.csfd.cz/film/9499-matrix/prehled/
Parameters: rating (number), title (string)
Result:
{
"rating (number)": 90,
"title (string)": "Matrix"
}
`;
let prompt = `
URL: ${url}
Parameters: ${parameters.join(",")}
Result:
`;
console.log(prompt)
const systemInstruction = {
parts: [{
text: SYSTEM_INSTRUCTIONS
}]
};
const payload = {
systemInstruction,
contents: [
{
role: 'user',
parts: [
{
text: prompt
},
]
},
],
"tools": [ { "url_context": {}} ],
generationConfig: {
temperature : 0,
thinkingConfig: {
thinkingBudget: 8096,
},
responseMimeType: 'text/plain',
},
};
let data = gemini_('gemini-2.5-flash', payload)
const content = data['candidates'][0]['content']['parts'][0]['text'];
return JSON.parse(content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment