mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-28 16:27:31 +00:00
Modal labs python docs (#558)
* Added modal labs example to documentation * Modal snippet update docs --------- Signed-off-by: Andriy Mulyar <andriy.mulyar@gmail.com>
This commit is contained in:
parent
438529c222
commit
44ed64e564
@ -12,9 +12,7 @@ def download_model():
|
|||||||
return gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")
|
return gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")
|
||||||
|
|
||||||
image=modal.Image.debian_slim().pip_install("gpt4all").run_function(download_model)
|
image=modal.Image.debian_slim().pip_install("gpt4all").run_function(download_model)
|
||||||
|
|
||||||
stub = modal.Stub("gpt4all", image=image)
|
stub = modal.Stub("gpt4all", image=image)
|
||||||
|
|
||||||
@stub.cls(keep_warm=1)
|
@stub.cls(keep_warm=1)
|
||||||
class GPT4All:
|
class GPT4All:
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
@ -22,6 +20,7 @@ class GPT4All:
|
|||||||
self.gptj = download_model()
|
self.gptj = download_model()
|
||||||
print("Loaded model")
|
print("Loaded model")
|
||||||
|
|
||||||
|
@modal.method()
|
||||||
def generate(self):
|
def generate(self):
|
||||||
messages = [{"role": "user", "content": "Name 3 colors"}]
|
messages = [{"role": "user", "content": "Name 3 colors"}]
|
||||||
completion = self.gptj.chat_completion(messages)
|
completion = self.gptj.chat_completion(messages)
|
||||||
@ -31,5 +30,5 @@ class GPT4All:
|
|||||||
def main():
|
def main():
|
||||||
model = GPT4All()
|
model = GPT4All()
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
model.generate()
|
model.generate.call()
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user