Update all_tools.py
Browse files- all_tools.py +1 -29
all_tools.py
CHANGED
|
@@ -1,42 +1,14 @@
|
|
| 1 |
from llama_index.core import VectorStoreIndex, Document
|
| 2 |
from smolagents import tool
|
| 3 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 4 |
-
from all_datasets import *
|
| 5 |
from level_classifier_tool_2 import (
|
| 6 |
classify_levels_phrases,
|
| 7 |
HFEmbeddingBackend,
|
| 8 |
build_phrase_index
|
| 9 |
)
|
| 10 |
from phrases import BLOOMS_PHRASES, DOK_PHRASES
|
| 11 |
-
D = {
|
| 12 |
-
"GSM8k": GSM8k['question'],
|
| 13 |
-
"Olympiad": Olympiad_math['question'],
|
| 14 |
-
"Olympiad2": Olympiad_math2['question'],
|
| 15 |
-
"DeepMind Math": clean_math['question'],
|
| 16 |
-
"MMMLU": MMMLU['question'],
|
| 17 |
-
"MMMU": MMMU['question'],
|
| 18 |
-
"ScienceQA": ScienceQA['question'],
|
| 19 |
-
"PubmedQA": PubmedQA['question']
|
| 20 |
-
}
|
| 21 |
|
| 22 |
-
all_questions = (
|
| 23 |
-
list(D["GSM8k"]) +
|
| 24 |
-
list(D["Olympiad"]) +
|
| 25 |
-
list(D["MMMLU"]) +
|
| 26 |
-
list(D["MMMU"]) +
|
| 27 |
-
list(D["DeepMind Math"]) +
|
| 28 |
-
list(D["Olympiad2"]) +
|
| 29 |
-
list(D["ScienceQA"]) +
|
| 30 |
-
list(D["PubmedQA"])
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
emb = HuggingFaceEmbeddings(
|
| 34 |
-
model_name="google/embeddinggemma-300m",
|
| 35 |
-
encode_kwargs={"normalize_embeddings": True},
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
texts = all_questions
|
| 39 |
-
index = VectorStoreIndex.from_documents([Document(text=t) for t in texts], embed_model=emb)
|
| 40 |
#Retriever tool
|
| 41 |
@tool
|
| 42 |
def QuestionRetrieverTool(subject: str, topic: str, grade: str) -> dict:
|
|
|
|
| 1 |
from llama_index.core import VectorStoreIndex, Document
|
| 2 |
from smolagents import tool
|
| 3 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 4 |
+
#from all_datasets import *
|
| 5 |
from level_classifier_tool_2 import (
|
| 6 |
classify_levels_phrases,
|
| 7 |
HFEmbeddingBackend,
|
| 8 |
build_phrase_index
|
| 9 |
)
|
| 10 |
from phrases import BLOOMS_PHRASES, DOK_PHRASES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
#Retriever tool
|
| 13 |
@tool
|
| 14 |
def QuestionRetrieverTool(subject: str, topic: str, grade: str) -> dict:
|