mirror of
https://github.com/ollama/ollama-python.git
synced 2026-09-04 18:49:54 +00:00
update to llama3.1 (#237)
This commit is contained in:
@@ -12,7 +12,7 @@ pip install ollama
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
import ollama
|
import ollama
|
||||||
response = ollama.chat(model='llama3', messages=[
|
response = ollama.chat(model='llama3.1', messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
'content': 'Why is the sky blue?',
|
'content': 'Why is the sky blue?',
|
||||||
@@ -29,7 +29,7 @@ Response streaming can be enabled by setting `stream=True`, modifying function c
|
|||||||
import ollama
|
import ollama
|
||||||
|
|
||||||
stream = ollama.chat(
|
stream = ollama.chat(
|
||||||
model='llama3',
|
model='llama3.1',
|
||||||
messages=[{'role': 'user', 'content': 'Why is the sky blue?'}],
|
messages=[{'role': 'user', 'content': 'Why is the sky blue?'}],
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
@@ -45,13 +45,13 @@ The Ollama Python library's API is designed around the [Ollama REST API](https:/
|
|||||||
### Chat
|
### Chat
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.chat(model='llama3', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}])
|
ollama.chat(model='llama3.1', messages=[{'role': 'user', 'content': 'Why is the sky blue?'}])
|
||||||
```
|
```
|
||||||
|
|
||||||
### Generate
|
### Generate
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.generate(model='llama3', prompt='Why is the sky blue?')
|
ollama.generate(model='llama3.1', prompt='Why is the sky blue?')
|
||||||
```
|
```
|
||||||
|
|
||||||
### List
|
### List
|
||||||
@@ -63,14 +63,14 @@ ollama.list()
|
|||||||
### Show
|
### Show
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.show('llama3')
|
ollama.show('llama3.1')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create
|
### Create
|
||||||
|
|
||||||
```python
|
```python
|
||||||
modelfile='''
|
modelfile='''
|
||||||
FROM llama3
|
FROM llama3.1
|
||||||
SYSTEM You are mario from super mario bros.
|
SYSTEM You are mario from super mario bros.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@@ -80,31 +80,31 @@ ollama.create(model='example', modelfile=modelfile)
|
|||||||
### Copy
|
### Copy
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.copy('llama3', 'user/llama3')
|
ollama.copy('llama3.1', 'user/llama3.1')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Delete
|
### Delete
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.delete('llama3')
|
ollama.delete('llama3.1')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pull
|
### Pull
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.pull('llama3')
|
ollama.pull('llama3.1')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Push
|
### Push
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.push('user/llama3')
|
ollama.push('user/llama3.1')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Embeddings
|
### Embeddings
|
||||||
|
|
||||||
```python
|
```python
|
||||||
ollama.embeddings(model='llama3', prompt='The sky is blue because of rayleigh scattering')
|
ollama.embeddings(model='llama3.1', prompt='The sky is blue because of rayleigh scattering')
|
||||||
```
|
```
|
||||||
|
|
||||||
### Ps
|
### Ps
|
||||||
@@ -123,7 +123,7 @@ A custom client can be created with the following fields:
|
|||||||
```python
|
```python
|
||||||
from ollama import Client
|
from ollama import Client
|
||||||
client = Client(host='http://localhost:11434')
|
client = Client(host='http://localhost:11434')
|
||||||
response = client.chat(model='llama3', messages=[
|
response = client.chat(model='llama3.1', messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
'content': 'Why is the sky blue?',
|
'content': 'Why is the sky blue?',
|
||||||
@@ -139,7 +139,7 @@ from ollama import AsyncClient
|
|||||||
|
|
||||||
async def chat():
|
async def chat():
|
||||||
message = {'role': 'user', 'content': 'Why is the sky blue?'}
|
message = {'role': 'user', 'content': 'Why is the sky blue?'}
|
||||||
response = await AsyncClient().chat(model='llama3', messages=[message])
|
response = await AsyncClient().chat(model='llama3.1', messages=[message])
|
||||||
|
|
||||||
asyncio.run(chat())
|
asyncio.run(chat())
|
||||||
```
|
```
|
||||||
@@ -152,7 +152,7 @@ from ollama import AsyncClient
|
|||||||
|
|
||||||
async def chat():
|
async def chat():
|
||||||
message = {'role': 'user', 'content': 'Why is the sky blue?'}
|
message = {'role': 'user', 'content': 'Why is the sky blue?'}
|
||||||
async for part in await AsyncClient().chat(model='llama3', messages=[message], stream=True):
|
async for part in await AsyncClient().chat(model='llama3.1', messages=[message], stream=True):
|
||||||
print(part['message']['content'], end='', flush=True)
|
print(part['message']['content'], end='', flush=True)
|
||||||
|
|
||||||
asyncio.run(chat())
|
asyncio.run(chat())
|
||||||
|
|||||||
Reference in New Issue
Block a user