Global-Chem / global-chem

A Knowledge Graph of Common Chemical Names to their Molecular Definition
https://globalchemistry.org/
Mozilla Public License 2.0
153 stars 20 forks source link

SS-181: Create an Agent LLM for Global-Chem using PandasAI #312

Open Sulstice opened 2 months ago

Sulstice commented 2 months ago
# Imports
# -------
import os
import pandas as pd
from pandasai import Agent
from pandasai.skills import skill

import plotly.graph_objects as go

class GlobalChemAgentLoader(object):

    __PANDAS_API_KEY__ = 'XXXX'

    def __init__(self, load_agents=[]):

        self.load_agents = load_agents
        self.gc_dataframe = self.read_global_chem()
        self.agent = self.build_global_chem_agent()

    def read_global_chem_dataframe(self):

        dataframe = pd.read_csv('global_chem.tsv', delimiter='\t')

        return dataframe

    def build_global_chem_agent(self):

        os.environ['PANDASAI_API_KEY'] = GlobalChemAgentLoader.__PANDAS_API_KEY__
        agent = Agent([ self.gc_dataframe ])

        agent.add_skills(
             show_chemicals_table
        )

        return agent

    @skill
    @staticmethod
    def show_chemicals_table(dataframe):

        '''
        Display all the chemicals in a table
        '''

if __name__ == '__main__':

    global_chem_agent_loader = GlobalChemAgentLoader()
Sulstice commented 1 month ago

Next tasks:

1.) Take your agent and make a standalone python script. 2.) Stand up a local server 3.) Write a docker file to install all the python scripts, and standup the server inside directory. This is probably already done by someone: https://github.com/Sinaptik-AI/pandas-ai (case in the point).

Download the docker, and then run it. Once that is accomplished, we can stand up the agent on heroku or something free or like digital ocean.

Tasks for Both of us:

  1. https://github.com/Global-Chem/Mother-Nature Edit Mother nature again, remove commands that we won't use and then add pandasai agent.