Skip to content

Commit

Permalink
Create integration.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelCurrin authored Jan 8, 2025
1 parent de63af2 commit 702cbb6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cheatsheets/artificial-intelligence/ollama/integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Integration
description: How to integrate the running Ollama service in your application
---


## Use LangChain

```python
from langchain_ollama.llms import OllamaLLM
```

## Use Ollama package

See [ollama-python](https://github.com/ollama/ollama-python) on GitHub.

```python
import ollama

response = ollama.chat(model='llama3.1', messages=[
{
'role': 'user',
'content': 'Why is the sky blue?',
},
])
print(response['message']['content'])
```

## Use cURL

Based on the [Ollama docs](https://github.com/ollama/ollama?tab=readme-ov-file#rest-api):

```sh
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt":"Why is the sky blue?"
}'
```

0 comments on commit 702cbb6

Please sign in to comment.