{"id":346498,"date":"2023-03-09T09:00:42","date_gmt":"2023-03-09T09:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346498"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346498","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0418\u0418, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f FastAPI, Qdrant \u0438 ChatGPT<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u0437-\u0437\u0430 \u0448\u0443\u043c\u0438\u0445\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 <a href=\"https:\/\/blogs.microsoft.com\/blog\/2023\/02\/07\/reinventing-search-with-a-new-ai-powered-microsoft-bing-and-edge-your-copilot-for-the-web\/?ref=dylan-castillo\"><u>Bing AI<\/u><\/a> \u0438 <a href=\"https:\/\/blog.google\/technology\/ai\/bard-google-ai-search-updates\/?ref=dylan-castillo\"><u>Bard<\/u><\/a> \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c. \u041f\u043e\u0432\u043e\u0437\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439, \u044f \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b <a href=\"https:\/\/seneca.dylancastillo.co\/?ref=dylan-castillo\"><u>Ask Seneca<\/u><\/a>. \u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 GPT, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0431\u043e\u043b\u0442\u0430\u0442\u044c \u0441 \u0421\u0435\u043d\u0435\u043a\u043e\u0439 (\u044d\u0442\u043e \u0434\u0440\u0435\u0432\u043d\u0435\u0440\u0438\u043c\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u043e\u0441\u043e\u0444, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e). \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, Ask Seneca \u0438\u0449\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0432\u044b\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b52\/988\/0a9\/b529880a9b68f48c07a2e684d5c9f267.png\" width=\"1200\" height=\"799\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b52\/988\/0a9\/b529880a9b68f48c07a2e684d5c9f267.png\"\/><\/figure>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 <a href=\"https:\/\/www.reuters.com\/technology\/google-ai-chatbot-bard-offers-inaccurate-information-company-ad-2023-02-08\/?ref=dylan-castillo\"><u>\u043a\u043e\u0441\u044f\u043a\u0438<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0433\u0440\u0435\u0448\u0430\u0442 Bing AI \u0438 Bard, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u044d\u0442\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043e\u0433\u0440\u043e\u043c\u0435\u043d \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0445, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0430\u0437\u0430\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430\u0445 \u043f\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u043c \u0438 \u0442. \u0434.<\/p>\n<p>\u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/dylancastillo.co\/ai-search-engine-fastapi-qdrant-chatgpt\/fastapi.tiangolo.com\/\"><u>FastAPI<\/u><\/a> , <a href=\"https:\/\/qdrant.tech\/?ref=dylan-castillo\"><u>Qdrant<\/u><\/a> , <a href=\"https:\/\/www.sbert.net\/?ref=dylan-castillo\"><u>Sentence Transformers<\/u><\/a> \u0438 <a href=\"https:\/\/openai.com\/product?ref=dylan-castillo\"><u>GPT-3<\/u><\/a>. \u0412\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u041c\u0430\u0440\u043a\u0443 \u0410\u0432\u0440\u0435\u043b\u0438\u044e \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0435\u0433\u043e \u00ab<a href=\"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe?ref=dylan-castillo\"><u>\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u00bb<\/u><\/a> (\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0435\u043b\u0438\u043a\u043e\u0433\u043e \u0440\u0438\u043c\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430).<\/p>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0438\u043d\u0438-\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a,\u00a0 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B5%D0%BC%D0%B0%D0%BD%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9_%D0%BF%D0%BE%D0%B8%D1%81%D0%BA\"><u>\u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0438\u0441\u043a<\/u><\/a><u>.<\/u><\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/www.pinecone.io\/learn\/vector-database\/?ref=dylan-castillo\"><u>\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/u><\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/fastapi.tiangolo.com\/?ref=dylan-castillo\"><u>FastAPI<\/u><\/a> \u0438 \u043a\u0430\u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0430\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043e\u043c \u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u043d\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043e \u0447\u0451\u043c \u044f \u0431\u0443\u0434\u0443 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 (\u043a\u0440\u043e\u0448\u0435\u0447\u043d\u043e\u0439) \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ChatGPT<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u0418\u0418. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ol>\n<li>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0431\u043e\u0440 <a href=\"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe?ref=dylan-castillo\"><u>\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439<\/u><\/a> \u041c\u0430\u0440\u043a\u0430 \u0410\u0432\u0440\u0435\u043b\u0438\u044f. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0437\u043a\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0413\u043e\u0442\u043e\u0432\u044b\u0439 <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-chatgpt\/blob\/main\/data\/processed\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe.json?ref=dylan-castillo\"><u>\u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445<\/u><\/a> \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u0421\u043b\u0435\u0434\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043a \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u0437\u0436\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0438\u0441\u043a\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u0430 \u043d\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u043c. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u00ab\u041a\u0430\u043a \u0441\u0442\u0430\u0442\u044c \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u044b\u043c?\u00bb \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0440\u044b\u0432\u043a\u0438 \u0438\u0437 \u00ab\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439\u00bb, \u0433\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u043e \u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u0438\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u043c \u0441\u0430\u043c\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0438, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0438\u0441\u043a<\/strong>: \u0421\u044e\u0434\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0441\u043b\u0443\u0436\u0431\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u043d\u0435\u0433\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 API OpenAI \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a\u00a0 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ae\/07b\/182\/9ae07b182a58e2856bcd8d953d393e5c.png\" width=\"688\" height=\"331\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ae\/07b\/182\/9ae07b182a58e2856bcd8d953d393e5c.png\"\/><\/figure>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0432\u043e\u044e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443<\/h3>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443:<\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <a href=\"https:\/\/www.python.org\/downloads\/?ref=dylan-castillo\"><u>Python 3.10<\/u><\/a> .<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/python-poetry.org\/docs\/?ref=dylan-castillo#installation\"><u>Poetry<\/u><\/a>. \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<\/li>\n<\/ol>\n<p><code>git clone https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-chatgpt<\/code><\/p>\n<ol start=\"4\">\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p><strong>Poetry<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435, \u0447\u0442\u043e \u0438 \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p><code>poetry config virtualenvs.in-project true<\/code><\/p>\n<p><code>poetry install<\/code><\/p>\n<\/li>\n<li>\n<p><strong>venv \u0438 pip<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435:<\/p>\n<p><code>python3.10 -m venv .venv &amp;&amp; source .venv\/bin\/activate<\/code><\/p>\n<p><code>pip install -r requirements.txt<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043c\u0435\u0439\u0442\u0435 \u0432\u00a0\u0432\u0438\u0434\u0443, \u0447\u0442\u043e\u00a0PyTorch \u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Python 3.11\u00a0\u0432\u00a0MacOS \u0438 Windows.<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>ai-search-fastapi-qdrant-gpt3 \u2502 \u251c\u2500\u2500 README.md \u251c\u2500\u2500 config.py \u251c\u2500\u2500 data \u2502   \u251c\u2500\u2500 processed \u2502   \u2502   \u2514\u2500\u2500 Marcus_Aurelius_Antoninus... \u2502   \u2502       \u2514\u2500\u2500 Marcus_Aurelius_Antoninus...json \u2502   \u2514\u2500\u2500 unzipped \u2502       \u2514\u2500\u2500 Marcus_Aurelius_Antoninus... \u2502           \u251c\u2500\u2500 index.html \u2502           \u251c\u2500\u2500 metadata.opf \u2502           \u2514\u2500\u2500 style.css \u251c\u2500\u2500 main.py \u251c\u2500\u2500 notebooks \u2502   \u251c\u2500\u2500 extract_text.ipynb \u2502   \u2514\u2500\u2500 vectorize_text.ipynb \u251c\u2500\u2500 poetry.lock \u251c\u2500\u2500 pyproject.toml \u251c\u2500\u2500 requirements.txt \u251c\u2500\u2500 .env-example \u2514\u2500\u2500 .venv\/<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><code>config.py<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0445\u043e\u0441\u0442 Qdrant, \u043f\u043e\u0440\u0442 \u0438 \u043a\u043b\u044e\u0447 API (\u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 .env).<\/p>\n<\/li>\n<li>\n<p><code>data\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u00ab\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u00bb, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 <a href=\"https:\/\/en.wikisource.org\/wiki\/Main_Page?ref=dylan-castillo\"><u>\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/u><\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p><code>main.py<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f FastAPI.<\/p>\n<\/li>\n<li>\n<p><code>notebooks\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u043d\u044b\u0435 \u043a\u043d\u0438\u0436\u043a\u0438 Jupyter \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f, \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <code>extract_text.ipynb<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0444\u0430\u0439\u043b\u0430 HTML, \u0430 <code>vectorize_text.ipynb<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>poetry.lock<\/code> \u0438 <code>pyproject.toml<\/code>: \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f Poetry \u0434\u043b\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0440\u0435\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p><code>requirements.txt<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Python, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><code>.env-example<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>.venv\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Qdrant \u0438 OpenAI<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f .env-example \u0432 .env. \u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 .env. \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438 \u043a\u043b\u044e\u0447\u0438 API \u0434\u043b\u044f Qdrant \u0438 OpenAI, \u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u044b.<\/p>\n<h2>Qdrant<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 <a href=\"https:\/\/cloud.qdrant.io\/?ref=dylan-castillo\"><u>Qdrant<\/u><\/a>, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0451 \u0435\u0449\u0451 \u043d\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u0432\u043e\u0435\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 Clusters > Create \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 1 \u0413\u0411 \u041e\u0417\u0423, 0,5 vCPU \u0438 \u0434\u0438\u0441\u043a\u0430 \u043d\u0430 20 \u0413\u0411. Qdrant \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0449\u0435\u0434\u0440\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/818\/33b\/025\/81833b02508fb2b22161626d012d43f9.png\" width=\"1000\" height=\"355\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/818\/33b\/025\/81833b02508fb2b22161626d012d43f9.png\"\/><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0445\u043e\u0441\u0442 \u0438 \u043a\u043b\u044e\u0447 API, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0432 <code>.env<\/code>:<\/p>\n<pre><code>QDRANT_PORT=6333 QDRANT_HOST=&lt;your_qdrant_host> QDRANT_API_KEY=&lt;your_qdrant_api_key><\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u044e\u0447, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0432 <em>Access<\/em>.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u0441\u0451 \u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>vectorize_data.ipynb<\/code>.<\/p>\n<h2>OpenAI<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 OpenAI, <a href=\"https:\/\/platform.openai.com\/login?ref=dylan-castillo\"><u>\u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0435<\/u><\/a> <u>(<\/u><a href=\"https:\/\/habr.com\/ru\/post\/704600\/\">\u0430 \u0432\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u043e\u0441\u0441\u0438\u044f\u043d<\/a><u>)<\/u>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 <em>Manage account > API keys >\u00a0 + Create new secret key.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/300\/f6c\/8c2\/300f6c8c2175ec6465530e7354f259d6.png\" width=\"1000\" height=\"393\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/300\/f6c\/8c2\/300f6c8c2175ec6465530e7354f259d6.png\"\/><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 <code>.env<\/code>:<\/p>\n<pre><code>QDRANT_PORT=6333 QDRANT_HOST=&lt;your_qdrant_host> QDRANT_API_KEY=&lt;your_qdrant_api_key> OPENAI_API_KEY=&lt;your_openai_api_key> # new<\/code><\/pre>\n<h3>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u0425\u0440\u0435\u043d\u044c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u2014 \u0445\u0440\u0435\u043d\u044c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435<\/strong>. \u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0438\u0441\u043a, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e. \u041b\u0438\u0447\u043d\u043e \u044f \u0434\u0435\u043b\u0438\u043b \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0430\u0431\u0437\u0430\u0446\u044b, \u0430 \u0435\u0441\u043b\u0438 \u0430\u0431\u0437\u0430\u0446 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0434\u0435\u043b\u0438\u043b \u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u0441\u0438\u043d\u0433, API) \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0432\u044b\u043c \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0435\u043c, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Jupyter\u00a0Notebook, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-gpt3\/blob\/main\/data\/processed\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe.json?ref=dylan-castillo\"><u>\u0434\u0430\u043d\u043d\u044b\u0445 <\/u><\/a>\u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430:<\/p>\n<pre><code>{     \"book_title\": \"Meditations by Marcus Aurelius\",     \"url\": \"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\",     \"data\": [         {             \"title\": \"THE FIRST BOOK\",             \"url\": \"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe#THE_FIRST_BOOK\",             \"sentences\": [                 \"I. Of my grandfather Verus I have learned to be gentle and meek...\",                 \"II. Of him that brought me up, not to be fondly addicted...\",                 \"III. Of Diognetus, not to busy myself about vain things...\",                 \"IV. To Rusticus I am beholding, that I first entered into the...\",  ...  }  ]  }<\/code><\/pre>\n<p>\u0421\u044e\u0434\u0430 \u0432\u0445\u043e\u0434\u044f\u0442 \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 URL-\u0430\u0434\u0440\u0435\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u043b\u0430\u0432\u044b \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u044f \u0438\u0437\u0432\u043b\u0451\u043a \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u0444\u0430\u0439\u043b\u043e\u043c <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-gpt3\/blob\/main\/notebooks\/extract_text.ipynb?ref=dylan-castillo\"><u>extract_data.ipynb<\/u><\/a>.<\/p>\n<h3>\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 <a href=\"https:\/\/qdrant.tech\/documentation\/collections\/?ref=dylan-castillo\"><u>\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e<\/u><\/a> (\u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432 <code>notebooks\/vectorize_data.ipynb<\/code>.<\/p>\n<p>\u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code>import json  import numpy as np import pandas as pd import torch  from qdrant_client import QdrantClient from qdrant_client.http import models from sentence_transformers import SentenceTransformer  from tqdm.notebook import tqdm  from config import QDRANT_HOST, QDRANT_PORT, QDRANT_API_KEY, DATA, COLLECTION_NAME<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><code>qdrant_client<\/code> \u0438 <code>qdrant_client.http<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c Qdrant, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>sentence_transformers<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>BOOK_FILENAME = \"Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\"  with open(f\"{DATA}\/processed\/{BOOK_FILENAME}\/{BOOK_FILENAME}.json\", \"r\") as file:     meditations_json = json.load(file)  rows = [] for chapter in tqdm(meditations_json[\"data\"]):     for sentence in chapter[\"sentences\"]:         rows.append(             (                 chapter[\"title\"],                 chapter[\"url\"],                 sentence,             )         )  df = pd.DataFrame(     data=rows, columns=[\"title\", \"url\", \"sentence\"] )  df = df[df[\"sentence\"].str.split().str.len() > 15]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u043d\u0435\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 1 \u043f\u043e 4 \u0447\u0438\u0442\u0430\u044e\u0442 \u0444\u0430\u0439\u043b JSON, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u043c\u0438 \u0434\u043b\u044f \u201c\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439\u201d, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0435\u0433\u043e \u043a\u0430\u043a meditations_json.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 6 \u043f\u043e 15 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u0435 \u0433\u043b\u0430\u0432\u044b \u043a\u043d\u0438\u0433\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 <em>data <\/em>\u043e\u0442 <code>meditations_json<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u043b\u0430\u0432\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043b\u0430\u0432\u044b, URL-\u0430\u0434\u0440\u0435\u0441 \u0433\u043b\u0430\u0432\u044b \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435) \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0445 \u0432 rows.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 17 \u043f\u043e 21 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 DataFrame \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 <code>rows<\/code> \u0438 \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043c\u0435\u043d\u0435\u0435 15 \u0441\u043b\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code># Create collection client = QdrantClient( host=QDRANT_HOST, port=QDRANT_PORT, api_key=QDRANT_API_KEY ) client.recreate_collection(     collection_name=COLLECTION_NAME,     vectors_config=models.VectorParams(     size=384,      distance=models.Distance.COSINE     ), )<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443 Qdrant \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>size384<\/strong> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, <a href=\"https:\/\/huggingface.co\/sentence-transformers\/msmarco-MiniLM-L-6-v3?ref=dylan-castillo\"><u>\u043a\u043e\u0442\u043e\u0440\u0443\u044e<\/u><\/a> \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 distance, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cosine_similarity?ref=dylan-castillo\"><u>\u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 (\u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u043e\u0432) \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 OpenAI \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 Sentence Transformers. <a href=\"https:\/\/medium.com\/@nils_reimers\/openai-gpt-3-text-embeddings-really-a-new-state-of-the-art-in-dense-text-embeddings-6571fe3ec9d9?ref=dylan-castillo\"><u>OpenAI \u0434\u043e\u0440\u043e\u0436\u0435, \u043d\u043e \u043d\u0435 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435<\/u><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 DataFrame \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0438\u0445 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0432\u0430\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e:<\/p>\n<pre><code>model = SentenceTransformer(     \"msmarco-MiniLM-L-6-v3\",     device=\"cuda\"     if torch.cuda.is_available()     else \"mps\"     if torch.backends.mps.is_available()     else \"cpu\", )  vectors = [] batch_size = 512 batch = []  for doc in tqdm(df[\"sentence\"].to_list()):     batch.append(doc)          if len(batch) >= batch_size:         vectors.append(model.encode(batch))         batch = []  if len(batch) > 0:     vectors.append(model.encode(batch))     batch = []      vectors = np.concatenate(vectors)  book_name = meditations_json[\"book_title\"]  client.upsert(     collection_name=COLLECTION_NAME,     points=models.Batch(         ids=[i for i in range(df.shape[0])],         payloads=[             {                 \"text\": row[\"sentence\"],                 \"title\": row[\"title\"] + f\", {book_name}\",                 \"url\": row[\"url\"],             }             for _, row in df.iterrows()         ],         vectors=[v.tolist() for v in vectors],     ), )<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 DataFrame \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0432\u0430\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<ol>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 1 \u043f\u043e 8 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 <code>msmarco-MiniLM-L-6-v3<\/code>\u00a0 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 10 \u043f\u043e 23 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0443\u044e \u0432\u0430\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 DataFrame.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 29 \u043f\u043e 43 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438 \u0438 \u0433\u043b\u0430\u0432\u044b \u0438 URL-\u0430\u0434\u0440\u0435\u0441) \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 FastAPI<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 ChatGPT. \u041a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>main.py<\/code>.<\/p>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 Qdrant \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code>import openai from fastapi import FastAPI from qdrant_client import QdrantClient from sentence_transformers import SentenceTransformer  from config import (     COLLECTION_NAME,     OPENAI_API_KEY,     QDRANT_API_KEY,     QDRANT_HOST,     QDRANT_PORT, )  openai.api_key = OPENAI_API_KEY  qdrant_client = QdrantClient(     host=QDRANT_HOST,     port=QDRANT_PORT,     api_key=QDRANT_API_KEY, )  retrieval_model = SentenceTransformer(\"msmarco-MiniLM-L-6-v3\")  app = FastAPI()<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442 Qdrant \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c (\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439). \u0412\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0435 \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e, \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0435\u0451 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0434\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a \u0434\u043b\u044f ChatGPT, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043e\u0442\u0440\u044b\u0432\u043a\u043e\u0432 \u0438\u0437 \u00ab\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439\u00bb:<\/p>\n<pre><code>def build_prompt(question: str, references: list) -> tuple[str, str]:     prompt = f\"\"\"     \u0422\u044b \u041c\u0430\u0440\u043a \u0410\u0432\u0440\u0435\u043b\u0438\u0439, \u0440\u0438\u043c\u0441\u043a\u0438\u0439 \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u0422\u044b \u0434\u0430\u0451\u0448\u044c \u0441\u043e\u0432\u0435\u0442 \u0434\u0440\u0443\u0433\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u043b \u0442\u0435\u0431\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: '{\u0432\u043e\u043f\u0440\u043e\u0441}'  \u00a0\u00a0\u00a0\u00a0\u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0442\u044b \u0432\u044b\u0431\u0440\u0430\u043b \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u044b\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0442\u0432\u043e\u0438\u0445 \u0437\u0430\u043c\u0435\u0442\u043e\u043a. \u0423\u043a\u0430\u0436\u0438 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0451\u043c \u043e\u0442\u0432\u0435\u0442\u0435.\u00a0     References:     \"\"\".strip()      references_text = \"\"      for i, reference in enumerate(references, start=1):         text = reference.payload[\"text\"].strip()         references_text += f\"\\n[{i}]: {text}\"      prompt += (         references_text         + \"\\nHow to cite a reference: This is a citation [1]. This one too [3]. And this is sentence with many citations [2][3].\\nAnswer:\"     )     return prompt, references_text<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 \u0434\u043b\u044f ChatGPT, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e\u00a0 \u00ab\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u041c\u0430\u0440\u043a\u0430 \u0410\u0432\u0440\u0435\u043b\u0438\u044f, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0432\u043e\u043f\u0440\u043e\u0441, \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0441\u044b\u043b\u043e\u043a, \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u00a0 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0434\u0432\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code>@app.get(\"\/\") def read_root():     return {         \"message\": \"Make a post request to \/ask to ask a question about Meditations by Marcus Aurelius\"     }   @app.post(\"\/ask\") def ask(question: str):     similar_docs = qdrant_client.search(         collection_name=COLLECTION_NAME,         query_vector=retrieval_model.encode(question),         limit=3,         append_payload=True,     )      prompt, references = build_prompt(question, similar_docs)      response = openai.ChatCompletion.create(         model=\"gpt-3.5-turbo\",         messages=[             {\"role\": \"user\", \"content\": prompt},         ],         max_tokens=250,         temperature=0.2,     )      return {         \"response\": response[\"choices\"][0][\"text\"],         \"references\": references,     }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0434\u0432\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430:<\/p>\n<ol>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 1 \u043f\u043e 5 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Methods\/GET?ref=dylan-castillo\"><u>GET<\/u><\/a> \u043d\u0430 \u00ab\/\u00bb. \u041e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 &#171;\/ask&#187;.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 8 \u043f\u043e 17 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Methods\/POST?ref=dylan-castillo\"><u>POST<\/u><\/a> \u043d\u0430 \u00ab\/ask\u00bb \u0441 \u043e\u0434\u043d\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c question \u0442\u0438\u043f\u0430 string. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u0442\u0435 \u0432\u043e\u043f\u0440\u043e\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 3 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0432\u0430\u0448\u0435\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0440\u043e\u043a\u0438 \u0441 19 \u043f\u043e 32 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u0432\u0430\u0448\u0435\u0439 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u043e\u0439 \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API ChatGPT. \u0412\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 <code>max_tokens=250<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0432\u0435\u0442\u044b \u0431\u044b\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438, \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0435 <code>temperature=0.2<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u043d\u0435\u0441\u043b\u0430 \u043e\u0442\u0441\u0435\u0431\u044f\u0442\u0438\u043d\u0443. \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0435 \u043e\u0442\u0432\u0435\u0442 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 API ChatGPT \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b (\u0432\u043d\u0443\u0442\u0440\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430):<\/p>\n<pre><code>uvicorn main:app --reload<\/code><\/pre>\n<p>\u0412 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043a localhost:8000\/docs, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \/ask:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf7\/bf2\/7c3\/cf7bf27c3280f52e3327c5051cb786d9.png\" width=\"1000\" height=\"246\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf7\/bf2\/7c3\/cf7bf27c3280f52e3327c5051cb786d9.png\"\/><\/figure>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u043e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7e5\/bfe\/537\/7e5bfe5379f187758292e0ffb9e8615c.png\" width=\"1000\" height=\"357\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e5\/bfe\/537\/7e5bfe5379f187758292e0ffb9e8615c.png\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435! \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c.\u00a0<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f VPS \u0441 NGINX, \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043a\u0441\u0438-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438 Gunicorn \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0441 \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 Uvicorn. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043c\u043e\u0451 <a href=\"https:\/\/dylancastillo.co\/fastapi-nginx-gunicorn\/\"><u>\u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e<\/u><\/a>.<\/p>\n<p>\u0418 \u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/dylancastillo.co\/fastapi-nginx-gunicorn\/\"><u>&#8212;preload<\/u><\/a>, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/tiangolo\/fastapi\/issues\/2425?ref=dylan-castillo\"><u>\u041f\u0440\u0438 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/u><\/a> \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0443\u0442\u0435\u0447\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u043e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u043d\u0438\u0437\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f &#8212;max-requests \u0438 &#8212;max-requests-jitter.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-chatgpt?ref=dylan-castillo\"><u>\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 GitHub<\/u><\/a>. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<hr\/>\n<h4>\u0427\u0442\u043e \u0435\u0449\u0451 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0432 \u0431\u043b\u043e\u0433\u0435\u00a0Cloud4Y<\/h4>\n<p>\u2192\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/696078\/\">\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0433\u043b\u0443\u043f\u043e\u0441\u0442\u044c: \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b<\/a><\/p>\n<p>\u2192\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/703540\/\">NAS \u0437\u0430 \u0448\u0430\u043f\u043a\u0443 \u0441\u0443\u0445\u0430\u0440\u0435\u0439<\/a><\/p>\n<p>\u2192\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/712264\/\">\u0412\u0437\u043b\u043e\u043c Hyundai Tucson, \u0447\u0430\u0441\u0442\u044c 1<\/a>,\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/713312\/\">\u0447\u0430\u0441\u0442\u044c 2<\/a><\/p>\n<p>\u2192\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/715668\/\">\u0421\u0442\u043e\u043b\u0435\u0442\u043d\u0438\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u043a\u0430\u043a\u043e\u0439 \u043e\u043d<\/a><\/p>\n<p>\u2192\u00a0<a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/716934\/\">50 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440 \u0438\u0437 \u0447\u0430\u0441\u0442\u043d\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/721212\/\"> https:\/\/habr.com\/ru\/company\/cloud4y\/blog\/721212\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u0437-\u0437\u0430 \u0448\u0443\u043c\u0438\u0445\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 <a href=\"https:\/\/blogs.microsoft.com\/blog\/2023\/02\/07\/reinventing-search-with-a-new-ai-powered-microsoft-bing-and-edge-your-copilot-for-the-web\/?ref=dylan-castillo\"><u>Bing AI<\/u><\/a> \u0438 <a href=\"https:\/\/blog.google\/technology\/ai\/bard-google-ai-search-updates\/?ref=dylan-castillo\"><u>Bard<\/u><\/a> \u0443 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c. \u041f\u043e\u0432\u043e\u0437\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439, \u044f \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b <a href=\"https:\/\/seneca.dylancastillo.co\/?ref=dylan-castillo\"><u>Ask Seneca<\/u><\/a>. \u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 GPT, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0431\u043e\u043b\u0442\u0430\u0442\u044c \u0441 \u0421\u0435\u043d\u0435\u043a\u043e\u0439 (\u044d\u0442\u043e \u0434\u0440\u0435\u0432\u043d\u0435\u0440\u0438\u043c\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u043e\u0441\u043e\u0444, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e). \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0434\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, Ask Seneca \u0438\u0449\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0432\u044b\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u043e\u0431\u0440\u0430\u0437\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 <a href=\"https:\/\/www.reuters.com\/technology\/google-ai-chatbot-bard-offers-inaccurate-information-company-ad-2023-02-08\/?ref=dylan-castillo\"><u>\u043a\u043e\u0441\u044f\u043a\u0438<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0433\u0440\u0435\u0448\u0430\u0442 Bing AI \u0438 Bard, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u044d\u0442\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043e\u0433\u0440\u043e\u043c\u0435\u043d \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0445, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0431\u0430\u0437\u0430\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430\u0445 \u043f\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u043c \u0438 \u0442. \u0434.<\/p>\n<p>\u042f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"https:\/\/dylancastillo.co\/ai-search-engine-fastapi-qdrant-chatgpt\/fastapi.tiangolo.com\/\"><u>FastAPI<\/u><\/a> , <a href=\"https:\/\/qdrant.tech\/?ref=dylan-castillo\"><u>Qdrant<\/u><\/a> , <a href=\"https:\/\/www.sbert.net\/?ref=dylan-castillo\"><u>Sentence Transformers<\/u><\/a> \u0438 <a href=\"https:\/\/openai.com\/product?ref=dylan-castillo\"><u>GPT-3<\/u><\/a>. \u0412\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u041c\u0430\u0440\u043a\u0443 \u0410\u0432\u0440\u0435\u043b\u0438\u044e \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0435\u0433\u043e \u00ab<a href=\"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe?ref=dylan-castillo\"><u>\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u00bb<\/u><\/a> (\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0435\u043b\u0438\u043a\u043e\u0433\u043e \u0440\u0438\u043c\u0441\u043a\u043e\u0433\u043e \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430).<\/p>\n<h2>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0438\u043d\u0438-\u043f\u043e\u0438\u0441\u043a\u043e\u0432\u0438\u043a,\u00a0 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445:<\/p>\n<ol>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B5%D0%BC%D0%B0%D0%BD%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9_%D0%BF%D0%BE%D0%B8%D1%81%D0%BA\"><u>\u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0438\u0441\u043a<\/u><\/a><u>.<\/u><\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/www.pinecone.io\/learn\/vector-database\/?ref=dylan-castillo\"><u>\u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/u><\/a>.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/fastapi.tiangolo.com\/?ref=dylan-castillo\"><u>FastAPI<\/u><\/a> \u0438 \u043a\u0430\u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0430\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043e\u043c \u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u043d\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043e \u0447\u0451\u043c \u044f \u0431\u0443\u0434\u0443 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 (\u043a\u0440\u043e\u0448\u0435\u0447\u043d\u043e\u0439) \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ChatGPT<\/h3>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u0418\u0418. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ol>\n<li>\n<p><strong>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435<\/strong>: \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0440\u0430\u0437\u0431\u043e\u0440 <a href=\"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe?ref=dylan-castillo\"><u>\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439<\/u><\/a> \u041c\u0430\u0440\u043a\u0430 \u0410\u0432\u0440\u0435\u043b\u0438\u044f. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0437\u043a\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0413\u043e\u0442\u043e\u0432\u044b\u0439 <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-chatgpt\/blob\/main\/data\/processed\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe.json?ref=dylan-castillo\"><u>\u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445<\/u><\/a> \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u0421\u043b\u0435\u0434\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043a \u043d\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u0437\u0436\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u0438\u0441\u043a\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443, \u0430 \u043d\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u0430\u043c. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u00ab\u041a\u0430\u043a \u0441\u0442\u0430\u0442\u044c \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u044b\u043c?\u00bb \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0440\u044b\u0432\u043a\u0438 \u0438\u0437 \u00ab\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439\u00bb, \u0433\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u043e \u0441\u0447\u0430\u0441\u0442\u044c\u0435 \u0438\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u043c \u0441\u0430\u043c\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0438, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0438\u0441\u043a<\/strong>: \u0421\u044e\u0434\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0441\u043b\u0443\u0436\u0431\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u0442 \u0435\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u043d\u0430 \u043d\u0435\u0433\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 API OpenAI \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a\u00a0 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0441\u0432\u043e\u044e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443<\/h3>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443:<\/p>\n<ol>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 <a href=\"https:\/\/www.python.org\/downloads\/?ref=dylan-castillo\"><u>Python 3.10<\/u><\/a> .<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/python-poetry.org\/docs\/?ref=dylan-castillo#installation\"><u>Poetry<\/u><\/a>. \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<\/li>\n<\/ol>\n<p><code>git clone https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-chatgpt<\/code><\/p>\n<ol start=\"4\">\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<p><strong>Poetry<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435, \u0447\u0442\u043e \u0438 \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p><code>poetry config virtualenvs.in-project true<\/code><\/p>\n<p><code>poetry install<\/code><\/p>\n<\/li>\n<li>\n<p><strong>venv \u0438 pip<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435:<\/p>\n<p><code>python3.10 -m venv .venv &amp;&amp; source .venv\/bin\/activate<\/code><\/p>\n<p><code>pip install -r requirements.txt<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u043c\u0435\u0439\u0442\u0435 \u0432\u00a0\u0432\u0438\u0434\u0443, \u0447\u0442\u043e\u00a0PyTorch \u043f\u043e\u043a\u0430 \u043d\u0435\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Python 3.11\u00a0\u0432\u00a0MacOS \u0438 Windows.<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>ai-search-fastapi-qdrant-gpt3 \u2502 \u251c\u2500\u2500 README.md \u251c\u2500\u2500 config.py \u251c\u2500\u2500 data \u2502   \u251c\u2500\u2500 processed \u2502   \u2502   \u2514\u2500\u2500 Marcus_Aurelius_Antoninus... \u2502   \u2502       \u2514\u2500\u2500 Marcus_Aurelius_Antoninus...json \u2502   \u2514\u2500\u2500 unzipped \u2502       \u2514\u2500\u2500 Marcus_Aurelius_Antoninus... \u2502           \u251c\u2500\u2500 index.html \u2502           \u251c\u2500\u2500 metadata.opf \u2502           \u2514\u2500\u2500 style.css \u251c\u2500\u2500 main.py \u251c\u2500\u2500 notebooks \u2502   \u251c\u2500\u2500 extract_text.ipynb \u2502   \u2514\u2500\u2500 vectorize_text.ipynb \u251c\u2500\u2500 poetry.lock \u251c\u2500\u2500 pyproject.toml \u251c\u2500\u2500 requirements.txt \u251c\u2500\u2500 .env-example \u2514\u2500\u2500 .venv\/<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><code>config.py<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0445\u043e\u0441\u0442 Qdrant, \u043f\u043e\u0440\u0442 \u0438 \u043a\u043b\u044e\u0447 API (\u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 .env).<\/p>\n<\/li>\n<li>\n<p><code>data\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u00ab\u0420\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f\u00bb, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 <a href=\"https:\/\/en.wikisource.org\/wiki\/Main_Page?ref=dylan-castillo\"><u>\u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/u><\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p><code>main.py<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f FastAPI.<\/p>\n<\/li>\n<li>\n<p><code>notebooks\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u043d\u044b\u0435 \u043a\u043d\u0438\u0436\u043a\u0438 Jupyter \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f, \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <code>extract_text.ipynb<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0444\u0430\u0439\u043b\u0430 HTML, \u0430 <code>vectorize_text.ipynb<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p><code>poetry.lock<\/code> \u0438 <code>pyproject.toml<\/code>: \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f Poetry \u0434\u043b\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0440\u0435\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p><code>requirements.txt<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Python, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><code>.env-example<\/code>: \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>.venv\/<\/code>: \u044d\u0442\u043e\u0442 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 Qdrant \u0438 OpenAI<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f .env-example \u0432 .env. \u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 .env. \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438 \u043a\u043b\u044e\u0447\u0438 API \u0434\u043b\u044f Qdrant \u0438 OpenAI, \u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u044b.<\/p>\n<h2>Qdrant<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 <a href=\"https:\/\/cloud.qdrant.io\/?ref=dylan-castillo\"><u>Qdrant<\/u><\/a>, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0451 \u0435\u0449\u0451 \u043d\u0435\u0442. \u0417\u0430\u0442\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u0432\u043e\u0435\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 Clusters > Create \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 1 \u0413\u0411 \u041e\u0417\u0423, 0,5 vCPU \u0438 \u0434\u0438\u0441\u043a\u0430 \u043d\u0430 20 \u0413\u0411. Qdrant \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0449\u0435\u0434\u0440\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0445\u043e\u0441\u0442 \u0438 \u043a\u043b\u044e\u0447 API, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0432 <code>.env<\/code>:<\/p>\n<pre><code>QDRANT_PORT=6333 QDRANT_HOST=&lt;your_qdrant_host> QDRANT_API_KEY=&lt;your_qdrant_api_key><\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u044e\u0447, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0432 <em>Access<\/em>.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u0441\u0451 \u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0442\u0440\u0438 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>vectorize_data.ipynb<\/code>.<\/p>\n<h2>OpenAI<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 OpenAI, <a href=\"https:\/\/platform.openai.com\/login?ref=dylan-castillo\"><u>\u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0435\u0435<\/u><\/a> <u>(<\/u><a href=\"https:\/\/habr.com\/ru\/post\/704600\/\">\u0430 \u0432\u043e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u043e\u0441\u0441\u0438\u044f\u043d<\/a><u>)<\/u>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 <em>Manage account > API keys >\u00a0 + Create new secret key.<\/em><\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 <code>.env<\/code>:<\/p>\n<pre><code>QDRANT_PORT=6333 QDRANT_HOST=&lt;your_qdrant_host> QDRANT_API_KEY=&lt;your_qdrant_api_key> OPENAI_API_KEY=&lt;your_openai_api_key> # new<\/code><\/pre>\n<h3>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u0425\u0440\u0435\u043d\u044c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u2014 \u0445\u0440\u0435\u043d\u044c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435<\/strong>. \u041a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0438\u0441\u043a, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041d\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e. \u041b\u0438\u0447\u043d\u043e \u044f \u0434\u0435\u043b\u0438\u043b \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0430\u0431\u0437\u0430\u0446\u044b, \u0430 \u0435\u0441\u043b\u0438 \u0430\u0431\u0437\u0430\u0446 \u0431\u044b\u043b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0434\u0435\u043b\u0438\u043b \u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong>: \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u0441\u0438\u043d\u0433, API) \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0432\u044b\u043c \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0435\u043c, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Jupyter\u00a0Notebook, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0434\u0435\u044f.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-gpt3\/blob\/main\/data\/processed\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe.json?ref=dylan-castillo\"><u>\u0434\u0430\u043d\u043d\u044b\u0445 <\/u><\/a>\u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430:<\/p>\n<pre><code>{     \"book_title\": \"Meditations by Marcus Aurelius\",     \"url\": \"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\",     \"data\": [         {             \"title\": \"THE FIRST BOOK\",             \"url\": \"https:\/\/en.wikisource.org\/wiki\/Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe#THE_FIRST_BOOK\",             \"sentences\": [                 \"I. Of my grandfather Verus I have learned to be gentle and meek...\",                 \"II. Of him that brought me up, not to be fondly addicted...\",                 \"III. Of Diognetus, not to busy myself about vain things...\",                 \"IV. To Rusticus I am beholding, that I first entered into the...\",  ...  }  ]  }<\/code><\/pre>\n<p>\u0421\u044e\u0434\u0430 \u0432\u0445\u043e\u0434\u044f\u0442 \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043d\u0438\u0433\u0438 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 URL-\u0430\u0434\u0440\u0435\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u043b\u0430\u0432\u044b \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u044f \u0438\u0437\u0432\u043b\u0451\u043a \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u0444\u0430\u0439\u043b\u043e\u043c <a href=\"https:\/\/github.com\/dylanjcastillo\/ai-search-fastapi-qdrant-gpt3\/blob\/main\/notebooks\/extract_text.ipynb?ref=dylan-castillo\"><u>extract_data.ipynb<\/u><\/a>.<\/p>\n<h3>\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043e \u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 <a href=\"https:\/\/qdrant.tech\/documentation\/collections\/?ref=dylan-castillo\"><u>\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e<\/u><\/a> (\u043d\u0430\u0431\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0432 <code>notebooks\/vectorize_data.ipynb<\/code>.<\/p>\n<p>\u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code>import json  import numpy as np import pandas as pd import torch  from qdrant_client import QdrantClient from qdrant_client.http import models from sentence_transformers import SentenceTransformer  from tqdm.notebook import tqdm  from config import QDRANT_HOST, QDRANT_PORT, QDRANT_API_KEY, DATA, COLLECTION_NAME<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><code>qdrant_client<\/code> \u0438 <code>qdrant_client.http<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c Qdrant, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>sentence_transformers<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>BOOK_FILENAME = \"Marcus_Aurelius_Antoninus_-_His_Meditations_concerning_himselfe\"  with open(f\"{DATA}\/processed\/{BOOK_FILENAME}\/{BOOK_FILENAME}.json\", \"r\") as file:     meditations_json = json.load(file)  rows = [] for chapter in tqdm(meditations_json[\"data\"]):     for sentence in chapter[\"sentences\"]:         rows.append(             (                 chapter[\"title\"],                 chapter[\"url\"],                 sentence,             )         )  df = pd.DataFrame(     data=rows, columns=[\"title\", \"url\", \"sentence\"] )  df = df[df[\"sentence\"].str.split().str.len() > 15]<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346498","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346498"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346498\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}