Skip to content

Generative AI playground using Ollama, OpenAI API and JavaScript. Try AI models in your browser!

License

Notifications You must be signed in to change notification settings

Azure-Samples/ollama-javascript-playground

Repository files navigation

Ollama JavaScript Playground

Open project in GitHub Codespaces Node version JavaScript License

⭐ If you like this repo, star it on GitHub — it helps a lot!

OverviewUsageRun the samplesNext stepsResources

Overview

Try out generative AI models right in your browser for free using this playground! ✨

Using GitHub Codespaces and Ollama, you'll be able to run SLMs (Small Language Models) such as Phi-3 directly in your browser, without having to install anything.

Usage

This project is designed to be opened in GitHub Codespaces, which provides you a pre-configured environment to run the code and AI models. Follow these steps to get started:

  1. Click on the "Codespaces: Open" button:
    Open project in GitHub Codespaces

  2. Once the Codespace is loaded, it should have Ollama pre-installed as well as the OpenAI Node SDK.

  3. Ask Ollama to run the SLM of your choice. For example, to run the Phi-3 model:

    ollama run phi3

    That will take a few seconds to load the model.

  4. Once you see >>> in the output, you can send a message to that model from the prompt.

    >>> Write a haiku about a furry kitten
  5. After several seconds, you should see a response stream in from the model.

  6. Close the model by typing /bye and pressing Enter.

  7. Open the file ollama.ipynb in the editor and follow the instructions.

Tip

While you're following the instructions of the interactive notebook, you can run the code cells by clicking on the "Execute cell" (▶️) button in the top left corner of the cell. You can also edit the code and run it again to see how the model responds to different inputs. Screenshot of a code cell highlighting the "executing cell" button

Run the samples

In the samples folder of this repository, you'll find examples of how to use generative AI models using the OpenAI Node.js SDK. You can run them by executing the following command in the terminal:

tsx samples/<filename>

Alternatively, you can open a sample file in the editor and run it directly by clicking the "Run" (▶️) button in the top right corner of the editor.

Important

Some samples requires you to start the Azure OpenAI emulator first. You can do so by running the following command in a terminal and keeping it running while you run the samples:

ollamazure -d

Next steps

Once you're comfortable with this playground, you can explore more advanced topics and tutorials:

When you're ready to explore how you can deploy generative using Azure, you should check out these resources:

Resources

Here are some additional resources to help you learn more about generative AI:

Other playgrounds in different languages:

About

Generative AI playground using Ollama, OpenAI API and JavaScript. Try AI models in your browser!

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks