28}, 'model_name': 'text-davinci-003'} run=[RunInfo(run_id=UUID('b8f84619-ea5f-4c18-b411-b62194f36fe0'))]Create Metric Charts‚ÄãWe now use matplotlib to create graphs of latency, errors and tokens consumed.# Helper function to create a graph using matplotlib.def plot(data, title):    data = json.loads(data)    # Extract x and y values from the data    timestamps = [item["time"] for item in data]    dates = [dt.datetime.fromtimestamp(ts) for ts in timestamps]    y = [item["value"] for item in data]    plt.rcParams["figure.figsize"] = [6, 4]    plt.subplots_adjust(bottom=0.2)    plt.xticks(rotation=25)    ax = plt.gca()    xfmt = md.DateFormatter("%Y-%m-%d %H:%M:%S")    ax.xaxis.set_major_formatter(xfmt)    # Create the plot    plt.plot(dates, y)    # Set labels and title    plt.xlabel("Time")    plt.ylabel("Value")    plt.title(title)    plt.show()response = client.search_ts("__name__", "latency", 0, int(time.time()))plot(response.text, "Latency")response = client.search_ts("__name__", "error", 0, int(time.time()))plot(response.text, "Errors")response = client.search_ts("__name__", "prompt_tokens", 0, int(time.time()))plot(response.text, "Prompt Tokens")response = client.search_ts("__name__", "completion_tokens", 0, int(time.time()))plot(response.text, "Completion Tokens")response = client.search_ts("__name__", "total_tokens", 0, int(time.time()))plot(response.text, "Total Tokens")    ![png](_infino_files/output_12_0.png)        ![png](_infino_files/output_12_1.png)        ![png](_infino_files/output_12_2.png)        ![png](_infino_files/output_12_3.png)        ![png](_infino_files/output_12_4.png)    Full text query on prompt or prompt outputs.‚Äã# Search for a particular prompt text.query = "normandy"response = client.search_log(query, 0, int(time.time()))print("Results for", query, ":", response.text)print("===")query = "king charles III"response = client.search_log("king charles III", 0, int(time.time()))print("Results for", query, ":", response.text)    Results
This example shows how one can track the following while calling OpenAI and ChatOpenAI models via LangChain and Infino:
This example shows how one can track the following while calling OpenAI and ChatOpenAI models via LangChain and Infino: ->: 28}, 'model_name': 'text-davinci-003'} run=[RunInfo(run_id=UUID('b8f84619-ea5f-4c18-b411-b62194f36fe0'))]Create Metric Charts‚ÄãWe now use matplotlib to create graphs of latency, errors and tokens consumed.# Helper function to create a graph using matplotlib.def plot(data, title):    data = json.loads(data)    # Extract x and y values from the data    timestamps = [item["time"] for item in data]    dates = [dt.datetime.fromtimestamp(ts) for ts in timestamps]    y = [item["value"] for item in data]    plt.rcParams["figure.figsize"] = [6, 4]    plt.subplots_adjust(bottom=0.2)    plt.xticks(rotation=25)    ax = plt.gca()    xfmt = md.DateFormatter("%Y-%m-%d %H:%M:%S")    ax.xaxis.set_major_formatter(xfmt)    # Create the plot    plt.plot(dates, y)    # Set labels and title    plt.xlabel("Time")    plt.ylabel("Value")    plt.title(title)    plt.show()response = client.search_ts("__name__", "latency", 0, int(time.time()))plot(response.text, "Latency")response = client.search_ts("__name__", "error", 0, int(time.time()))plot(response.text, "Errors")response = client.search_ts("__name__", "prompt_tokens", 0, int(time.time()))plot(response.text, "Prompt Tokens")response = client.search_ts("__name__", "completion_tokens", 0, int(time.time()))plot(response.text, "Completion Tokens")response = client.search_ts("__name__", "total_tokens", 0, int(time.time()))plot(response.text, "Total Tokens")    ![png](_infino_files/output_12_0.png)        ![png](_infino_files/output_12_1.png)        ![png](_infino_files/output_12_2.png)        ![png](_infino_files/output_12_3.png)        ![png](_infino_files/output_12_4.png)    Full text query on prompt or prompt outputs.‚Äã# Search for a particular prompt text.query = "normandy"response = client.search_log(query, 0, int(time.time()))print("Results for", query, ":", response.text)print("===")query = "king charles III"response = client.search_log("king charles III", 0, int(time.time()))print("Results for", query, ":", response.text)    Results