File size: 2,827 Bytes
8d8cebe 056bbbf 8d8cebe |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# pip freeze > requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading settings from ../../env/ai.json\n"
]
}
],
"source": [
"import os\n",
"import json\n",
"\n",
"# If the file does not exist it'll default to the manual setting see below\n",
"filePathToSettingsFile = '../../env/ai.json'\n",
"\n",
"# Is there a settings file? \n",
"if os.path.exists(filePathToSettingsFile):\n",
" # Yes there is so load settings from there\n",
" \n",
" print(f'Loading settings from {filePathToSettingsFile}')\n",
" f = open(filePathToSettingsFile)\n",
" settingsJson = json.load(f)\n",
" del f\n",
"\n",
" for key in settingsJson:\n",
" os.environ[key] = settingsJson[key]\n",
" \n",
" del settingsJson\n",
"else: \n",
" # Set variables manually\n",
" \n",
" print('Setting variables manually as there is not ai.json settings file')\n",
"\n",
" # Update the variables below with your own settings\n",
" os.environ['REQUESTS_CA_BUNDLE'] = '../../env/ZCert.pem' \n",
" os.environ['HUGGING_FACE_API_KEY'] = 'Get here: https://huggingface.co/settings/tokens'\n",
" os.environ['OPENAI_API_KEY'] = 'Get here: https://platform.openai.com/account/api-keys'\n",
" os.environ[\"SERPAPI_API_KEY\"] = 'serpapi KEY, Get here: https://serpapi.com/manage-api-key'\n",
" os.environ[\"PINECONE_API_KEY\"] = 'serpapi KEY, Get here: https://app.pinecone.io/'\n",
" os.environ[\"PINECONE_API_ENV\"] = 'serpapi KEY, Get here: https://app.pinecone.io/'"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from huggingface_hub import HfFileSystem\n",
"fs = HfFileSystem()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n"
]
}
],
"source": [
"list = fs.glob(\"thrag/rag-demo-1/*\")\n",
"print(len(list))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|