Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- README.md +11 -13
- app.py +66 -0
- requirements.txt +8 -0
- storage/default__vector_store.json +0 -0
- storage/docstore.json +0 -0
- storage/graph_store.json +1 -0
- storage/image__vector_store.json +1 -0
- storage/index_store.json +1 -0
README.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# FishQ
|
2 |
+
A RAG Agent for the Guidelines of CPCSEA for Experimentation on Fishes-2021
|
3 |
+
|
4 |
+
|
5 |
+
## Write an brief description about the background information(prompt)
|
6 |
+
|
7 |
+
The given text is from the Guidelines of CPCSEA for Experimentation on Fishes-2021. The guidelines are intended to provide information on the humane procedures for holding, handling, and sampling fish for experimental, research, or teaching purposes. The guidelines cover various aspects of fish care and use, including the selection of appropriate fish species, housing and environmental conditions, feeding, handling and sampling, anesthesia and euthanasia, and the use of analgesics and anesthetics. The guidelines also provide information on the ethical considerations associated with the use of fish in research and the role of animal ethics committees in reviewing and approving fish research protocols. The guidelines are intended to promote the humane treatment of fish and to ensure that they are used in a responsible and ethical manner in research and teaching.
|
8 |
+
|
9 |
+
## To whom the background information will be of use(prompt)
|
10 |
+
|
11 |
+
The background information will be of use to the Institutional Animal Ethics Committee (IAEC) and the Institutional Biosafety Committee (IBC) of an institution that conducts experiments on fishes. The information will help them in ensuring that the fish facility is designed and operated in compliance with the guidelines set by the Committee for the Purpose of Control and Supervision of Experiments on Animals (CPCSEA), India. The IAEC and IBC can use this information to evaluate the facility's ability to provide adequate care and welfare to the fishes, ensure the safety of the staff and the environment, and maintain proper records. Additionally, the information can also be useful for researchers and fish facility managers to understand the best practices and regulatory requirements for conducting experiments on fishes.
|
|
|
|
app.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from llama_index.core import ServiceContext, StorageContext
|
2 |
+
from llama_index.core import VectorStoreIndex
|
3 |
+
from llama_index.llms.huggingface import HuggingFaceLLM
|
4 |
+
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
|
5 |
+
from llama_index.core import load_index_from_storage
|
6 |
+
from llama_index.core import Settings
|
7 |
+
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
8 |
+
from llama_index.core import VectorStoreIndex, get_response_synthesizer
|
9 |
+
from llama_index.core.retrievers import VectorIndexRetriever
|
10 |
+
from llama_index.core.query_engine import RetrieverQueryEngine
|
11 |
+
from llama_index.core.postprocessor import SimilarityPostprocessor
|
12 |
+
import gradio as gr
|
13 |
+
import os
|
14 |
+
from huggingface_hub import login
|
15 |
+
|
16 |
+
#Define the LLM to be used
|
17 |
+
Settings.llm = HuggingFaceInferenceAPI(model_name = "meta-llama/Meta-Llama-3-8B-Instruct")
|
18 |
+
|
19 |
+
#Define the embedding model
|
20 |
+
embed_model = HuggingFaceEmbedding(model_name="thenlper/gte-large")
|
21 |
+
Settings.embed_model = embed_model
|
22 |
+
|
23 |
+
#
|
24 |
+
PERSIST_DIR = "./storage"
|
25 |
+
storage_context = StorageContext.from_defaults(persist_dir = PERSIST_DIR)
|
26 |
+
index = load_index_from_storage(storage_context,index_id = "vector_index")
|
27 |
+
|
28 |
+
|
29 |
+
def gradio_interface(prompt):
|
30 |
+
try:
|
31 |
+
index = load_index_from_storage(storage_context, index_id="vector_index")
|
32 |
+
retriever = VectorIndexRetriever(
|
33 |
+
index=index,
|
34 |
+
similarity_top_k=2,
|
35 |
+
)
|
36 |
+
response_synthesizer = get_response_synthesizer()
|
37 |
+
query_engine = RetrieverQueryEngine(
|
38 |
+
retriever=retriever,
|
39 |
+
response_synthesizer=response_synthesizer,
|
40 |
+
node_postprocessors=[SimilarityPostprocessor(similarity_cutoff=0.7)]
|
41 |
+
)
|
42 |
+
response = query_engine.query(prompt)
|
43 |
+
return response
|
44 |
+
|
45 |
+
except Exception as e:
|
46 |
+
return f"An error occurred: {str(e)}"
|
47 |
+
|
48 |
+
with gr.Blocks(theme=gr.themes.Soft()) as interface:
|
49 |
+
gr.Markdown("# FishQ-RAG\nRAG Agent for 2021 CPCSEA Fish Experimentation Guidelines\n\nThe guidelines are intended to provide information on the humane procedures for holding, handling, and sampling fish for experimental, research, or teaching purposes.")
|
50 |
+
response = gr.Textbox(lines=10,label="Response",show_copy_button=True)
|
51 |
+
query = gr.Textbox(lines=2, placeholder="Ask me about guidelines here... Click submit or Shift + Enter.", label="Query")
|
52 |
+
|
53 |
+
gr.Examples(
|
54 |
+
examples=[
|
55 |
+
["What is CPCSEA?"],
|
56 |
+
["Give me guidelines for Zebrafish."],
|
57 |
+
["Write a compact email about the guidelines with their background information."]
|
58 |
+
],
|
59 |
+
inputs=query
|
60 |
+
)
|
61 |
+
|
62 |
+
submit_btn = gr.Button("Submit")
|
63 |
+
query.submit(gradio_interface, query, response)
|
64 |
+
submit_btn.click(gradio_interface, inputs=query, outputs=response)
|
65 |
+
|
66 |
+
interface.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
huggingface_hub
|
2 |
+
llama-index
|
3 |
+
transformers
|
4 |
+
torch
|
5 |
+
gradio
|
6 |
+
llama-index-llms-huggingface
|
7 |
+
llama-index-llms-huggingface-api
|
8 |
+
llama-index-embeddings-huggingface
|
storage/default__vector_store.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
storage/docstore.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
storage/graph_store.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"graph_dict": {}}
|
storage/image__vector_store.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"embedding_dict": {}, "text_id_to_ref_doc_id": {}, "metadata_dict": {}}
|
storage/index_store.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"index_store/data": {"vector_index": {"__type__": "vector_store", "__data__": "{\"index_id\": \"vector_index\", \"summary\": null, \"nodes_dict\": {\"d7059e42-a94c-4cce-8267-83401ae28c3e\": \"d7059e42-a94c-4cce-8267-83401ae28c3e\", \"cc0efab1-4d8c-4302-b9ee-123e1bffeb6d\": \"cc0efab1-4d8c-4302-b9ee-123e1bffeb6d\", \"028e1809-dc92-4061-b2f5-e5b969199559\": \"028e1809-dc92-4061-b2f5-e5b969199559\", \"e91f2494-ca8f-493b-8afc-f058feff91b8\": \"e91f2494-ca8f-493b-8afc-f058feff91b8\", \"ff95fc60-10bd-4de5-b70e-a2434cf534da\": \"ff95fc60-10bd-4de5-b70e-a2434cf534da\", \"84f3a275-81c7-4c88-bad2-89bb173934f7\": \"84f3a275-81c7-4c88-bad2-89bb173934f7\", \"44890f0d-37cd-4fbc-a5b7-8f99aed02024\": \"44890f0d-37cd-4fbc-a5b7-8f99aed02024\", \"dd4dd3c0-4bfb-46e6-9943-1956c05957e9\": \"dd4dd3c0-4bfb-46e6-9943-1956c05957e9\", \"b21adc4c-6aaa-48e9-8b66-4c9cb0aaae03\": \"b21adc4c-6aaa-48e9-8b66-4c9cb0aaae03\", \"cab0315b-313b-42de-8275-93b2a6515659\": \"cab0315b-313b-42de-8275-93b2a6515659\", \"6dff8738-a25f-4a28-8bbe-90bda2535107\": \"6dff8738-a25f-4a28-8bbe-90bda2535107\", \"ba61c32b-421c-45d3-83cd-239ca4f8d0b7\": \"ba61c32b-421c-45d3-83cd-239ca4f8d0b7\", \"3a54683e-f5a4-4b9c-94f2-013d6422791e\": \"3a54683e-f5a4-4b9c-94f2-013d6422791e\", \"823ee18c-8824-4d61-b19c-c4f316bb0c99\": \"823ee18c-8824-4d61-b19c-c4f316bb0c99\", \"3097b3f5-669a-4378-8671-d24b83f26c14\": \"3097b3f5-669a-4378-8671-d24b83f26c14\", \"fb4d7270-fd2f-448d-a293-9c13c3e938d8\": \"fb4d7270-fd2f-448d-a293-9c13c3e938d8\", \"ddf1b528-7d3a-4dee-903b-4f6473198994\": \"ddf1b528-7d3a-4dee-903b-4f6473198994\", \"b91f9ee8-abab-4b9f-a903-62f94c0ab194\": \"b91f9ee8-abab-4b9f-a903-62f94c0ab194\", \"bff92655-f753-4f53-91a2-388fc6a4c2ff\": \"bff92655-f753-4f53-91a2-388fc6a4c2ff\", \"79997015-3d2f-4e7d-872d-3b0edbe8b41c\": \"79997015-3d2f-4e7d-872d-3b0edbe8b41c\", \"22b80dc9-9900-40b5-bbeb-56761196da3b\": \"22b80dc9-9900-40b5-bbeb-56761196da3b\", \"d307511c-61a1-4035-82f4-0f4fccd37932\": \"d307511c-61a1-4035-82f4-0f4fccd37932\", \"0244e857-5921-422f-be2a-d22728fff592\": \"0244e857-5921-422f-be2a-d22728fff592\", \"89be9e89-1500-4da2-ad3a-1e774aadeb6b\": \"89be9e89-1500-4da2-ad3a-1e774aadeb6b\", \"1dde7b0b-d5c2-49b4-a13f-ffcf56720cb5\": \"1dde7b0b-d5c2-49b4-a13f-ffcf56720cb5\", \"86899ee0-a5da-4b4f-8be3-5ad179b615c5\": \"86899ee0-a5da-4b4f-8be3-5ad179b615c5\", \"0ff719e9-6e27-479f-a937-b4bf48264109\": \"0ff719e9-6e27-479f-a937-b4bf48264109\", \"965074ab-98fd-44b7-a654-fd3142a3d20e\": \"965074ab-98fd-44b7-a654-fd3142a3d20e\", \"4a4780df-4149-4464-932c-de31638b77bc\": \"4a4780df-4149-4464-932c-de31638b77bc\", \"7e0d6246-4c00-4d3c-a518-594106d14131\": \"7e0d6246-4c00-4d3c-a518-594106d14131\", \"a55608b8-eea4-4c92-86fb-4a30d69b5a60\": \"a55608b8-eea4-4c92-86fb-4a30d69b5a60\", \"c80ed325-3507-42c4-ad04-2e4adb7a9113\": \"c80ed325-3507-42c4-ad04-2e4adb7a9113\", \"a839196d-1109-4209-8d23-21b0ef0abcc1\": \"a839196d-1109-4209-8d23-21b0ef0abcc1\", \"dae1a15e-cd61-4839-adee-2e04b5e1f184\": \"dae1a15e-cd61-4839-adee-2e04b5e1f184\", \"a34602a9-ede3-4588-af5d-c67ef12c7241\": \"a34602a9-ede3-4588-af5d-c67ef12c7241\", \"069fa80a-752a-4e70-a2ad-68e511877570\": \"069fa80a-752a-4e70-a2ad-68e511877570\", \"1ab09310-9cc8-4a72-a5b4-cb5336a282b0\": \"1ab09310-9cc8-4a72-a5b4-cb5336a282b0\", \"21891201-2d59-47c7-b728-661b6bae93fb\": \"21891201-2d59-47c7-b728-661b6bae93fb\", \"64fc8001-db0e-4ac4-8be4-fd35feeecdde\": \"64fc8001-db0e-4ac4-8be4-fd35feeecdde\", \"d9f79895-0cf6-4558-a024-96e56a8739eb\": \"d9f79895-0cf6-4558-a024-96e56a8739eb\", \"25142976-7671-4522-889d-90e0392583d7\": \"25142976-7671-4522-889d-90e0392583d7\", \"617056d1-4027-46ae-8cdf-e5b1fb945c59\": \"617056d1-4027-46ae-8cdf-e5b1fb945c59\", \"31134d50-4277-4572-bf83-8062cfa3abf2\": \"31134d50-4277-4572-bf83-8062cfa3abf2\", \"990cade3-acb2-45ca-9e49-990943175de4\": \"990cade3-acb2-45ca-9e49-990943175de4\", \"16d1fb83-2560-4663-84e2-f0ba4a7b7ff3\": \"16d1fb83-2560-4663-84e2-f0ba4a7b7ff3\", \"9c1e9493-afb7-4f8f-b9f1-e4afe5c94a86\": \"9c1e9493-afb7-4f8f-b9f1-e4afe5c94a86\", \"ec62a715-62d4-490b-8d04-e104095b3fbe\": \"ec62a715-62d4-490b-8d04-e104095b3fbe\", \"6bb4f11c-4608-4f6f-b632-c218e241aa47\": \"6bb4f11c-4608-4f6f-b632-c218e241aa47\", \"7a25d77a-6dba-4754-b3f2-4516379eb83d\": \"7a25d77a-6dba-4754-b3f2-4516379eb83d\", \"692c9d43-ac85-40fb-8ace-65e33c2b9b6d\": \"692c9d43-ac85-40fb-8ace-65e33c2b9b6d\", \"5d5c7bee-b706-4d51-81dd-50dd58986a56\": \"5d5c7bee-b706-4d51-81dd-50dd58986a56\", \"47a769b8-48ef-43dd-aa14-66f0833e6e41\": \"47a769b8-48ef-43dd-aa14-66f0833e6e41\", \"207543ee-cd30-4233-aca4-0657ecf81431\": \"207543ee-cd30-4233-aca4-0657ecf81431\", \"4f761b06-6006-42bd-ac7d-5dd4be4919d9\": \"4f761b06-6006-42bd-ac7d-5dd4be4919d9\", \"22169a79-1658-4e9b-b2c1-897f416d1e30\": \"22169a79-1658-4e9b-b2c1-897f416d1e30\", \"6e02dc08-d254-48c2-a176-dc49f37bae84\": \"6e02dc08-d254-48c2-a176-dc49f37bae84\", \"539b031d-34e3-4320-aeb1-a3aac5d235eb\": \"539b031d-34e3-4320-aeb1-a3aac5d235eb\", \"2ac723fd-9caf-41a9-b39c-4a6e386619eb\": \"2ac723fd-9caf-41a9-b39c-4a6e386619eb\", \"0874fc1a-455f-41a8-87eb-3d36b7d9f4d3\": \"0874fc1a-455f-41a8-87eb-3d36b7d9f4d3\", \"b80ee19c-1f1f-435d-bdb7-de7ac10cc4cf\": \"b80ee19c-1f1f-435d-bdb7-de7ac10cc4cf\", \"d20e6f4d-b339-4093-8261-e85e51361fb3\": \"d20e6f4d-b339-4093-8261-e85e51361fb3\", \"f5f31693-ebf1-4a0b-abbf-ff1831d3663a\": \"f5f31693-ebf1-4a0b-abbf-ff1831d3663a\", \"2211ac7e-3a96-43e6-b632-f5973324c34e\": \"2211ac7e-3a96-43e6-b632-f5973324c34e\", \"76d48882-2cbd-41ab-a2d3-8ad506c1b533\": \"76d48882-2cbd-41ab-a2d3-8ad506c1b533\", \"b0a407fb-5386-4cd1-88f8-8eaee09d25f8\": \"b0a407fb-5386-4cd1-88f8-8eaee09d25f8\", \"c9346529-94e0-461a-96b9-8de3dcde6e0f\": \"c9346529-94e0-461a-96b9-8de3dcde6e0f\", \"caf0ba01-e119-42d6-b88e-baa203694ab0\": \"caf0ba01-e119-42d6-b88e-baa203694ab0\", \"ce6a2a8b-e58d-43dc-b446-472fbeaadeb5\": \"ce6a2a8b-e58d-43dc-b446-472fbeaadeb5\", \"c7076762-91bf-4ecd-8611-e30a095e2bf4\": \"c7076762-91bf-4ecd-8611-e30a095e2bf4\", \"18fa95f7-1d87-4752-95bf-3b7812211340\": \"18fa95f7-1d87-4752-95bf-3b7812211340\", \"83ba42ea-08e7-45b9-b1b9-b3493ceeeae7\": \"83ba42ea-08e7-45b9-b1b9-b3493ceeeae7\", \"a119d185-98ca-4e13-b3de-9cb5d070a968\": \"a119d185-98ca-4e13-b3de-9cb5d070a968\", \"d04d94d5-7a41-47fc-8298-11036959cfea\": \"d04d94d5-7a41-47fc-8298-11036959cfea\", \"fc0df6ab-ef89-4417-8453-ef902cd9c30c\": \"fc0df6ab-ef89-4417-8453-ef902cd9c30c\", \"f51963e6-80e3-4900-8973-dc33342a6b07\": \"f51963e6-80e3-4900-8973-dc33342a6b07\", \"15d6e3fe-8c8f-4fb9-9efe-7110d2991603\": \"15d6e3fe-8c8f-4fb9-9efe-7110d2991603\", \"3220f1d5-a4c5-43e9-bd95-58883f16dd9a\": \"3220f1d5-a4c5-43e9-bd95-58883f16dd9a\", \"80ccb397-a25a-4c52-8a4f-5751c66adb1f\": \"80ccb397-a25a-4c52-8a4f-5751c66adb1f\", \"8a3bc47c-4674-4ae8-bacf-c17ee7d65b05\": \"8a3bc47c-4674-4ae8-bacf-c17ee7d65b05\", \"f62ae07c-e9e6-478b-918b-15ad0f212f9c\": \"f62ae07c-e9e6-478b-918b-15ad0f212f9c\", \"232a5c6f-f946-43a9-a0d4-1d6d6db5821f\": \"232a5c6f-f946-43a9-a0d4-1d6d6db5821f\", \"51099a50-f210-4b63-8b14-709d990a2c8b\": \"51099a50-f210-4b63-8b14-709d990a2c8b\", \"2fdaf246-cb69-491b-8769-83153d407c17\": \"2fdaf246-cb69-491b-8769-83153d407c17\", \"431d7148-f106-44cb-acec-ee3ca7d5ce6f\": \"431d7148-f106-44cb-acec-ee3ca7d5ce6f\", \"32750f09-3d90-4236-aedd-e33b2a9942f2\": \"32750f09-3d90-4236-aedd-e33b2a9942f2\", \"0667b191-6c95-4e63-9257-7c3cc609912a\": \"0667b191-6c95-4e63-9257-7c3cc609912a\", \"ffca4382-8d4a-4732-b3a4-92736b5b4203\": \"ffca4382-8d4a-4732-b3a4-92736b5b4203\", \"e45aaaef-ec8f-4068-9dd5-d8fc9f77d424\": \"e45aaaef-ec8f-4068-9dd5-d8fc9f77d424\", \"798d168a-4dcb-467a-9ff9-f69d28fc3082\": \"798d168a-4dcb-467a-9ff9-f69d28fc3082\", \"38df0860-0954-4be0-b93e-115fd6acb993\": \"38df0860-0954-4be0-b93e-115fd6acb993\", \"64ed3169-0031-4fef-a6ad-d04a868ec23d\": \"64ed3169-0031-4fef-a6ad-d04a868ec23d\", \"2fad9242-4401-4fff-83eb-f402bd54bd4b\": \"2fad9242-4401-4fff-83eb-f402bd54bd4b\", \"8f505abb-d29f-4908-88c3-54ada3fe0758\": \"8f505abb-d29f-4908-88c3-54ada3fe0758\", \"80a20c6a-8577-4f5b-8a39-355006f5e80a\": \"80a20c6a-8577-4f5b-8a39-355006f5e80a\", \"a25421ce-4609-4cd1-81ad-07e284ac1bd6\": \"a25421ce-4609-4cd1-81ad-07e284ac1bd6\", \"997e3edf-1841-46e5-8581-7d3cafa74229\": \"997e3edf-1841-46e5-8581-7d3cafa74229\", \"ff87b132-70d0-4486-9f04-9889638f1ea8\": \"ff87b132-70d0-4486-9f04-9889638f1ea8\", \"b9cc99ae-9119-4584-a703-e1516540691f\": \"b9cc99ae-9119-4584-a703-e1516540691f\", \"672435a7-9255-45f0-9328-6f36b79efadc\": \"672435a7-9255-45f0-9328-6f36b79efadc\", \"e5fa58e7-9c40-4d7a-8156-0e62b9b6b4d6\": \"e5fa58e7-9c40-4d7a-8156-0e62b9b6b4d6\", \"82bd0570-25d7-4dcd-914f-9063950707a9\": \"82bd0570-25d7-4dcd-914f-9063950707a9\", \"a3c0006b-74ae-4ad2-887c-94a1669c5db2\": \"a3c0006b-74ae-4ad2-887c-94a1669c5db2\", \"b2711784-29db-44df-86c4-1cdb5b7aba38\": \"b2711784-29db-44df-86c4-1cdb5b7aba38\", \"0bcdfc91-ef45-44fe-8045-187021b5b3f1\": \"0bcdfc91-ef45-44fe-8045-187021b5b3f1\", \"9a4570eb-5dcf-4fec-a377-9962a32c8c66\": \"9a4570eb-5dcf-4fec-a377-9962a32c8c66\", \"8dc3d384-9df2-4771-b47b-39c6daf2b932\": \"8dc3d384-9df2-4771-b47b-39c6daf2b932\", \"12ef895e-6043-4573-8598-0d922673412e\": \"12ef895e-6043-4573-8598-0d922673412e\", \"08476221-b1f5-4910-b8b2-f75fef06b737\": \"08476221-b1f5-4910-b8b2-f75fef06b737\", \"0383e2c8-abf0-4956-9f1e-710fc2d7667f\": \"0383e2c8-abf0-4956-9f1e-710fc2d7667f\", \"1b2a05d9-16f2-446e-a0da-fd6214098110\": \"1b2a05d9-16f2-446e-a0da-fd6214098110\", \"961c0593-bc6d-4031-a70d-5c6b5336f627\": \"961c0593-bc6d-4031-a70d-5c6b5336f627\", \"4fa49e38-438a-4124-ac7a-078f34469b49\": \"4fa49e38-438a-4124-ac7a-078f34469b49\", \"8471d884-ba91-49ce-8cdd-58748df73348\": \"8471d884-ba91-49ce-8cdd-58748df73348\", \"f2841654-ff3f-41c2-b728-805c165cec12\": \"f2841654-ff3f-41c2-b728-805c165cec12\"}, \"doc_id_dict\": {}, \"embeddings_dict\": {}}"}}}
|