Skip to content

Commit

Permalink
Modal labs python docs (nomic-ai#558)
Browse files Browse the repository at this point in the history
* Added modal labs example to documentation

* Modal snippet update docs

---------

Signed-off-by: Andriy Mulyar <[email protected]>
  • Loading branch information
AndriyMulyar authored May 13, 2023
1 parent d94f37c commit f455b2f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions gpt4all-bindings/python/docs/gpt4all_modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ def download_model():
return gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")

image=modal.Image.debian_slim().pip_install("gpt4all").run_function(download_model)

stub = modal.Stub("gpt4all", image=image)

@stub.cls(keep_warm=1)
class GPT4All:
def __enter__(self):
print("Downloading model")
self.gptj = download_model()
print("Loaded model")

@modal.method()
def generate(self):
messages = [{"role": "user", "content": "Name 3 colors"}]
completion = self.gptj.chat_completion(messages)
Expand All @@ -31,5 +30,5 @@ class GPT4All:
def main():
model = GPT4All()
for i in range(10):
model.generate()
model.generate.call()
```

0 comments on commit f455b2f

Please sign in to comment.