### Initialize and Run ChemAgent Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/README.md Demonstrates how to initialize the ChemAgent with a specified model and API keys, and then run a query to get the final answer, tool use chain, and conversation history. ```Python from api_keys import api_keys from chemagent import ChemAgent agent = ChemAgent(model='gpt-4o-2024-08-06', api_keys=api_keys) query = "What is the molecular weight the chemical compound Caffeine." final_answer, tool_use_chain, conversation, conversation_with_icl = agent.run(query) ``` -------------------------------- ### Set up Python Environment Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/README.md Installs project dependencies using pip and sets up a conda environment. It also mentions manual installation for Uni-Core. ```Bash conda create -n chemagent python=3.9 pip install -r requirements.txt # Manually install Uni-Core, following https://github.com/dptech-corp/Uni-Core ``` -------------------------------- ### Start Jupyter Server Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/README.md Navigates to the python_server directory and starts a Jupyter server on port 8888. ```Bash ./start_jupyter_server.sh 8888 ``` -------------------------------- ### Import Libraries for ChemAgent Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Imports the logging module, API keys, and the ChemAgent class from the chemagent library. These are essential for setting up and running the agent. ```Python import logging from api_keys import api_keys from chemagent import ChemAgent ``` -------------------------------- ### Initialize ChemAgent Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Initializes an instance of the ChemAgent with a specified model ('gpt-4o-2024-08-06') and API keys. This sets up the agent for processing queries. ```Python agent = ChemAgent(model='gpt-4o-2024-08-06', api_keys=api_keys) ``` -------------------------------- ### Run ChemAgent with Rephrasing and Formatting Options Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Demonstrates running the ChemAgent with additional parameters: 'do_rephrasing=True' to enable query rephrasing and 'format' to control the output format, specifically requesting only the result number and unit. ```Python # You could also use the 'do_rephrasing' and 'format' parameters to control the output final_answer, tool_use_chain, conversation, conversation_with_icl = agent.run(query, do_rephrasing=True, format='Only return the result number and unit.') ``` -------------------------------- ### Run ChemAgent with Default Parameters Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Executes the ChemAgent's run method with a predefined query. This call returns the final answer, the tool use chain, and the conversation history. ```Python # Run the agent final_answer, tool_use_chain, conversation, conversation_with_icl = agent.run(query) ``` -------------------------------- ### Define Query for ChemAgent Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Defines a sample query string to be processed by the ChemAgent. This query asks for the molecular weight of Caffeine. ```Python query = "What is the molecular weight the chemical compound Caffeine." ``` -------------------------------- ### Configure Debug Logging for ChemAgent Source: https://github.com/osu-nlp-group/chemtoolagent/blob/main/playground.ipynb Provides commented-out code to enable debug logging for the ChemAgent. This allows for detailed monitoring of the agent's operations, including its internal processes and any potential issues. ```Python # Uncomment the following line to enable debug logging # logger = logging.getLogger('chemagent') # logger.setLevel(logging.DEBUG) # handler = logging.StreamHandler() # formatter = logging.Formatter("[%(levelname)s] %(name)s: %(message)s") # handler.setFormatter(formatter) # logger.addHandler(handler) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.