Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run generated sql code ? #3

Open
SamhithKakarla opened this issue Jun 12, 2024 · 8 comments
Open

How to run generated sql code ? #3

SamhithKakarla opened this issue Jun 12, 2024 · 8 comments

Comments

@SamhithKakarla
Copy link

SamhithKakarla commented Jun 12, 2024

Hello,

I downloaded and ran your code from the repo. The ouput i get locally doesnt match the intended output from your demo: https://wshi83.github.io/EHR-Agent-page/ . Here we see that the EHR agent is not only able to generate the code but also successfully execute the code to get an answer. When i run your code locally i only get the SQL output but not the actual answer. The code is never executed.

I was wondering how i can run the generated code? could i be missing some configurations ?

Furthermore, In the demo the EHR agent also able successfully re-write the code in the case of errors how would i ensure this also happens locally ?

Thanks

@night-chen
Copy link
Collaborator

Hi Samhith,

Thank you for your interest in our work. Our code is designed to automatically generate a code-based solution plan and modify the answers accordingly based on specific questions. To address your issue, we recommend the following checks:

  • Use the GPT-4 (0613) version: Reimplement the results using this version, as it explicitly supports function calling. Additionally, ensure you are using pyautogen version 0.2.0, as our code is developed on top of AutoGen, which is rapidly evolving.

  • Run the provided tools: Execute python tabtools.py in the EhrAgent/tools/ directory. This allows you to test the defined tools and identify any issues. Specifically, for the SQL issue, un-comment Line 215 of tabtools.py to see if it resolves the problem.

All the demos shown on the project page are from the running logs of this code. If the settings are correct, you should get the same logs in YOUR_LOG_PATH.

I hope these suggestions help resolve your issue.

Best regards,
EHRAgent Authors

@SamhithKakarla
Copy link
Author

Hey, i was following your advise, when i tried running python3 tabtools.py i immediately run into the following issue:
Screenshot 2024-06-15 at 4 40 32 PM

what is table_toolkits() ? i did a search for that symbol in your code and it was never defined and i ensured i have all the same imports aswell.

@night-chen
Copy link
Collaborator

Hi SamhithKakarla,

Those lines are commands from the previous version. You can try the following:
data = db_loader("microbiologyevents")
filtered_data = data_filter(data, "HADM_ID=107655")
filtered_data = data_filter(filtered_data, "SPEC_TYPE_DESC=peripheral blood lymphocytes")
values = get_value(filtered_data, 'CHARTTIME')
sql_results = sql_interpreter("select max(t1.c1) from ( select sum(cost.cost) as c1 from cost where cost.hadm_id in ( select diagnoses_icd.hadm_id from diagnoses_icd where diagnoses_icd.icd9_code = ( select d_icd_diagnoses.icd9_code from d_icd_diagnoses where d_icd_diagnoses.short_title = 'comp-oth vasc dev/graft' ) ) and datetime(cost.chargetime) >= datetime(current_time,'-1 year') group by cost.hadm_id ) as t1")

You can try to substitute these commands with the original commands in the tabtools.py. And the target is to test if each of the tools can be executed correctly. If your issue has not been resolved, can you also offer the error information when you execute the main code?

Thank you!

Best,
EHRAgent authors

@SamhithKakarla
Copy link
Author

When running the code with gpt4 i get 1 of 2 errors : Error: ModuleNotFoundError("No module named 'tools'"). Please make modifications accordingly and make sure the rest code works well with the modification. Potential Reasons: The error message indicates that there is a missing module named 'tools'. However, the provided code does not seem to import or use a module named 'tools'. The error might be coming from one of the functions used in the code, possibly these functions are defined in another script where 'tools' module is not imported correctly. TERMINATE

or sometimes it will output the following:

exitcode: 1 (execution failed) Code output: Traceback (most recent call last): File "", line 2, in <module> patient_db = LoadDB('admissions') NameError: name 'LoadDB' is not defined

@SamhithKakarla
Copy link
Author

Even after running spesifically with gpt-4-0613 i am still getting the following error:

Screenshot 2024-06-26 at 7 22 51 PM

please advise how to move forward.

@zlzGithub-0801
Copy link

Hello SamhithKakarla,
Maybe you can try to move tools folder into ehragent folder.

Currently, it is:

.
|---ehragent
|---scripts
|---tools

Change it to:

.
|---ehragent
|     |---tools
|---scripts

@SamhithKakarla

This comment was marked as outdated.

@SamhithKakarla
Copy link
Author

Finally got it working. Moving tools into the ehragent folder as mentioned above and un-installing tools fixed the issue!! I also had to remember to update the dataset path in tabtools.py. Thanks for the help !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants