File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed
Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ __pycache__
2+ * .wasm
3+ .spin
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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" ))
Original file line number Diff line number Diff line change 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" ]
You can’t perform that action at this time.
0 commit comments