Skip to content

Commit 006f666

Browse files
committed
feat: vertexai integated with tool calling
1 parent a57b04d commit 006f666

30 files changed

+829
-1315
lines changed

docs/quickstart.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ description: "Let's have you setup LLMstudio"
4545
Using it in a Python notebook is also fairly simple! Just run the following cell:
4646

4747
```python
48-
from llmstudio import LLM
48+
from llmstudio.providers import LLM
4949
model = LLM("anthropic/claude-2.1")
5050
model.chat("What are Large Language Models?")
5151
```

examples/01_intro_to_llmstudio.ipynb

+37-53
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
16-
"from llmstudio import LLM\n",
16+
"from llmstudio.providers import LLM\n",
1717
"from pprint import pprint"
1818
]
1919
},
@@ -43,7 +43,7 @@
4343
{
4444
"data": {
4545
"text/plain": [
46-
"ChatCompletion(id='47c45235-3cba-498a-9bfa-255c3f1b829a', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='I’m called Assistant. How can I help you today?', refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729090941, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output='I’m called Assistant. How can I help you today?', chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729090942.350497, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 12, 'total_tokens': 16, 'cost_usd': 0.0002, 'latency_s': 1.0681071281433105, 'time_to_first_token_s': 0.911978006362915, 'inter_token_latency_s': 0.011577862959641676, 'tokens_per_second': 13.107299475040659})"
46+
"ChatCompletion(id='ec40a65d-77f0-43f3-b78e-510c362a8b65', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"I'm called Assistant. How can I assist you today?\", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729179436, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output=\"I'm called Assistant. How can I assist you today?\", chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729179437.0009851, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 12, 'total_tokens': 16, 'cost_usd': 0.0002, 'latency_s': 0.8632550239562988, 'time_to_first_token_s': 0.7578170299530029, 'inter_token_latency_s': 0.007991174856821695, 'tokens_per_second': 15.059281022682017})"
4747
]
4848
},
4949
"execution_count": 3,
@@ -66,18 +66,7 @@
6666
"cell_type": "code",
6767
"execution_count": 4,
6868
"metadata": {},
69-
"outputs": [
70-
{
71-
"data": {
72-
"text/plain": [
73-
"ChatCompletion(id='65b6f534-3aea-4361-995a-822628ff7950', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"I'm called Assistant or ChatGPT. How can I help you today?\", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729090942, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output=\"I'm called Assistant or ChatGPT. How can I help you today?\", chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729090943.4086301, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 16, 'total_tokens': 20, 'cost_usd': 0.00026000000000000003, 'latency_s': 1.0519328117370605, 'time_to_first_token_s': 0.9430949687957764, 'inter_token_latency_s': 0.007242250442504883, 'tokens_per_second': 15.21009690113111})"
74-
]
75-
},
76-
"execution_count": 4,
77-
"metadata": {},
78-
"output_type": "execute_result"
79-
}
80-
],
69+
"outputs": [],
8170
"source": [
8271
"await openai.achat(\"What's your name\", model=\"gpt-4o\")"
8372
]
@@ -100,29 +89,31 @@
10089
"text": [
10190
"\n",
10291
"\n",
103-
"Space, an immense and enigmatic expanse beyond Earth's atmosphere, captivates the imagination with its bound\n",
92+
"Space, the vast expanse beyond Earth's atmosphere, captivates the human imagination with its infinite possibilities\n",
10493
"\n",
105-
"less mysteries and wonders. It holds stars, planets, galaxies, and countless celestial phenomena that both intrigue\n",
94+
" and mysteries. It is a realm where celestial bodies such as planets, stars, comets, and\n",
10695
"\n",
107-
" and inspire humanity. The vastness of space is punctuated by brilliant constellations, swirling neb\n",
96+
" galaxies reside, each offering a unique insight into the origins and evolution of the universe. Space exploration has\n",
10897
"\n",
109-
"ulae, and the remnants of ancient supernovae, offering clues to the origins of the universe\n",
98+
" propelled technological advancements and fostered international collaboration as scientists and engineers strive to unravel the secrets of cosmic phenomena\n",
11099
"\n",
111-
". Exploration through telescopes and spacecraft expands our understanding, revealing the intricate dance of cosmic bodies and the\n",
100+
" like black holes, dark matter, and the potential for extraterrestrial life. This boundless frontier continues\n",
112101
"\n",
113-
" potential for life beyond our planet. Space challenges us to push technological boundaries and ponder profound questions about our\n",
102+
" to inspire wonder, pushing the boundaries of human knowledge and ambition as we seek to understand our place in\n",
114103
"\n",
115-
" place in the cosmos, making it an endless frontier of discovery and curiosity.\n",
104+
" the cosmos and the potential for future habitation beyond our home planet. With each mission and discovery, space\n",
105+
"\n",
106+
" challenges and expands our perceptions, fueling the quest for discovery and innovation.\n",
116107
"\n",
117108
"## Metrics:\n",
118-
"{'cost_usd': 0.002095,\n",
109+
"{'cost_usd': 0.0024100000000000002,\n",
119110
" 'input_tokens': 8,\n",
120-
" 'inter_token_latency_s': 0.018547398955733686,\n",
121-
" 'latency_s': 3.2096359729766846,\n",
122-
" 'output_tokens': 137,\n",
123-
" 'time_to_first_token_s': 0.7052650451660156,\n",
124-
" 'tokens_per_second': 42.37240644890664,\n",
125-
" 'total_tokens': 145}\n"
111+
" 'inter_token_latency_s': 0.011506473863279664,\n",
112+
" 'latency_s': 2.5703747272491455,\n",
113+
" 'output_tokens': 158,\n",
114+
" 'time_to_first_token_s': 0.7979397773742676,\n",
115+
" 'tokens_per_second': 60.302491444849906,\n",
116+
" 'total_tokens': 166}\n"
126117
]
127118
}
128119
],
@@ -156,40 +147,33 @@
156147
"text": [
157148
"\n",
158149
"\n",
159-
"Space, the vast and seemingly infinite expanse beyond our planet, captivates the imagination and fuels\n",
150+
"Space, the vast and seemingly infinite expanse that extends beyond our planet, captivates the imagination\n",
151+
"\n",
152+
" and fuels our curiosity about the universe. It is a realm where celestial bodies like stars, planets,\n",
160153
"\n",
161-
" human curiosity. It is a realm of celestial wonders, from the swirling galaxies and shimmering stars to the\n",
154+
" and galaxies interact through complex gravitational forces, giving rise to phenomena such as black holes, supernovae\n",
162155
"\n",
163-
" enigmatic black holes and majestic nebulae. In this cosmic backdrop, the laws of physics reign supreme\n",
156+
", and cosmic radiation. The sheer scale of space is mind-boggling—vast distances measured in\n",
164157
"\n",
165-
", governing the motion of planets and the life cycles of stars. Space not only challenges our understanding of\n",
158+
" light-years and the potential for countless worlds yet to be discovered. As humanity ventures further into this un\n",
166159
"\n",
167-
" the universe but also invites exploration, as humanity pushes the boundaries of technology to uncover its secrets. As\n",
160+
"charted territory with missions to distant planets and explorations of exoplanets, we grapple with fundamental questions\n",
161+
"\n",
162+
" about our place in the cosmos and the possibility of life beyond Earth. Each new discovery adds to our\n",
163+
"\n",
164+
" understanding of the origin and evolution of the universe, inspiring dreams of what lies beyond the final frontier.\n",
168165
"\n",
169-
" we gaze at the night sky, we are reminded of our place in the cosmos and the endless possibilities\n",
170166
"\n",
171-
" that lie beyond, beckoning us to explore and discover the mysteries of the universe.\n",
172167
"\n",
173168
"## Metrics:\n",
174-
"{'cost_usd': 8.46e-05,\n",
169+
"{'cost_usd': 9.839999999999999e-05,\n",
175170
" 'input_tokens': 8,\n",
176-
" 'inter_token_latency_s': 0.0063348164523605015,\n",
177-
" 'latency_s': 2.652230739593506,\n",
178-
" 'output_tokens': 139,\n",
179-
" 'time_to_first_token_s': 1.7840969562530518,\n",
180-
" 'tokens_per_second': 52.031672033614456,\n",
181-
" 'total_tokens': 147}\n"
182-
]
183-
},
184-
{
185-
"ename": "",
186-
"evalue": "",
187-
"output_type": "error",
188-
"traceback": [
189-
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
190-
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
191-
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
192-
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
171+
" 'inter_token_latency_s': 0.014622557163238525,\n",
172+
" 'latency_s': 2.8971738815307617,\n",
173+
" 'output_tokens': 162,\n",
174+
" 'time_to_first_token_s': 0.5567238330841064,\n",
175+
" 'tokens_per_second': 55.57139701774939,\n",
176+
" 'total_tokens': 170}\n"
193177
]
194178
}
195179
],

examples/01_intro_to_llmstudio_core.ipynb

+30-34
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [
23-
"from llmstudio_core import LLMCore as LLM\n",
23+
"from llmstudio_core.providers import LLMCore as LLM\n",
2424
"from pprint import pprint"
2525
]
2626
},
@@ -51,7 +51,7 @@
5151
{
5252
"data": {
5353
"text/plain": [
54-
"ChatCompletion(id='e67fd10c-e2d4-442d-9140-1d73d5345e78', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='I’m OpenAI’s language model, and I don’t have a personal name, but you can call me Assistant! How can I help you today?', refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729091027, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output='I’m OpenAI’s language model, and I don’t have a personal name, but you can call me Assistant! How can I help you today?', chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729091027.668681, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 31, 'total_tokens': 35, 'cost_usd': 0.000485, 'latency_s': 0.9814362525939941, 'time_to_first_token_s': 0.5442612171173096, 'inter_token_latency_s': 0.013376839458942413, 'tokens_per_second': 33.624190988236926})"
54+
"ChatCompletion(id='7047f538-e331-4b0e-82d7-7dee0e628efc', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='I’m called Assistant, but you can name me whatever you like! How can I assist you today?', refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729182272, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output='I’m called Assistant, but you can name me whatever you like! How can I assist you today?', chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729182273.070267, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 21, 'total_tokens': 25, 'cost_usd': 0.000335, 'latency_s': 0.9371509552001953, 'time_to_first_token_s': 0.7164719104766846, 'inter_token_latency_s': 0.009395230900157581, 'tokens_per_second': 24.542470849946167})"
5555
]
5656
},
5757
"execution_count": 3,
@@ -78,7 +78,7 @@
7878
{
7979
"data": {
8080
"text/plain": [
81-
"ChatCompletion(id='2abb7143-6fec-453f-a088-8e68bd024450', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"I don't have a personal name, but you can call me Assistant. How can I help you today?\", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729091028, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output=\"I don't have a personal name, but you can call me Assistant. How can I help you today?\", chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729091028.540685, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 22, 'total_tokens': 26, 'cost_usd': 0.00035, 'latency_s': 0.8616046905517578, 'time_to_first_token_s': 0.48931884765625, 'inter_token_latency_s': 0.01686550270427357, 'tokens_per_second': 26.6943764956423})"
81+
"ChatCompletion(id='ac79b4be-d765-4b96-949c-8d5663bab6ae', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=\"I don't have a personal name, but you can call me Assistant. How can I help you today?\", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729182278, model='gpt-4o', object='chat.completion', service_tier=None, system_fingerprint=None, usage=None, chat_input=\"What's your name\", chat_output=\"I don't have a personal name, but you can call me Assistant. How can I help you today?\", chat_output_stream='', context=[{'role': 'user', 'content': \"What's your name\"}], provider='openai', deployment='gpt-4o-2024-08-06', timestamp=1729182283.168303, parameters={}, metrics={'input_tokens': 4, 'output_tokens': 22, 'total_tokens': 26, 'cost_usd': 0.00035, 'latency_s': 5.415894031524658, 'time_to_first_token_s': 5.212275981903076, 'inter_token_latency_s': 0.009226820685646751, 'tokens_per_second': 4.246759605361987})"
8282
]
8383
},
8484
"execution_count": 4,
@@ -108,33 +108,33 @@
108108
"text": [
109109
"\n",
110110
"\n",
111-
"Space, the final frontier, is an awe-inspiring expanse that has captivated human imagination for\n",
111+
"Space, the final frontier, is a vast and mysterious expanse that has captivated human curiosity for\n",
112112
"\n",
113-
" centuries. It is a vast, seemingly infinite realm filled with wonders beyond our full comprehension, from radiant\n",
113+
" centuries. It stretches beyond the grasp of our everyday experiences, an infinite void punctuated by celestial wonders\n",
114114
"\n",
115-
" stars and swirling galaxies to mysterious black holes and distant, perhaps habitable, planets. Space is not\n",
115+
" like stars, galaxies, and planets. The study of space, known as astronomy, allows us to\n",
116116
"\n",
117-
" merely the absence of earthly bounds but a vast, dynamic tapestry woven with the delicate interplay of gravity,\n",
117+
" explore the origins of the universe, the intricacies of cosmic formations, and the potential for life beyond\n",
118118
"\n",
119-
" time, and matter. The exploration of space presents unparalleled opportunities for scientific discovery, technological advancement, and\n",
119+
" Earth. With advancements in technology, such as powerful telescopes and space probes, we continue to unlock\n",
120120
"\n",
121-
" a deeper understanding of our place in the universe. As we venture further into the cosmos, peering\n",
121+
" the secrets of the cosmos, gaining deeper insights into phenomena like black holes, quasars, and super\n",
122122
"\n",
123-
" through sophisticated telescopes and embarking on ambitious missions, space continues to challenge our intellect, inspiring a profound\n",
123+
"novae. Space exploration not only fuels scientific discovery but also inspires a sense of wonder and possibility,\n",
124124
"\n",
125-
" sense of curiosity and a relentless pursuit of knowledge — inviting us to explore its boundless possibilities and seek\n",
125+
" reminding us of our place in the universe and the boundless potential for discovery that lies beyond our home\n",
126126
"\n",
127-
" answers to some of humanity's most fundamental questions.\n",
127+
" planet.\n",
128128
"\n",
129129
"## Metrics:\n",
130-
"{'cost_usd': 0.002635,\n",
130+
"{'cost_usd': 0.0024850000000000002,\n",
131131
" 'input_tokens': 8,\n",
132-
" 'inter_token_latency_s': 0.009682952656465418,\n",
133-
" 'latency_s': 2.4021809101104736,\n",
134-
" 'output_tokens': 173,\n",
135-
" 'time_to_first_token_s': 0.7550098896026611,\n",
136-
" 'tokens_per_second': 71.18531301297199,\n",
137-
" 'total_tokens': 181}\n"
132+
" 'inter_token_latency_s': 0.01804932694376251,\n",
133+
" 'latency_s': 3.679605007171631,\n",
134+
" 'output_tokens': 163,\n",
135+
" 'time_to_first_token_s': 0.754986047744751,\n",
136+
" 'tokens_per_second': 44.29823301205141,\n",
137+
" 'total_tokens': 171}\n"
138138
]
139139
}
140140
],
@@ -174,24 +174,13 @@
174174
"## Metrics:\n",
175175
"{'cost_usd': 6.45e-06,\n",
176176
" 'input_tokens': 3,\n",
177-
" 'inter_token_latency_s': 0.02283191680908203,\n",
178-
" 'latency_s': 1.0239500999450684,\n",
177+
" 'inter_token_latency_s': 0.017167633230035954,\n",
178+
" 'latency_s': 1.0735399723052979,\n",
179179
" 'output_tokens': 10,\n",
180-
" 'time_to_first_token_s': 0.7725250720977783,\n",
181-
" 'tokens_per_second': 11.719321088638754,\n",
180+
" 'time_to_first_token_s': 0.8838629722595215,\n",
181+
" 'tokens_per_second': 11.177972231654723,\n",
182182
" 'total_tokens': 13}\n"
183183
]
184-
},
185-
{
186-
"ename": "",
187-
"evalue": "",
188-
"output_type": "error",
189-
"traceback": [
190-
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
191-
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
192-
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
193-
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
194-
]
195184
}
196185
],
197186
"source": [
@@ -206,6 +195,13 @@
206195
" pprint(chunk.metrics)\n",
207196
" i+=1"
208197
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"metadata": {},
203+
"outputs": [],
204+
"source": []
209205
}
210206
],
211207
"metadata": {

0 commit comments

Comments
 (0)