mirror of
https://github.com/ollama/ollama.git
synced 2025-05-12 19:07:06 +02:00
rename dirs
Signed-off-by: Matt Williams <m@technovangelist.com>
This commit is contained in:
parent
a85329f59a
commit
cdf5e106ae
42 changed files with 0 additions and 0 deletions
17
examples/python-dockerit/dockerit.py
Normal file
17
examples/python-dockerit/dockerit.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import requests, json, docker, io, sys
|
||||
inputDescription = " ".join(sys.argv[1:])
|
||||
imageName = input("Enter the name of the image: ")
|
||||
client = docker.from_env()
|
||||
s = requests.Session()
|
||||
output=""
|
||||
with s.post('http://localhost:11434/api/generate', json={'model': 'dockerit', 'prompt': inputDescription}, stream=True) as r:
|
||||
for line in r.iter_lines():
|
||||
if line:
|
||||
j = json.loads(line)
|
||||
if "response" in j:
|
||||
output = output +j["response"]
|
||||
output = output[output.find("---start")+9:output.find("---end")-1]
|
||||
f = io.BytesIO(bytes(output, 'utf-8'))
|
||||
client.images.build(fileobj=f, tag=imageName)
|
||||
container = client.containers.run(imageName, detach=True)
|
||||
print("Container named", container.name, " started with id: ",container.id)
|
Loading…
Add table
Add a link
Reference in a new issue