Kairong-Han / Causal_Agent

Causal Agent based on Large Language Model
30 stars 3 forks source link

A little question about how use ChatGPT API in your code #2

Open FrankLiu1102 opened 1 week ago

FrankLiu1102 commented 1 week ago

Thank you very much for sharing your code. I'm also very interested in the Causal Agent based on LLM. I'm trying to run your code, but since it's my first time using the ChatGPT API, I'm not very familiar with it. I modified this section in gpt_api.py by doing this:

openai.api_base = "https://api.openai.com/v1"

because I hink this is the API base URL.

and added my own key here:

class Keypool(): def init(self): self.api_keys = [ 'My-key', ] self.counter = 0 self.lock = threading.Lock()

However, the code doesn't seem to call the API correctly. I'm quite certain that my key is valid. Could it be that I made a mistake in some part, or do I need to adjust other sections of the code? I would be incredibly grateful if you could offer any guidance.

Kairong-Han commented 1 week ago

Thank you for being interested. if you want to use the causal agent, please replace line 57 in main.py by your openai API and line 323 (openai_api_base) by your openai.api_base. gpt_api.py is a .py file that is used in DGP process. If you want to use it, replace line 31 with your API and api_base. I hope this will solve your problem!

FrankLiu1102 commented 1 week ago

Thank you for your help. I tried running main.py, but I couldn't find dataset_gt.json in your Git repository, nor does your code seem to create this JSON file. However in line 382 in main.py: data_loader.read_data('DGP_description/dataset_gt.json').

Kairong-Han commented 1 week ago

Yes,line 382 should be replaced by the jsonl file you want to test. For example,result_xxx.jsonl in root path. I will update this soon,and thank you for reminding me.

---- Replied Message ---- | From | Wuche @.> | | Date | 11/03/2024 11:44 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [Kairong-Han/Causal_Agent] A little question about how use ChatGPT API in your code (Issue #2) |

Thank you for your help. I tried running main.py, but I couldn't find dataset_gt.json in your Git repository, nor does your code seem to create this JSON file. However in line 382 in main.py: data_loader.read_data('DGP_description/dataset_gt.json').

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>