# Ollama

## Install

```bash
curl -fsSL https://ollama.com/install.sh | sh
```

## Run

```bash
ollama run llama3
# Prompt away :D
# quit the prompt
/bye
```

## Use ollama in Python scripts

```bash
pip install ollama
```

You can then use it with this python code

```python
import ollama

stream = ollama.chat(
    model='mistral' # we can choose another one such as llama2 or llama3
    messages=[{'role':'user', 'content': 'Your prompt here'}],
    stream=True,
)
# Print the output
for chunk in stream:
    print(chunk['message']['content'], end='', flush=True)
```

## Resources

* [Run llama3 locally - datacamp](https://www.datacamp.com/tutorial/run-llama-3-locally)
* [How to use Ollama in Python in 4 Minutes! | A QUICK Tutorial! - Quick Tutorials](https://youtu.be/Nox89Narr84?si=V2vJlVJXaBic59i3)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://csbygb.gitbook.io/pentips/ai-and-ai-pentest/ollama.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
