kyegomez / tree-of-thoughts

Plug in and Play Implementation of Tree of Thoughts: Deliberate Problem Solving with Large Language Models that Elevates Model Reasoning by atleast 70%
https://discord.gg/qUtxnK2NMf
Apache License 2.0
4.18k stars 353 forks source link

AuthenticationError when Using Tree of Thoughts with OpenAI's API #2

Closed webolizzer closed 1 year ago

webolizzer commented 1 year ago

Hello,

I'm attempting to use your Tree of Thoughts (ToT) library in conjunction with OpenAI's API, but I'm encountering an issue with authentication. When I try to instantiate either the OpenAILanguageModel or OptimizedOpenAILanguageModel class with my API key, I get the following error:

openai.error.AuthenticationError: <empty message>

This is confusing because when I use the same API key in a standalone script to call OpenAI's API directly, it works perfectly fine.

Here's the relevant part of my code (with the API key redacted):

from tree_of_thoughts import OpenAILanguageModel, TreeofThoughts

api_key = "my-api-key"  # redacted
model = OpenAILanguageModel(api_key)
tree_of_thoughts = TreeofThoughts(model, "BFS")

Do you have any idea why this might be happening, or suggestions for how I could troubleshoot this issue? Your guidance would be greatly appreciated.

Thank you in advance for your help.

Best Regards, Dennis

Gumbu commented 1 year ago

issue is in the treeofthoughts.py file his example script is also there. Edited for clarity.

webolizzer commented 1 year ago

@Gumbu

Ok, it works when I run treeofthoughts.py with example in it.

Thank you very much!

webolizzer commented 1 year ago

Ok the problem was inside of init.py of /tree_of_thoughts directory.

This file should contain the following code:

from .treeofthoughts import TreeofThoughts, CustomLanguageModel, OptimizedOpenAILanguageModel, OptimizedTreeofThoughts