OpenAI.__init__() got an unexpected keyword argument 'api_key' (type=type_error) #463
Replies: 1 comment
-
please update to the new version |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm a student and would love to learn about this algorithm works. I am trying to run the GraphBuilder code, but I keep getting the following error:
raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for OpenAI
root
OpenAI.init() got an unexpected keyword argument 'api_key' (type=type_error)
"""
GraphBuilder Module
"""
from langchain_core.prompts import ChatPromptTemplate
from langchain.chains import create_extraction_chain
from openai import OpenAI
from helpers import nodes_metadata, graph_schema
import json
import os
from dotenv import load_dotenv
load_dotenv()
def get_keys():
with open('keys.json', 'r') as f:
j = json.load(f)
return j['key']
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
print("OpenAI API Key:", OPENAI_API_KEY)
class GraphBuilder:
"""
GraphBuilder is a dynamic tool for constructing web scraping graphs based on user prompts.
It utilizes a natural language understanding model to interpret user prompts and
automatically generates a graph configuration for scraping web content.
Example Usage
prompt = "Scrape product names and prices from an e-commerce website."
config = {
"llm": {
"api_key": OPENAI_API_KEY,
"model": "gpt-3.5-turbo",
},
"verbose": True,
"headless": False,
}
graph_builder = GraphBuilder(prompt, config)
graph_config = graph_builder.build_graph()
graphviz_obj = graph_builder.convert_json_to_graphviz(graph_config)
graphviz_obj.view()
Any ideas how I can resolve it?
Beta Was this translation helpful? Give feedback.
All reactions