File size: 4,026 Bytes
1e522dd
 
 
 
 
 
 
 
 
 
 
 
 
b38f031
 
 
1e522dd
 
 
 
b38f031
 
1e522dd
b38f031
1e522dd
b38f031
1e522dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b38f031
 
 
 
 
 
1e522dd
 
 
b38f031
 
 
 
 
 
 
 
 
 
 
1e522dd
 
 
 
 
 
 
b38f031
 
 
 
 
 
 
 
 
 
 
 
1e522dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# goal: store results from app.py into vector store

from structured_apparatus_chain import (
    arxiv_chain as apparatus_arxiv_chain, 
    pub_med_chain as apparatus_pub_med_chain, 
    wikipedia_chain as apparatus_wikipedia_chain
)
from structured_experiment_chain import (
    arxiv_chain as experiment_arxiv_chain, 
    pub_med_chain as experiment_pub_med_chain, 
    wikipedia_chain as experiment_wikipedia_chain
)


# from google_buckets import upload_file, man

from weaviate_utils import init_client

from datetime import datetime, timezone

from gradio_client import Client as ShapEClient
import os

from google_buckets import CloudStorageManager

from utils import copy_file_to_location

def main():
    # exp_qury = "fabricating cellolouse based electronics"
    # exp_qury = "fabrication of spider silk"
    # app_query = "microscope"
    # app_query = "A gas Condenser"
    app_query = "Electron Microscope"
    app_data = apparatus_arxiv_chain.invoke(app_query)
    # exp_data = experiment_arxiv_chain.invoke(exp_qury)
    
    weaviate_client = init_client()
    
    component_collection = weaviate_client.collections.get("Component")
    component_image_collection = weaviate_client.collections.get("ComponentImage")
    science_experiment_collection = weaviate_client.collections.get("ScienceEperiment")
    
    
    bucket_name = os.getenv('GOOGLE_BUCKET_NAME')
    manager = CloudStorageManager(bucket_name)
    
    
    
    app_components =  app_data["Material"]
    
    for i in app_components:
        
        client = ShapEClient("hysts/Shap-E")
        client.hf_token = os.getenv("HUGGINGFACE_API_KEY")
        result = client.predict(
                i,	# str  in 'Prompt' Textbox component
                1621396601,	# float (numeric value between 0 and 2147483647) in 'Seed' Slider component
                15,	# float (numeric value between 1 and 20) in 'Guidance scale' Slider component
                64,	# float (numeric value between 2 and 100) in 'Number of inference steps' Slider component
                api_name="/text-to-3d"
        )
        
    
        app_uuid = component_collection.data.insert({
            "Tags": app_data['Fields_of_study'],
            "FeildsOfStudy" : app_data['Fields_of_study'],
            "ToolName" : i,
            "UsedInComps" : [app_query]
        })
        
        glb_file_name = app_uuid.hex + ".glb"
        
        manager.upload_file(
            result,
            glb_file_name,
            )
        # copy_file_to_location(result,glb_file_name)
        # upload_file(glb_file_name)
        # os.remove(glb_file_name)
        
        x = 0
    
    response = component_collection.query.bm25(
            query="something that goes in a microscope",
            limit=5
        )
    
    # exp_uuid = science_experiment_collection.data.insert({
    #     # "DateCreated": datetime.now(timezone.utc),
    #     "FieldsOfStudy": exp_data['Fields_of_study'],
    #     "Tags": exp_data['Fields_of_study'],
    #     "Experiment_Name": exp_data['Experiment_Name'],
    #     "Material": exp_data['Material'],
    #     "Sources": exp_data['Sources'],
    #     "Protocal": exp_data['Protocal'],
    #     "Purpose_of_Experiments": exp_data['Purpose_of_Experiments'],
    #     "Safety_Precaution": exp_data['Safety_Precuation'],  # Corrected spelling mistake
    #     "Level_of_Difficulty": exp_data['Level_of_Difficulty'],
    # })
    
    response = science_experiment_collection.query.bm25(
            query="silk",
            limit=3
        )
    
    jj = science_experiment_collection.query.near_text(
        query="biology",
        limit=2
    )
    
    
    
    # uuid = component_collection.data.insert({
    #     "DateCreated" : datetime.now(timezone.utc),
    #     "UsedInComps" : [query],
    #     "ToolName" : shap_e_sample,
    #     "Tags" : shap_e_list,
    #     "feildsOfStudy" : shap_e_list,
    #     # "GlbBlob" : base_64_result,
    # })
    
    x = 0

if __name__ == '__main__':
    main()