sasan commited on
Commit
b4ec609
1 Parent(s): 962f893

Measurements

Browse files
Files changed (1) hide show
  1. notebooks/measurements.ipynb +383 -0
notebooks/measurements.ipynb ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "## TTS"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 1,
13
+ "metadata": {},
14
+ "outputs": [
15
+ {
16
+ "name": "stderr",
17
+ "output_type": "stream",
18
+ "text": [
19
+ "/home/ubix/miniconda3/envs/llm/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
20
+ " from .autonotebook import tqdm as notebook_tqdm\n"
21
+ ]
22
+ }
23
+ ],
24
+ "source": [
25
+ "import os\n",
26
+ "\n",
27
+ "import torch\n",
28
+ "import gradio as gr\n",
29
+ "from TTS.api import TTS\n",
30
+ "os.environ[\"COQUI_TOS_AGREED\"] = \"1\"\n",
31
+ "os.environ[\"PYTHONPATH\"] = \"/usr/lib/python3.10/dist-packages/\"\n",
32
+ "\n",
33
+ "from kitt.core import voices, tts_gradio"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "code",
38
+ "execution_count": 2,
39
+ "metadata": {},
40
+ "outputs": [],
41
+ "source": [
42
+ "speaker_embedding_cache = {}"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": 3,
48
+ "metadata": {},
49
+ "outputs": [
50
+ {
51
+ "name": "stderr",
52
+ "output_type": "stream",
53
+ "text": [
54
+ "\u001b[32m2024-05-21 14:20:22.300\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mkitt.core\u001b[0m:\u001b[36mload_tts_pipeline\u001b[0m:\u001b[36m58\u001b[0m - \u001b[1mLoading model tts_models/multilingual/multi-dataset/xtts_v2 into device: cuda\u001b[0m\n",
55
+ "/home/ubix/TTS/TTS/api.py:70: UserWarning: `gpu` will be deprecated. Please use `tts.to(device)` instead.\n",
56
+ " warnings.warn(\"`gpu` will be deprecated. Please use `tts.to(device)` instead.\")\n"
57
+ ]
58
+ },
59
+ {
60
+ "name": "stdout",
61
+ "output_type": "stream",
62
+ "text": [
63
+ " > tts_models/multilingual/multi-dataset/xtts_v2 is already downloaded.\n"
64
+ ]
65
+ },
66
+ {
67
+ "ename": "ModuleNotFoundError",
68
+ "evalue": "No module named 'tensorrt'",
69
+ "output_type": "error",
70
+ "traceback": [
71
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
72
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
73
+ "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[43mtts_gradio\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mThe path to glory isn\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mt paved. Be very careful what you say\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mFreeman - Neutral\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mspeaker_embedding_cache\u001b[49m\u001b[43m)\u001b[49m\n",
74
+ "File \u001b[0;32m~/kitt/kitt/core/__init__.py:191\u001b[0m, in \u001b[0;36mtts_gradio\u001b[0;34m(text, voice, cache)\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[38;5;28;01mglobal\u001b[39;00m tts_pipeline\n\u001b[1;32m 190\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m tts_pipeline:\n\u001b[0;32m--> 191\u001b[0m tts_pipeline \u001b[38;5;241m=\u001b[39m \u001b[43mload_tts_pipeline\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 193\u001b[0m voice_path \u001b[38;5;241m=\u001b[39m voice_from_text(voice)\n\u001b[1;32m 194\u001b[0m speed \u001b[38;5;241m=\u001b[39m speed_from_text(voice)\n",
75
+ "File \u001b[0;32m~/kitt/kitt/core/__init__.py:60\u001b[0m, in \u001b[0;36mload_tts_pipeline\u001b[0;34m()\u001b[0m\n\u001b[1;32m 58\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mLoading model \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodel\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m into device: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdevice\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 59\u001b[0m \u001b[38;5;66;03m# device = \"mps\"\u001b[39;00m\n\u001b[0;32m---> 60\u001b[0m tts_pipeline \u001b[38;5;241m=\u001b[39m \u001b[43mTTS\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgpu\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdevice\u001b[49m\u001b[38;5;241;43m==\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcuda\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mto(device)\n\u001b[1;32m 61\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m tts_pipeline\n",
76
+ "File \u001b[0;32m~/TTS/TTS/api.py:74\u001b[0m, in \u001b[0;36mTTS.__init__\u001b[0;34m(self, model_name, model_path, config_path, vocoder_path, vocoder_config_path, progress_bar, gpu)\u001b[0m\n\u001b[1;32m 72\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m model_name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(model_name) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 73\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtts_models\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m model_name:\n\u001b[0;32m---> 74\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_tts_model_by_name\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgpu\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 75\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvoice_conversion_models\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m model_name:\n\u001b[1;32m 76\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mload_vc_model_by_name(model_name, gpu)\n",
77
+ "File \u001b[0;32m~/TTS/TTS/api.py:177\u001b[0m, in \u001b[0;36mTTS.load_tts_model_by_name\u001b[0;34m(self, model_name, gpu)\u001b[0m\n\u001b[1;32m 171\u001b[0m model_path, config_path, vocoder_path, vocoder_config_path, model_dir \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdownload_model_by_name(\n\u001b[1;32m 172\u001b[0m model_name\n\u001b[1;32m 173\u001b[0m )\n\u001b[1;32m 175\u001b[0m \u001b[38;5;66;03m# init synthesizer\u001b[39;00m\n\u001b[1;32m 176\u001b[0m \u001b[38;5;66;03m# None values are fetch from the model\u001b[39;00m\n\u001b[0;32m--> 177\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msynthesizer \u001b[38;5;241m=\u001b[39m \u001b[43mSynthesizer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 178\u001b[0m \u001b[43m \u001b[49m\u001b[43mtts_checkpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmodel_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 179\u001b[0m \u001b[43m \u001b[49m\u001b[43mtts_config_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 180\u001b[0m \u001b[43m \u001b[49m\u001b[43mtts_speakers_file\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 181\u001b[0m \u001b[43m \u001b[49m\u001b[43mtts_languages_file\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 182\u001b[0m \u001b[43m \u001b[49m\u001b[43mvocoder_checkpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvocoder_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 183\u001b[0m \u001b[43m \u001b[49m\u001b[43mvocoder_config\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvocoder_config_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 184\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_checkpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 185\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoder_config\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 186\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmodel_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 187\u001b[0m \u001b[43m \u001b[49m\u001b[43muse_cuda\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mgpu\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 188\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
78
+ "File \u001b[0;32m~/TTS/TTS/utils/synthesizer.py:109\u001b[0m, in \u001b[0;36mSynthesizer.__init__\u001b[0;34m(self, tts_checkpoint, tts_config_path, tts_speakers_file, tts_languages_file, vocoder_checkpoint, vocoder_config, encoder_checkpoint, encoder_config, vc_checkpoint, vc_config, model_dir, voice_dir, use_cuda)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_sample_rate \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtts_config\u001b[38;5;241m.\u001b[39maudio[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msample_rate\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m 108\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 109\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_load_tts_from_dir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_dir\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_cuda\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 110\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_sample_rate \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtts_config\u001b[38;5;241m.\u001b[39maudio[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moutput_sample_rate\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n",
79
+ "File \u001b[0;32m~/TTS/TTS/utils/synthesizer.py:161\u001b[0m, in \u001b[0;36mSynthesizer._load_tts_from_dir\u001b[0;34m(self, model_dir, use_cuda)\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_load_tts_from_dir\u001b[39m(\u001b[38;5;28mself\u001b[39m, model_dir: \u001b[38;5;28mstr\u001b[39m, use_cuda: \u001b[38;5;28mbool\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 157\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Load the TTS model from a directory.\u001b[39;00m\n\u001b[1;32m 158\u001b[0m \n\u001b[1;32m 159\u001b[0m \u001b[38;5;124;03m We assume the model knows how to load itself from the directory and there is a config.json file in the directory.\u001b[39;00m\n\u001b[1;32m 160\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 161\u001b[0m config \u001b[38;5;241m=\u001b[39m \u001b[43mload_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpath\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_dir\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mconfig.json\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtts_config \u001b[38;5;241m=\u001b[39m config\n\u001b[1;32m 163\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtts_model \u001b[38;5;241m=\u001b[39m setup_tts_model(config)\n",
80
+ "File \u001b[0;32m~/TTS/TTS/config/__init__.py:97\u001b[0m, in \u001b[0;36mload_config\u001b[0;34m(config_path)\u001b[0m\n\u001b[1;32m 95\u001b[0m config_dict\u001b[38;5;241m.\u001b[39mupdate(data)\n\u001b[1;32m 96\u001b[0m model_name \u001b[38;5;241m=\u001b[39m _process_model_name(config_dict)\n\u001b[0;32m---> 97\u001b[0m config_class \u001b[38;5;241m=\u001b[39m \u001b[43mregister_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel_name\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlower\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 98\u001b[0m config \u001b[38;5;241m=\u001b[39m config_class()\n\u001b[1;32m 99\u001b[0m config\u001b[38;5;241m.\u001b[39mfrom_dict(config_dict)\n",
81
+ "File \u001b[0;32m~/TTS/TTS/config/__init__.py:40\u001b[0m, in \u001b[0;36mregister_config\u001b[0;34m(model_name)\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[38;5;66;03m# TODO: fix this\u001b[39;00m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m model_name \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mxtts\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m---> 40\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mTTS\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtts\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconfigs\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mxtts_config\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m XttsConfig\n\u001b[1;32m 42\u001b[0m config_class \u001b[38;5;241m=\u001b[39m XttsConfig\n\u001b[1;32m 43\u001b[0m paths \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTTS.tts.configs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTTS.vocoder.configs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTTS.encoder.configs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTTS.vc.configs\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n",
82
+ "File \u001b[0;32m~/TTS/TTS/tts/configs/xtts_config.py:5\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtyping\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m List\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mTTS\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtts\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconfigs\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mshared_configs\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BaseTTSConfig\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mTTS\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtts\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmodels\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mxtts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m XttsArgs, XttsAudioConfig\n\u001b[1;32m 8\u001b[0m \u001b[38;5;129m@dataclass\u001b[39m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mclass\u001b[39;00m \u001b[38;5;21;01mXttsConfig\u001b[39;00m(BaseTTSConfig):\n\u001b[1;32m 10\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Defines parameters for XTTS TTS model.\u001b[39;00m\n\u001b[1;32m 11\u001b[0m \n\u001b[1;32m 12\u001b[0m \u001b[38;5;124;03m Args:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[38;5;124;03m >>> config = XttsConfig()\u001b[39;00m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n",
83
+ "File \u001b[0;32m~/TTS/TTS/tts/models/xtts.py:20\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mTTS\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtts\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmodels\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mbase_tts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BaseTTS\n\u001b[1;32m 18\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mTTS\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutils\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mio\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m load_fsspec\n\u001b[0;32m---> 20\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtorch2trt\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m torch2trt, TRTModule\n\u001b[1;32m 21\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtensorrt\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mtrt\u001b[39;00m\n\u001b[1;32m 23\u001b[0m init_stream_support()\n",
84
+ "File \u001b[0;32m~/miniconda3/envs/llm/lib/python3.10/site-packages/torch2trt-0.5.0-py3.10.egg/torch2trt/__init__.py:1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtorch2trt\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconverters\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtensorrt\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mtrt\u001b[39;00m\n",
85
+ "File \u001b[0;32m~/miniconda3/envs/llm/lib/python3.10/site-packages/torch2trt-0.5.0-py3.10.egg/torch2trt/torch2trt.py:2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtorch\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtensorrt\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mtrt\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mcopy\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n",
86
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'tensorrt'"
87
+ ]
88
+ }
89
+ ],
90
+ "source": [
91
+ "out = tts_gradio(\"The path to glory isn't paved. Be very careful what you say\", \"Freeman - Neutral\", speaker_embedding_cache)"
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "markdown",
96
+ "metadata": {},
97
+ "source": [
98
+ "## STT\n"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "code",
103
+ "execution_count": 8,
104
+ "metadata": {},
105
+ "outputs": [],
106
+ "source": [
107
+ "import torch\n",
108
+ "from transformers import pipeline\n"
109
+ ]
110
+ },
111
+ {
112
+ "cell_type": "code",
113
+ "execution_count": 9,
114
+ "metadata": {},
115
+ "outputs": [
116
+ {
117
+ "name": "stderr",
118
+ "output_type": "stream",
119
+ "text": [
120
+ "/home/ubix/miniconda3/envs/llm/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
121
+ " warnings.warn(\n"
122
+ ]
123
+ }
124
+ ],
125
+ "source": [
126
+ "device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
127
+ "transcriber = pipeline(\n",
128
+ " \"automatic-speech-recognition\", model=\"openai/whisper-base.en\", device=device\n",
129
+ ")"
130
+ ]
131
+ },
132
+ {
133
+ "cell_type": "code",
134
+ "execution_count": 14,
135
+ "metadata": {},
136
+ "outputs": [
137
+ {
138
+ "data": {
139
+ "text/plain": [
140
+ "(22050,\n",
141
+ " array([-0.00043467, -0.00379933, -0.00812101, ..., 0. ,\n",
142
+ " 0. , 0. ]))"
143
+ ]
144
+ },
145
+ "execution_count": 14,
146
+ "metadata": {},
147
+ "output_type": "execute_result"
148
+ }
149
+ ],
150
+ "source": [
151
+ "out[0]"
152
+ ]
153
+ },
154
+ {
155
+ "cell_type": "code",
156
+ "execution_count": 15,
157
+ "metadata": {},
158
+ "outputs": [],
159
+ "source": [
160
+ "sr, y = out[0]"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": 18,
166
+ "metadata": {},
167
+ "outputs": [
168
+ {
169
+ "name": "stdout",
170
+ "output_type": "stream",
171
+ "text": [
172
+ "391 ms ± 39 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
173
+ ]
174
+ }
175
+ ],
176
+ "source": [
177
+ "%timeit transcriber({\"sampling_rate\": sr, \"raw\": y})"
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "code",
182
+ "execution_count": 17,
183
+ "metadata": {},
184
+ "outputs": [
185
+ {
186
+ "data": {
187
+ "text/plain": [
188
+ "{'text': ' The path to glory is in paves. Be very careful what you say.'}"
189
+ ]
190
+ },
191
+ "execution_count": 17,
192
+ "metadata": {},
193
+ "output_type": "execute_result"
194
+ }
195
+ ],
196
+ "source": [
197
+ "text"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "markdown",
202
+ "metadata": {},
203
+ "source": [
204
+ "## LLM"
205
+ ]
206
+ },
207
+ {
208
+ "cell_type": "code",
209
+ "execution_count": 1,
210
+ "metadata": {},
211
+ "outputs": [],
212
+ "source": [
213
+ "from langchain.memory import ChatMessageHistory\n",
214
+ "from langchain.tools.base import StructuredTool\n",
215
+ "\n",
216
+ "\n",
217
+ "from kitt.core.model import process_query\n",
218
+ "from kitt.skills import (\n",
219
+ " get_weather,\n",
220
+ " find_route,\n",
221
+ " get_forecast,\n",
222
+ " vehicle_status as vehicle_status_fn,\n",
223
+ " search_points_of_interests,\n",
224
+ " search_along_route_w_coordinates,\n",
225
+ " do_anything_else,\n",
226
+ " date_time_info,\n",
227
+ " get_weather_current_location,\n",
228
+ " code_interpreter,\n",
229
+ ")"
230
+ ]
231
+ },
232
+ {
233
+ "cell_type": "code",
234
+ "execution_count": 2,
235
+ "metadata": {},
236
+ "outputs": [],
237
+ "source": [
238
+ "history = ChatMessageHistory()\n",
239
+ "tools = [\n",
240
+ " StructuredTool.from_function(get_weather),\n",
241
+ " StructuredTool.from_function(find_route),\n",
242
+ " StructuredTool.from_function(vehicle_status_fn),\n",
243
+ " StructuredTool.from_function(search_points_of_interests),\n",
244
+ " # StructuredTool.from_function(search_along_route),\n",
245
+ " StructuredTool.from_function(date_time_info),\n",
246
+ " StructuredTool.from_function(get_weather_current_location),\n",
247
+ " StructuredTool.from_function(code_interpreter),\n",
248
+ " # StructuredTool.from_function(do_anything_else),\n",
249
+ "]"
250
+ ]
251
+ },
252
+ {
253
+ "cell_type": "code",
254
+ "execution_count": 3,
255
+ "metadata": {},
256
+ "outputs": [
257
+ {
258
+ "name": "stdout",
259
+ "output_type": "stream",
260
+ "text": [
261
+ "Prompt is:<|im_start|>system\n",
262
+ "You are a function calling AI agent with self-recursion.\n",
263
+ "You can call only one function at a time and analyse data you get from function response.\n",
264
+ "You are provided with function signatures within <tools></tools> XML tags.\n",
265
+ "\n",
266
+ "You may use agentic frameworks for reasoning and planning to help with user query.\n",
267
+ "Please call a function and wait for function results to be provided to you in the next iteration.\n",
268
+ "Don't make assumptions about what values to plug into function arguments.\n",
269
+ "Once you have called a function, results will be fed back to you within <tool_response></tool_response> XML tags.\n",
270
+ "Don't make assumptions about tool results if <tool_response> XML tags are not present since function hasn't been executed yet.\n",
271
+ "Analyze the data once you get the results and call another function.\n",
272
+ "At each iteration please continue adding the your analysis to previous summary.\n",
273
+ "Your final response should directly answer the user query. Don't tell what you are doing, just do it.\n",
274
+ "\n",
275
+ "\n",
276
+ "Here are the available tools:\n",
277
+ "<tools> [{'name': 'get_weather', 'description': 'Get the current weather in a specified location.\\nWhen responding to user, only mention the weather condition, temperature, and the temperature that it feels like, unless the user asks for more information.\\n\\nArgs:\\n location (string) : Optional. The name of the location, if empty, the vehicle location is used.\\n\\nReturns:\\n dict: The weather data in the specified location.', 'parameters': {'type': 'object', 'properties': {'location': {'default': '', 'type': 'string'}}, {'name': 'find_route', 'description': 'Get a route to a destination from the current location of the vehicle.\\n\\n Args:\\n destination (string): Optional. The destination name.', 'parameters': {'type': 'object', 'properties': {'destination': {}, 'required': ['destination']}, {'name': 'vehicle_status', 'description': 'Get current vehicle status, which includes, location, date, time, destination.\\n Call this to get the current destination or location of the car/vehicle.\\n Returns:\\n dict[str, str]: The vehicle status. For example:\\n {\\n \"location\": \"Luxembourg Gare, Luxembourg\",\\n \"lat\": 49.6000,\\n \"lon\": 6.1333,\\n \"date\": \"2025-03-29\",\\n \"time\": \"08:00:20\",\\n \"destination\": \"Kirchberg Campus, Kirchberg\"\\n }', 'parameters': {'type': 'object', 'properties': {}}, {'name': 'search_points_of_interests', 'description': 'Get some of the closest points of interest matching the query.\\n\\nArgs:\\n search_query (string): Required. Describing the type of point of interest depending on what the user wants to do. Make sure to include the type of POI you are looking for. For example italian restaurant, grocery shop, etc.', 'parameters': {'type': 'object', 'properties': {'search_query': {'default': 'french restaurant'}}, {'name': 'date_time_info', 'description': 'Get the current date and time.', 'parameters': {'type': 'object', 'properties': {}}, {'name': 'get_weather_current_location', 'description': 'Returns the CURRENT weather in current location.\\nWhen responding to user, only mention the weather condition, temperature, and the temperature that it feels like, unless the user asks for more information.\\n\\nReturns:\\n dict: The weather data in the specified location.', 'parameters': {'type': 'object', 'properties': {}}, {'name': 'code_interpreter', 'description': 'Execute the provided Python code string on the terminal using exec.\\n\\n The string should contain valid, executable and pure Python code in markdown syntax.\\n Code should also import any required Python packages.\\n\\n Args:\\n code_markdown (str): The Python code with markdown syntax to be executed.\\n For example: ```python\\n<code-string>\\n```\\n\\n Returns:\\n dict | str: A dictionary containing variables declared and values returned by function calls,\\n or an error message if an exception occurred.\\n\\n Note:\\n Use this function with caution, as executing arbitrary code can pose security risks. Use it only for numerical calculations.', 'parameters': {'type': 'object', 'properties': {'code_markdown': {'type': 'string'}, 'required': ['code_markdown']}] </tools>\n",
278
+ "If the provided function signatures doesn't have the function you must call, you may write executable python code in markdown syntax and call code_interpreter() function as follows:\n",
279
+ "<tool_call>\n",
280
+ "{\"arguments\": {\"code_markdown\": <python-code>, \"name\": \"code_interpreter\"}\n",
281
+ "</tool_call>\n",
282
+ "Make sure that the json object above with code markdown block is parseable with json.loads() and the XML block with XML ElementTree.\n",
283
+ "When using tools, ensure to only use the tools provided and not make up any data and do not provide any explanation as to which tool you are using and why.\n",
284
+ "\n",
285
+ "Example 1:\n",
286
+ "User: How is the weather today?\n",
287
+ "Assistant:\n",
288
+ "<tool_call>\n",
289
+ "{\"arguments\": {\"location\": \"\"}, \"name\": \"get_weather\"}\n",
290
+ "</tool_call>\n",
291
+ "\n",
292
+ "Example 2:\n",
293
+ "User: Is there a Spa nearby?\n",
294
+ "Assistant:\n",
295
+ "<tool_call>\n",
296
+ "{\"arguments\": {\"search_query\": \"Spa\"}, \"name\": \"search_points_of_interests\"}\n",
297
+ "</tool_call>\n",
298
+ "\n",
299
+ "Example 3:\n",
300
+ "User: How long will it take to get to the destination?\n",
301
+ "Assistant:\n",
302
+ "<tool_call>\n",
303
+ "{\"arguments\": {\"destination\": \"\"}, \"name\": \"calculate_route\"}\n",
304
+ "\n",
305
+ "When asked for the weather or points of interest, use the appropriate tool with the current location of the car. Unless the user provides a location, then use that location.\n",
306
+ "Always assume user wants to travel by car.\n",
307
+ "\n",
308
+ "Use the following pydantic model json schema for each tool call you will make:\n",
309
+ "{'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}, 'required': ['arguments', 'name'], 'title': 'FunctionCall', 'type': 'object'}\n",
310
+ "\n",
311
+ "At the very first turn you don't have <tool_results> so you shouldn't not make up the results.\n",
312
+ "Please keep a running summary with analysis of previous function results and summaries from previous iterations.\n",
313
+ "Do not stop calling functions until the task has been accomplished or you've reached max iteration of 10.\n",
314
+ "If you plan to continue with analysis, always call another function.\n",
315
+ "For each function call return a valid json object (using doulbe quotes) with function name and arguments within <tool_call></tool_call> XML tags as follows:\n",
316
+ "<tool_call>\n",
317
+ "{\"arguments\": <args-dict>, \"name\": <function-name>}\n",
318
+ "</tool_call>\n",
319
+ "<|im_end|>\n",
320
+ "<|im_start|>user\n",
321
+ "Given that:\n",
322
+ "The current location is: Rue Alphonse Weicker, Luxembourg (49.505, 6.28111)\n",
323
+ "The current date and time: 2025-05-06 08:00:00\n",
324
+ "The current destination is: Rue Alphonse Weicker, Luxembourg\n",
325
+ "Answer the following:\n",
326
+ "How is the weather?<|im_end|>\n",
327
+ "<|im_start|>assistant\n",
328
+ "\n",
329
+ "------------------\n",
330
+ "\n"
331
+ ]
332
+ },
333
+ {
334
+ "ename": "ResponseError",
335
+ "evalue": "model 'dolphin-llama3:8b' not found, try pulling it first",
336
+ "output_type": "error",
337
+ "traceback": [
338
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
339
+ "\u001b[0;31mResponseError\u001b[0m Traceback (most recent call last)",
340
+ "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mprocess_query\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mHow is the weather?\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m)\u001b[49m\n",
341
+ "File \u001b[0;32m~/kitt/kitt/core/model.py:263\u001b[0m, in \u001b[0;36mprocess_query\u001b[0;34m(user_query, history, tools)\u001b[0m\n\u001b[1;32m 261\u001b[0m history\u001b[38;5;241m.\u001b[39madd_message(HumanMessage(content\u001b[38;5;241m=\u001b[39muser_query_status))\n\u001b[1;32m 262\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m depth \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m10\u001b[39m):\n\u001b[0;32m--> 263\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[43mrun_inference_step\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdepth\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mschema_json\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 264\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInference step result:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mout\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m------------------\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 265\u001b[0m history\u001b[38;5;241m.\u001b[39madd_message(AIMessage(content\u001b[38;5;241m=\u001b[39mout))\n",
342
+ "File \u001b[0;32m~/kitt/kitt/core/model.py:249\u001b[0m, in \u001b[0;36mrun_inference_step\u001b[0;34m(depth, history, tools, schema_json, dry_run)\u001b[0m\n\u001b[1;32m 247\u001b[0m client \u001b[38;5;241m=\u001b[39m Client(host\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mhttp://localhost:11434\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 248\u001b[0m \u001b[38;5;66;03m# out = ollama.generate(**data)\u001b[39;00m\n\u001b[0;32m--> 249\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 250\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mResponse from model: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mout\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 251\u001b[0m res \u001b[38;5;241m=\u001b[39m out[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mresponse\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n",
343
+ "File \u001b[0;32m~/miniconda3/envs/llm/lib/python3.10/site-packages/ollama/_client.py:126\u001b[0m, in \u001b[0;36mClient.generate\u001b[0;34m(self, model, prompt, system, template, context, stream, raw, format, images, options, keep_alive)\u001b[0m\n\u001b[1;32m 123\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m model:\n\u001b[1;32m 124\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m RequestError(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmust provide a model\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m--> 126\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_request_stream\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 127\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mPOST\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 128\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m/api/generate\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 129\u001b[0m \u001b[43m \u001b[49m\u001b[43mjson\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\n\u001b[1;32m 130\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mmodel\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 131\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mprompt\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprompt\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 132\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msystem\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43msystem\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 133\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtemplate\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtemplate\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 134\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mcontext\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 135\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mstream\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 136\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mraw\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mraw\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 137\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mimages\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m_encode_image\u001b[49m\u001b[43m(\u001b[49m\u001b[43mimage\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mimage\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mimages\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 138\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mformat\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mformat\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 139\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43moptions\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43moptions\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 140\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mkeep_alive\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mkeep_alive\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 141\u001b[0m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 142\u001b[0m \u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 143\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
344
+ "File \u001b[0;32m~/miniconda3/envs/llm/lib/python3.10/site-packages/ollama/_client.py:97\u001b[0m, in \u001b[0;36mClient._request_stream\u001b[0;34m(self, stream, *args, **kwargs)\u001b[0m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_request_stream\u001b[39m(\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 93\u001b[0m \u001b[38;5;241m*\u001b[39margs,\n\u001b[1;32m 94\u001b[0m stream: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 95\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 96\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Union[Mapping[\u001b[38;5;28mstr\u001b[39m, Any], Iterator[Mapping[\u001b[38;5;28mstr\u001b[39m, Any]]]:\n\u001b[0;32m---> 97\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_stream(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;28;01mif\u001b[39;00m stream \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_request\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mjson()\n",
345
+ "File \u001b[0;32m~/miniconda3/envs/llm/lib/python3.10/site-packages/ollama/_client.py:73\u001b[0m, in \u001b[0;36mClient._request\u001b[0;34m(self, method, url, **kwargs)\u001b[0m\n\u001b[1;32m 71\u001b[0m response\u001b[38;5;241m.\u001b[39mraise_for_status()\n\u001b[1;32m 72\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m httpx\u001b[38;5;241m.\u001b[39mHTTPStatusError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m---> 73\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ResponseError(e\u001b[38;5;241m.\u001b[39mresponse\u001b[38;5;241m.\u001b[39mtext, e\u001b[38;5;241m.\u001b[39mresponse\u001b[38;5;241m.\u001b[39mstatus_code) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 75\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n",
346
+ "\u001b[0;31mResponseError\u001b[0m: model 'dolphin-llama3:8b' not found, try pulling it first"
347
+ ]
348
+ }
349
+ ],
350
+ "source": [
351
+ "process_query(\"How is the weather?\", history, tools)"
352
+ ]
353
+ },
354
+ {
355
+ "cell_type": "code",
356
+ "execution_count": null,
357
+ "metadata": {},
358
+ "outputs": [],
359
+ "source": []
360
+ }
361
+ ],
362
+ "metadata": {
363
+ "kernelspec": {
364
+ "display_name": "llm",
365
+ "language": "python",
366
+ "name": "python3"
367
+ },
368
+ "language_info": {
369
+ "codemirror_mode": {
370
+ "name": "ipython",
371
+ "version": 3
372
+ },
373
+ "file_extension": ".py",
374
+ "mimetype": "text/x-python",
375
+ "name": "python",
376
+ "nbconvert_exporter": "python",
377
+ "pygments_lexer": "ipython3",
378
+ "version": "3.10.14"
379
+ }
380
+ },
381
+ "nbformat": 4,
382
+ "nbformat_minor": 2
383
+ }