forked from Data-drone/ANZ_LLM_Bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.3_Testing_Endpoints.py
33 lines (23 loc) · 958 Bytes
/
3.3_Testing_Endpoints.py
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
# Databricks notebook source
# MAGIC %md
# MAGIC # Let us use our endpoings
# COMMAND ----------
%run ./endpoint_utils
# COMMAND ----------
import requests
# COMMAND ----------
# setup config variables
# embedding model
embed_path = 'https://e2-demo-field-eng.cloud.databricks.com/serving-endpoints/brian_embedding_endpoint/invocations'
# COMMAND ----------
serving_client = EndpointApiClient()
# COMMAND ----------
#Let's try to send some inference to our REST endpoint
dataset = {"dataframe_split": {'data': ['test sentence']}}
import timeit
#f"{serving_client.base_url}/realtime-inference/dbdemos_embedding_endpoint/invocations"
endpoint_url = embed_path
print(f"Sending requests to {endpoint_url}")
starting_time = timeit.default_timer()
inferences = requests.post(endpoint_url, json=dataset, headers=serving_client.headers).json()
print(f"Embedding inference, end 2 end :{round((timeit.default_timer() - starting_time)*1000)}ms {inferences}")