mirror of
https://gh-proxy.org/https://github.com/klinsmaya/gateway.git
synced 2026-11-08 00:57:59 +08:00
* agents with telemetry * GPT-4o Cookbooks * provider cookbooks * update * update readme * update readme * artifacts gpt-4o * tool use with portkey Added detailed guide for LLM tool use across providers. --------- Co-authored-by: Rohit Agarwal <[email protected]>
467 KiB
Vendored
467 KiB
Vendored
In [1]:
!pip install -qU portkey-ai openai[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m405.9/405.9 kB[0m [31m5.9 MB/s[0m eta [36m0:00:00[0m [2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m328.5/328.5 kB[0m [31m8.1 MB/s[0m eta [36m0:00:00[0m [2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m75.6/75.6 kB[0m [31m2.8 MB/s[0m eta [36m0:00:00[0m [2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m12.7/12.7 MB[0m [31m28.2 MB/s[0m eta [36m0:00:00[0m [2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m77.9/77.9 kB[0m [31m3.6 MB/s[0m eta [36m0:00:00[0m [2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m58.3/58.3 kB[0m [31m3.1 MB/s[0m eta [36m0:00:00[0m [?25h
In [ ]:
from openai import OpenAI
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
from google.colab import userdata
client = OpenAI(
api_key= userdata.get('NVIDIA_API_KEY'), ## replace it your Mistral API key
base_url=PORTKEY_GATEWAY_URL,
default_headers=createHeaders(
provider = "openai",
custom_host = "https://integrate.api.nvidia.com/v1",
api_key= userdata.get('PORTKEY_API_KEY'), ## replace it your Portkey API key
)
)
completion = client.chat.completions.create(
model="google/gemma-2-27b-it",
messages=[{"role":"user","content":"Write a limerick about the wonders of GPU computing."}],
)
print(completion.choices[0].message.content)In [ ]: