-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatlas.quarto_ipynb
More file actions
146 lines (146 loc) · 3.38 KB
/
chatlas.quarto_ipynb
File metadata and controls
146 lines (146 loc) · 3.38 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: \"chatlas LLM pacakge for Python\"\n",
"\n",
"execute:\n",
" warning: false\n",
" error: false\n",
"\n",
" \n",
"format:\n",
" html:\n",
" toc: true\n",
" toc-location: right\n",
" code-fold: show\n",
" code-tools: true\n",
" number-sections: true\n",
" code-block-bg: true\n",
" code-block-border-left: \"#31BAE9\"\n",
"---\n",
"\n",
"chatlas provides a simple and unified interface across large language model (llm) providers in Python. \n",
"\n",
"{width=\"260\"}\n",
"\n",
"\n",
"```{bash}\n",
"#| eval: false\n",
"pip3 install -U chatlas\n",
"pip3 install -q -U google-genai\n",
"pip3 install shiny\n",
"pip3 install keyring\n",
"```"
],
"id": "56885a8f"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"from chatlas import ChatGoogle,token_usage\n",
"import keyring"
],
"id": "9efb6193",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Google gemini"
],
"id": "09c7df20"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"from chatlas import ChatGoogle\n",
"\n",
"chat_google_model = ChatGoogle(\n",
" model = \"gemini-2.0-flash\",\n",
" api_key=keyring.get_password(\"system\", \"google_ai_api_key\"),\n",
" system_prompt = \"You are a IT expert\",\n",
")\n",
"\n",
"chat_google_model"
],
"id": "9b0d999f",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {},
"source": [
"result=chat_google_model.chat(\"What preceding languages most influenced Python?\")\n",
"result"
],
"id": "13fc9296",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Interactive mode"
],
"id": "d35ae1f7"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"#chat_google_model.app()"
],
"id": "7b2fe6c3",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# console mode"
],
"id": "bf069658"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"#chat_google_model.console()"
],
"id": "5f77b18a",
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# reference\n",
"\n",
"https://ellmer.tidyverse.org/"
],
"id": "56ad68dc"
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3 (ipykernel)",
"path": "/Library/Frameworks/Python.framework/Versions/3.13/share/jupyter/kernels/python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}