-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path05-extras
More file actions
89 lines (65 loc) · 1.36 KB
/
05-extras
File metadata and controls
89 lines (65 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "llm==0.27.1",
# "llm-openrouter==0.5",
# "marimo",
# "python-dotenv==1.2.1",
# ]
# ///
import marimo
__generated_with = "0.17.8"
app = marimo.App(sql_output="polars")
@app.cell
def _(mo):
mo.md(r"""
## OpenRouter
""")
return
@app.cell
def _():
import marimo as mo
return (mo,)
@app.cell
def _():
import os
from dotenv import load_dotenv
load_dotenv(".env")
return (os,)
@app.cell
def _(llm):
llm.get_model_aliases();
return
@app.cell
def _(os):
import llm
model = llm.get_model("openrouter/moonshotai/kimi-k2-0905")
# key= is optional, you can configure the key in other ways
response = model.prompt(
"Five surprising names for a pet pelican",
key=os.environ.get("OPENROUTER_KEY")
)
print(response.text())
return (llm,)
@app.cell
def _(llm):
new_model = llm.get_model("gpt-4o-mini")
print(new_model.attachment_types)
return (new_model,)
@app.cell
def _(mo):
mo.image("grump.jpg")
return
@app.cell
def _(llm, new_model):
new_resp = new_model.prompt(
"Describe these images",
attachments=[llm.Attachment(path="grump.jpg")]
)
return (new_resp,)
@app.cell
def _(new_resp):
print(new_resp.text())
return
if __name__ == "__main__":
app.run()