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%

Home Page:https://discord.gg/qUtxnK2NMf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Receiving invalid_api_key when using api key that I've confirmed to be valid

dougdew64 opened this issue · comments

This code results in an error (invalid_api_key). I've confirmed that my api key is valid by successfully using it in some Swift code after this error occurred.

model = OptimizedOpenAILanguageModel(api_key='omitted', api_model='gpt-4')

search_algorithm = "BFS"

strategy = "cot"

evaluation_strategy = "value"

tree_of_thoughts = TreeofThoughts(model, search_algorithm)

input_problem = "use 4 numbers and basic arithmetic operations (+-*/) to obtain 24"

num_thoughts = 2
max_steps = 3
max_states = 5
value_threshold = 0.5

solution = tree_of_thoughts.solve(input_problem,
num_thoughts=num_thoughts,
max_steps=max_steps,
max_states=max_states,
value_threshold=value_threshold)

print(f"Final solution: {solution}")

I've debugged the problem all the way into the openai code, where the http request is sent to openai. The Authorization: Bearer header is correct.

This is baffling.

Perhaps leave the string empty in optimizedopenailanguagemodel and put your key in the ENV as OPENAI_API_KEY

Thanks. I tried that, and also tried specifying simultaneously in both locations. Both led to the same exception.

I just tested with curl, and received the same error. So, the problem has nothing to do with this stuff. Thank you again for being so helpful.

Meanwhile, I need to figure out why my api key works fine on MacOS but not on Windows / WSL2.

I generated a new api key and now am running the problem of 24 on my Windows / WSL2 machine.

I'm hoping to receive a result soon.