Skip to content

Instantly share code, notes, and snippets.

@ddanielsantos
Last active August 19, 2024 17:07
Show Gist options
  • Save ddanielsantos/e252670ab43db2757a484de75853f36e to your computer and use it in GitHub Desktop.
Save ddanielsantos/e252670ab43db2757a484de75853f36e to your computer and use it in GitHub Desktop.
async function generate_embeddings(input) {
const response = await fetch('http://localhost:11434/api/embeddings', {
method: 'POST',
body: JSON.stringify({ model: 'nomic-embed-text', prompt: input }),
headers: { "Content-Type": "application/json" },
});
const response_json = await response.json();
return response_json.embedding;
}
(async () => {
const embeddings = await generate_embeddings("my awesome string is made up of chars");
console.log(embeddings)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment