diff --git a/tools/gpt-helper/term_helper.ipynb b/tools/gpt-helper/term_helper.ipynb index 3780f65a..e09a0dcd 100644 --- a/tools/gpt-helper/term_helper.ipynb +++ b/tools/gpt-helper/term_helper.ipynb @@ -2,21 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "id": "413b2b8e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Hello! How can I assist you today?'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import openai\n", "import os\n", @@ -31,9 +20,10 @@ "\n", "openai.api_key = os.getenv('OPENAI_API_KEY')\n", "\n", - "# print(openai.Engine.list())\n", + "def print_engine_list():\n", + " print(openai.Engine.list())\n", "\n", - "global_path: Path = Path(\"../../lib/StaticDataStorage/data/Global.json\").resolve()\n", + "global_path: Path = Path(\"../../source/staticDataStorage/data/Global.json\").resolve()\n", "\n", "def load_global_static_data() -> Dict[str, Any]:\n", " return json.loads(global_path.read_text())\n", @@ -66,11 +56,45 @@ " for line in lines:\n", " print(line)\n", "\n", + "\n", + "@dataclass\n", + "class TermData:\n", + " area: str | None\n", + " termDef: str\n", + "\n", + "\n", + "class StaticStorage:\n", + " def __init__(self, path: Path):\n", + " self.path = path\n", + " json_data = json.loads(self.path.read_text())\n", + " self.name = json_data['name']\n", + " self.terms: List[TermData] = []\n", + " for term in json_data['terms']:\n", + " area = term['area'] if 'area' in term else None\n", + " term_data = TermData(area, term['termDef'])\n", + " self.terms.append(term_data)\n", + "\n", + " def save(self):\n", + " dict_data = {\n", + " \"name\": self.name,\n", + " \"terms\": []\n", + " }\n", + "\n", + " for term in self.terms:\n", + " term_dict = {}\n", + " if term.area:\n", + " term_dict[\"area\"] = term.area\n", + " term_dict[\"termDef\"] = term.termDef\n", + " dict_data[\"terms\"].append(term_dict)\n", + "\n", + " self.path.write_text(json.dumps(dict_data, indent=4, ensure_ascii=False) + \"\\n\")\n", + "\n", + "\n", "class ChatEngine:\n", " model = \"\"\n", " temp = 0\n", "\n", - " def __init__(self, model: str = \"gpt-4o\", temp: float = 0):\n", + " def __init__(self, model: str = \"gpt-3.5-turbo\", temp: float = 0):\n", " self.model = model\n", " self.temp = temp\n", "\n", @@ -83,35 +107,97 @@ " return {\"role\": self.role, \"content\": self.content}\n", "\n", "class TermChat:\n", + " system_message: Message\n", " messages: List[Message] = []\n", " engine: ChatEngine\n", "\n", - " def __init__(self, engine: ChatEngine, system_message: str, user_messages: List[str] = []):\n", + " def __init__(self, engine: ChatEngine, system_message: str):\n", " self.engine = engine\n", - " self.messages.append(Message(\"system\", system_message))\n", - " self.messages.extend([Message(\"user\", message) for message in user_messages])\n", + " self.system_message = Message(\"system\", system_message)\n", + "\n", + " def _get_messages(self) -> List[Dict[str, str]]:\n", + " ret: List[Dict[str, str]] = []\n", + " ret.append(self.system_message.to_dict())\n", + "\n", + " for message in self.messages:\n", + " ret.append(message.to_dict())\n", + "\n", + " return ret\n", "\n", " def get_answer(self, user_message: str = \"\") -> str | None:\n", " if user_message != \"\":\n", " self.messages.append(Message(\"user\", user_message))\n", "\n", - " chat_messages = [message.to_dict() for message in self.messages]\n", " response = openai.chat.completions.create(\n", " model=self.engine.model,\n", - " messages=chat_messages,\n", + " messages=self._get_messages(),\n", " temperature=self.engine.temp,\n", " )\n", " answer = response.choices[0].message.content\n", - " self.messages.append({\"role\": \"assistant\", \"content\": answer})\n", + " answer = answer if answer else \"\"\n", + " # self.messages.append({\"role\": \"assistant\", \"content\": answer})\n", + " self.messages.append(Message(\"assistant\", answer))\n", " return answer\n", "\n", " def clear_messages(self):\n", - " first_message = self.messages[0]\n", - " self.messages = []\n", - " self.messages.append(first_message)\n", + " self.messages = []\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "446ba34c", + "metadata": {}, + "outputs": [], + "source": [ + "# Prompts\n", "\n", + "continue_term_prompt = \"\"\"\n", + "You are a terms helper robot\n", + "your task is to guess, based on the list of terms,\n", + "which one term, not in the list,\n", + "is the most relevant to already given terms. Answer with one term please.\n", + "\"\"\"\n", + "\n", + "give_definition_prompt = \"\"\"\n", + "You are a terms definition robot\n", + "your task is to give a best possible definition to the user requested term.\n", + "\n", + "You should give a definition step by step, according to the this rules:\n", + "\n", + "1. Definition should contain only information about what the term intrinsically is,\n", + "without any information about what the term is not, and what the term is related to.\n", + "Every entity that can be removed from definition without changing the meaning, should be removed.\n", + "2. Definition should based on the existing list of terms (list would be provided to you).\n", + "3. Check if there exist terms that also fit this definition and are not synonymous to the term.\n", + "4. Definition should be as short as possible.\n", + "\n", + "List of existing terms: '''{0}'''\n", + "\n", + "User requested definition for term: '''{1}'''\n", + "\n", + "Format of answer should be step by step thoughts:\n", + "Raw term definition: \n", + "Thoughts about definition: \n", + "\n", + "First retry: \n", + "Thoughts about definition: \n", + "\n", + "Final try: \n", + "\"\"\"\n", "\n", - "TermChat(ChatEngine(), \"\").get_answer()" + "translate_term_prompt = \"\"\"\n", + "You are a GPT that is specified in term translation.\n", + "Your task is to translate terms from russian to english, saving their format.\n", + "\n", + "Format description:\n", + "- TermDef format: each term should start with a capital letter, and the definition should start with a lowercase letter.\n", + "- Preserve brackets: If in definition some terms are in brackets, you should save them in brackets in the translation.\n", + "- Keyword Usage: Each definition is carefully crafted with specific details\n", + "- Scientific answers: each definition should be as precise, scientific and dry as possible. Expect that your user knows difficult conceptions and you should use them. your task is just with definition show how this conceptions are related.\n", + "- If there is no provided definition on russian, you should provide a definition in english based on the term itself\n", + "Answer with one term please.\n", + "\"\"\"" ] }, { @@ -121,11 +207,6 @@ "metadata": {}, "outputs": [], "source": [ - "continue_term_prompt = \"\"\"You are a terms helper robot \\\n", - "your task is to guess, based on the list of terms, \\\n", - "which one term, not in the list, \\\n", - "is the most relevant to already given terms. Answer with one term please.\"\"\"\n", - "\n", "def predict_next_term():\n", " engine = ChatEngine(temp=0.5)\n", " chat = TermChat(engine, continue_term_prompt)\n", @@ -145,33 +226,6 @@ "metadata": {}, "outputs": [], "source": [ - "give_definition_prompt = \"\"\"\n", - "You are a terms definition robot \\\n", - "your task is to give a best possible definition to the user requested term. \\\n", - "\n", - "You should give a definition step by step, according to the this rules: \\\n", - "\n", - "1. Definition should contain only information about what the term intrinsically is, \\\n", - "without any information about what the term is not, and what the term is related to.\n", - "Every entity that can be removed from definition without changing the meaning, should be removed.\n", - "2. Definition should based on the existing list of terms (list would be provided to you).\n", - "3. Check if there exist terms that also fit this definition and are not synonymous to the term.\n", - "4. Definition should be as short as possible. \\\n", - "\n", - "List of existing terms: '''{0}''' \\\n", - "\n", - "User requested definition for term: '''{1}''' \\\n", - "\n", - "Format of answer should be step by step thoughts: \\\n", - "Raw term definition: \\\n", - "Thoughts about definition: \\\n", - "\n", - "First retry: \\\n", - "Thoughts about definition: \\\n", - "\n", - "Final try: \\\n", - "\"\"\"\n", - "\n", "def give_definition(new_term):\n", " terms_str = get_terms_string()\n", "\n", @@ -187,7 +241,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "939a297f", "metadata": {}, "outputs": [], @@ -206,6 +260,214 @@ "\n", "add_term(\"Symmetry\", f\"{{system}} {{property}} that remains unchanged after a certain {{transformation}}\", \"phys\")" ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "8e07cf2c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Translating term 0: Макроспорогенез - \n", + "Translated term 0: Macrosporogenesis - \n", + "The process of formation and development of the female gametophyte in plants, leading to the production of megaspores through meiosis.\n", + "Transferred 0 terms\n", + "Translating term 1: Макрогематогенез - \n", + "Translated term 1: Macrohematogenesis - \n", + "The process of blood cell formation, specifically referring to the production of red blood cells, white blood cells, and platelets in the bone marrow.\n", + "Translating term 2: Односпорический зародышевый мешок - \n", + "Translated term 2: Monosporic embryo sac - \n", + "A structure in plants that contains the female gametophyte and develops into the embryo after fertilization. It is formed from a single spore and plays a crucial role in sexual reproduction in angiosperms.\n", + "Translating term 3: Биспорический зародышевый мешок - \n", + "Translated term 3: Bisporic embryo sac - \n", + "A structure in plants that contains the female gametophyte and develops into the embryo after fertilization. It is formed from two spores and plays a crucial role in sexual reproduction in angiosperms.\n", + "Translating term 4: Тетраспорический зародышевый мешок - \n", + "Translated term 4: Tetrasporic embryo sac - \n", + "A structure in plants that contains the female gametophyte and develops into the embryo after fertilization. It is formed from four spores and plays a crucial role in sexual reproduction in angiosperms.\n", + "Translating term 5: Сперматогенез - \n", + "Translated term 5: Spermatogenesis - \n", + "The process of sperm cell formation in the testes of male organisms, involving mitosis and meiosis to produce mature sperm cells capable of fertilizing an egg cell.\n", + "Translating term 6: Овогенез - {гаметогенез} женской {половой клетки}\n", + "Translated term 6: Oogenesis - \n", + "The process of egg cell formation in the ovaries of female organisms, involving mitosis and meiosis to produce mature egg cells capable of being fertilized by a sperm cell.\n", + "Translating term 7: Сперматоциты - \n", + "Translated term 7: Spermatocytes - \n", + "Immature male germ cells that undergo meiosis to produce haploid sperm cells.\n", + "Translating term 8: Ооцит - женская {гамета}, участвующая в {размножении}\n", + "Translated term 8: Oocyte - \n", + "The female gamete, or egg cell, that participates in reproduction by fusing with a sperm cell during fertilization.\n", + "Translating term 9: Сперматиды - \n", + "Translated term 9: Spermatids - \n", + "Immature male germ cells that undergo a process of maturation called spermiogenesis to develop into mature sperm cells.\n", + "Translating term 10: Полярные тельца - \n", + "Translated term 10: Polar bodies - \n", + "Small cells produced during oogenesis as a byproduct of meiosis, containing a minimal amount of cytoplasm and genetic material. Their main function is to discard excess genetic material and ensure the proper distribution of nutrients to the mature egg cell.\n", + "Transferred 10 terms\n", + "Translating term 11: Редукционные тельца - {Полярные тельца}\n", + "Translated term 11: Reduction bodies - \n", + "(Polar bodies) Small cells produced during meiosis in oogenesis, containing half the number of chromosomes as the parent cell. Their formation is essential for reducing the genetic material to ensure the proper chromosome number in the mature egg cell.\n", + "Translating term 12: Спермиогенез - \n", + "Translated term 12: Spermiogenesis - \n", + "The process of spermatid maturation into sperm cells, involving structural changes such as the formation of a head, midpiece, and tail, as well as the development of motility and the ability to fertilize an egg cell.\n", + "Translating term 13: Аутосомы - {хромосомы|33cebd18-855a-4d26-bfa3-a0bfe74768a1}, которые одинаковы у {самцов|aaf63b50-22ee-49e3-9dd7-29cf1ef5cca5} и {самок|4ae797ba-3acf-443c-b639-78bbbe3fbb72} одного {вида|91984768-ca88-4428-998b-17b7be97abb7}\n", + "Translated term 13: Autosomes - \n", + "Chromosomes that are the same in males and females of the same species, carrying genetic information responsible for various traits and characteristics excluding those related to sex determination.\n", + "Translating term 14: Яйцевая оболочка - \n", + "Translated term 14: Eggshell - \n", + "A protective covering surrounding the egg that provides mechanical support and protection, regulates gas exchange, and prevents dehydration during embryonic development.\n", + "Translating term 15: Кортикальные гранулы - \n", + "Translated term 15: Cortical granules - \n", + "Specialized secretory vesicles found in the cytoplasm of oocytes, containing enzymes and proteins that play a crucial role in preventing polyspermy by modifying the zona pellucida after fertilization.\n", + "Translating term 16: Олигодендроглия - \n", + "Translated term 16: Oligodendroglia - \n", + "A type of glial cell in the central nervous system that provides support and insulation to axons by producing myelin, a fatty substance that wraps around nerve fibers to increase the speed of electrical impulse conduction.\n", + "Translating term 17: Митотоксины - {токсины}, производимые {плесневыми грибами}\n", + "Translated term 17: Mitotoxins - \n", + "Toxins produced by mold fungi that specifically target and disrupt cell division (mitosis) in other organisms, leading to cell death and potential harm to the affected organism.\n", + "Translating term 18: Вода зоны отчуждения - \n", + "Translated term 18: Water of alienation zone - \n", + "Water located in the immediate vicinity of the contaminated area, which may be affected by pollutants and poses a risk to the environment and human health.\n", + "Translating term 19: Цитокины - \n", + "Translated term 19: Cytokines - \n", + "A diverse group of small proteins secreted by immune cells that regulate inflammation, immunity, and hematopoiesis by acting as signaling molecules between cells in the immune system.\n", + "Translating term 20: Биофотоны и митохондрии - \n", + "Translated term 20: Biophotons and Mitochondria - \n", + "Biophotons are weak electromagnetic emissions emitted by biological systems, including mitochondria, which are the powerhouse of the cell responsible for producing energy in the form of ATP through cellular respiration. The interaction between biophotons and mitochondria may play a role in cellular communication and energy metabolism.\n", + "Transferred 20 terms\n", + "Translating term 21: Вазоактивный интестинальный полипептид - \n", + "Translated term 21: Vasoactive intestinal peptide - \n", + "A neuropeptide hormone that plays a key role in regulating various physiological processes, including smooth muscle relaxation, vasodilation, immune modulation, and neurotransmission in the gastrointestinal tract and nervous system.\n", + "Translating term 22: Эйкозаноиды - \n", + "Translated term 22: Eicosanoids - \n", + "Biologically active lipid compounds derived from arachidonic acid that play crucial roles in inflammation, immune response, blood clotting, and the regulation of various physiological processes in the body.\n", + "Translating term 23: Клетка - структурно-функциональная элементарная единица строения и {жизнедеятельности} всех организмов. Характеризуется собственным {геномом}, {обменом веществ} и {гомеостазом}\n", + "Translated term 23: Cell - \n", + "The structural and functional basic unit of all organisms, characterized by its own genome, metabolism, and homeostasis, playing a fundamental role in the organization and functioning of living systems.\n", + "Translating term 24: Цитоплазма - полужидкое содержимое {клетки}, её внутренняя среда, кроме ядра и вакуоли, ограниченная {плазматической мембраной}\n", + "Translated term 24: Cytoplasm - \n", + "The semi-fluid content of a cell, its internal environment excluding the nucleus and vacuole, enclosed by the plasma membrane, where various cellular organelles are suspended and metabolic processes take place.\n", + "Translating term 25: Мацерация тканей - \n", + "Translated term 25: Tissue maceration - \n", + "A method used in biological research to soften and break down tissues by soaking them in a solution, typically to facilitate the study of cellular structures or extract specific components for analysis.\n", + "Translating term 26: Ткань - совокупность {клеток|feb6e604-3dba-468b-b283-347f1fd2e2b3} и {межклеточного вещества|dab15bb7-ff5e-4556-ae67-ffcfee068c0c}, объединённых общим происхождением, строением и выполняемыми функциями\n", + "Translated term 26: Tissue - \n", + "A collection of cells and extracellular matrix with a common origin, structure, and specialized functions, working together to perform specific tasks in the body.\n", + "Translating term 27: Протоплазма - {Цитоплазма|6ddebaeb-acb5-48c9-a43a-bf0c58ce496a} и {клеточное ядро|56dedbd5-f5b3-40e1-9d01-8c30ca25ab6f}. Термин считается устаревшим\n", + "Translated term 27: Protoplasm - \n", + "The term used in the past to refer to the living contents of a cell, including both the cytoplasm and the cell nucleus. It is considered outdated, with modern biology using more specific terminologies such as cytoplasm and cell nucleus.\n", + "Translating term 28: Апохроматический объектив - вид {объектива}\n", + "Translated term 28: Achromatic objective - \n", + "A type of microscope objective lens designed to correct for chromatic aberration by bringing two wavelengths of light (usually red and blue) into focus at the same point, resulting in a clearer and more accurate image.\n", + "Translating term 29: Иммерсионный объектив - вид {объектива}\n", + "Translated term 29: Immersion objective - \n", + "A type of microscope objective that is designed to be used with a special immersion medium (such as oil or water) between the lens and the specimen, improving the resolution and numerical aperture of the lens by reducing light refraction and increasing the amount of light collected from the specimen.\n", + "Translating term 30: Фазово-контрастный - вид {микроскопии}\n", + "Translated term 30: Phase contrast microscopy - \n", + "A microscopy technique that enhances the contrast of transparent and colorless specimens by exploiting differences in refractive index to produce detailed images without the need for staining or labeling.\n", + "Transferred 30 terms\n", + "Translating term 31: Интерференционный - вид {микроскопии}\n", + "Translated term 31: Interference microscopy - \n", + "A microscopy technique that utilizes interference patterns generated by the interaction of light waves passing through a specimen to produce high-contrast images with detailed surface topography and thickness information.\n", + "Translating term 32: Светового поля - вид {микроскопии}\n", + "Translated term 32: Bright-field microscopy - \n", + "A microscopy technique where light is transmitted through a specimen, and the image is formed by the differences in absorption, reflection, and refraction of light by the specimen, resulting in a bright image on a dark background.\n", + "Translating term 33: Темного поля - вид {микроскопии}\n", + "Translated term 33: Dark-field microscopy - \n", + "A microscopy technique where only light scattered by the specimen is collected by the objective lens, producing a bright image of the specimen on a dark background, enhancing the contrast and visibility of transparent or unstained specimens.\n", + "Translating term 34: Поляризационный - вид {микроскопии}\n", + "Translated term 34: Polarized light microscopy - \n", + "A microscopy technique that uses polarized light to investigate the optical properties of specimens, revealing details about their molecular structure, birefringence, and anisotropy, which are not visible under normal light microscopy.\n", + "Translating term 35: Люминесцентный - вид {микроскопии}\n", + "Translated term 35: Fluorescence microscopy - \n", + "A microscopy technique that uses fluorescence to visualize specific structures or molecules within a specimen by exciting fluorescent dyes or proteins with light of a specific wavelength, producing a highly sensitive and detailed image.\n", + "Translating term 36: Электронная микроскопия - вид {микроскопии}\n", + "Translated term 36: Electron microscopy - \n", + "A microscopy technique that uses a beam of accelerated electrons to illuminate a specimen, providing high-resolution images with magnifications exceeding those of light microscopy, allowing for detailed visualization of cellular structures and organelles.\n", + "Translating term 37: Электронная сканирующая микроскопия - вид {микроскопии}\n", + "Translated term 37: Scanning electron microscopy - \n", + "A microscopy technique that uses a focused beam of electrons to scan the surface of a specimen, producing detailed three-dimensional images with high resolution and depth of field, making it ideal for studying surface structures of biological and inorganic samples.\n", + "Translating term 38: Метод замораживания-скалывания - {метод анализа|1411461f-59f9-4781-bfa5-63202699d4ae}\n", + "Translated term 38: Freeze-fracture method - \n", + "An analytical technique used to study the internal structure of biological samples by freezing them and then fracturing them to reveal the internal surfaces, providing valuable information about membrane structure and organization.\n", + "Translating term 39: Методы анализа - \n", + "Translated term 39: Methods of analysis - \n", + "Procedures and techniques used in scientific research to investigate and study various phenomena, materials, or substances in order to gather data, draw conclusions, and gain insights into the nature of the subject being analyzed.\n", + "Translating term 40: Микроскопия - \n", + "Translated term 40: Microscopy - \n", + "The scientific technique of using microscopes to observe and study objects or specimens that are too small to be seen by the naked eye, enabling the visualization of fine details and structures at the microscopic level.\n", + "Transferred 40 terms\n", + "Translating term 41: Центрифугирование - {Метод анализа|1411461f-59f9-4781-bfa5-63202699d4ae}\n", + "Translated term 41: Centrifugation - \n", + "An analytical method used to separate components of a mixture based on their size, density, and sedimentation rate by spinning the sample at high speeds in a centrifuge, causing particles to separate and form distinct layers according to their properties.\n", + "Translating term 42: Способ разрушения клетки - \n", + "Translated term 42: Cell disruption method - \n", + "A technique used in biological research to break open cells and release their contents for further analysis, often involving physical, chemical, or enzymatic methods to disrupt the cell membrane and access intracellular components.\n", + "Translating term 43: Механически - {Способ разрушения клетки}\n", + "Translated term 43: Mechanical - \n", + "A method of cell disruption that involves physically breaking open cells using mechanical force, such as grinding, shearing, or ultrasonication, to release cellular contents for further analysis or extraction of biomolecules.\n", + "Translating term 44: Химически - {Способ разрушения клетки}\n", + "Translated term 44: Chemical - \n", + "A method of cell disruption that involves using chemical agents, such as detergents, enzymes, or chaotropic agents, to break down the cell membrane and release cellular components for analysis or extraction of biomolecules.\n", + "Translating term 45: Ультразвуком - {Способ разрушения клетки}\n", + "Translated term 45: Ultrasonication - \n", + "A method of cell disruption that utilizes high-frequency sound waves (ultrasound) to disrupt cell membranes and break open cells, releasing cellular contents for analysis or extraction of biomolecules.\n", + "Translating term 46: Микроскоп - прибор для проведения {микроскопии}\n", + "Translated term 46: Microscope - \n", + "An instrument used for conducting microscopy, enabling the observation and magnification of objects or specimens that are too small to be seen by the naked eye, allowing for detailed examination of their structures and features.\n", + "Translating term 47: Оптическая система микроскопа - часть {микроскопа}\n", + "Translated term 47: Microscope optical system - \n", + "The component of a microscope that includes the objective and eyepiece lenses, as well as any additional optical elements, responsible for magnifying and focusing light to produce a clear and enlarged image of the specimen being observed.\n", + "Translating term 48: Объектив - часть {оптической системы микроскопа}. Система линз, направляется на объект исследования\n", + "Translated term 48: Objective lens - \n", + "A component of the microscope optical system consisting of a series of lenses designed to gather light, magnify the specimen, and focus the image for observation, playing a crucial role in determining the resolution and magnification of the microscope.\n", + "Translating term 49: Окуляр - часть {оптической системы микроскопа}. Расположена со стороны наблюдателя\n", + "Translated term 49: Eyepiece - \n", + "A component of the microscope optical system located at the top of the microscope and positioned for observation by the viewer, magnifying the image produced by the objective lens and allowing for further magnification and detailed examination of the specimen.\n", + "Translating term 50: Диафрагма - часть {оптической системы микроскопа}, ограничивающая поток света\n", + "Translated term 50: Diaphragm - \n", + "A component of the microscope optical system located beneath the stage and above the condenser, used to adjust and control the amount of light entering the microscope, thereby regulating the intensity and quality of illumination for optimal specimen visualization.\n", + "Transferred 50 terms\n", + "Translating term 51: Конденсор - часть {оптической системы микроскопа}, которая фокусирует луч света на препарате\n", + "Translated term 51: Condenser - \n", + "A component of the microscope optical system located beneath the stage, responsible for focusing and directing light onto the specimen, ensuring even illumination and maximizing the resolution and contrast of the image observed through the microscope.\n" + ] + } + ], + "source": [ + "# Transfer all terms from Biochemistry to Global with translation\n", + "\n", + "biochemistry_path: Path = Path(\"../../source/staticDataStorage/data/Biochemistry.json\").resolve()\n", + "biochemistry_storage = StaticStorage(biochemistry_path)\n", + "global_storage = StaticStorage(global_path)\n", + "\n", + "bio_term_count = len(biochemistry_storage.terms)\n", + "for i in range(bio_term_count):\n", + " term_data = biochemistry_storage.terms.pop(0)\n", + "\n", + " engine = ChatEngine(temp=0.5)\n", + " translator = TermChat(engine, translate_term_prompt)\n", + " print(f\"Translating term {i}: {term_data.termDef}\")\n", + " answer = translator.get_answer(term_data.termDef)\n", + " term_data.termDef = answer if answer else term_data.termDef\n", + " print(f\"Translated term {i}: {term_data.termDef}\")\n", + "\n", + " if term_data.area is None:\n", + " term_data.area = \"chem\"\n", + "\n", + " global_storage.terms.append(term_data)\n", + " biochemistry_storage.save()\n", + " global_storage.save()\n", + " if i % 10 == 0:\n", + " print(f\"Transferred {i} terms\")\n", + "\n", + " translator.clear_messages()\n", + "\n", + " if i > 50:\n", + " break" + ] } ], "metadata": {