Skip to content

Commit 3c2ce12

Browse files
committed
examples/llm: init
Signed-off-by: Danielle Lancashire <[email protected]>
1 parent 6c41448 commit 3c2ce12

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

examples/llm/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__pycache__
2+
*.wasm
3+
.spin

examples/llm/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Spin python Hello World
2+
3+
A simple example showcasing the return of a simple response to a request in the Spin Python SDK.

examples/llm/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from spin_http import Response
2+
from spin_llm import llm_infer
3+
4+
5+
def handle_request(request):
6+
prompt="You are a smart bot. What is a smart bots favorite joke?"
7+
result=llm_infer("llama2-chat", prompt)
8+
return Response(200,
9+
{"content-type": "text/plain"},
10+
bytes(result.text, "utf-8"))

examples/llm/spin.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
spin_manifest_version = "1"
2+
authors = ["Fermyon Engineering <[email protected]>"]
3+
description = "Spin Python SDK hello llm"
4+
name = "spin-py-hello-llm"
5+
trigger = { type = "http", base = "/" }
6+
version = "0.1.0"
7+
8+
[[component]]
9+
id = "python-sdk-example"
10+
source = "app.wasm"
11+
ai_models = ["llama2-chat"]
12+
[component.trigger]
13+
route = "/..."
14+
[component.build]
15+
command = "spin py2wasm app -o app.wasm"
16+
watch = ["app.py"]

0 commit comments

Comments
 (0)