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

OPENAI_API_KEY #1111

Open
abdullah91111 opened this issue Feb 22, 2025 · 11 comments
Open

OPENAI_API_KEY #1111

abdullah91111 opened this issue Feb 22, 2025 · 11 comments

Comments

@abdullah91111
Copy link

2025-02-22 20:55:44 openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: openai_a**_key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

When the document is processed the status shows failed and the above error occurs.

However I have updated the .env file with my open ai api key

If im correct I only need to replace OPENAI_API_KEY = "my_API_KEY" and nowhere else right?

If someone can let me know the why this error occurs.

@abdullah91111
Copy link
Author

Also, since Difbott offers a free tier but is eventually a paid service, is the diffbott api key mandatory, and if so, for what?

@kaustubh-darekar
Copy link
Collaborator

kaustubh-darekar commented Feb 24, 2025

Hi @abdullah91111
Openai key needs to be updated at at two places
OPENAI_API_KEY = #if you are using openai embedding model

For using LLM for extraction and chatbot, any of the following can be configured
LLM_MODEL_CONFIG_openai_gpt_3.5="gpt-3.5-turbo-0125,openai_api_key"
LLM_MODEL_CONFIG_openai_gpt_4o_mini="gpt-4o-mini-2024-07-18,openai_api_key"
LLM_MODEL_CONFIG_openai_gpt_4o="gpt-4o-2024-11-20,openai_api_key"
LLM_MODEL_CONFIG_openai-gpt-o3-mini="o3-mini-2025-01-31,openai_api_key"

For more clarity you can refer example.env in backend folder.

Diffbot is not mandatory if you are not using diffbot model.

@abdullah91111
Copy link
Author

Another question: is it possible to use this as a rest API? If so is there any guide on how to do so

@kartikpersistent
Copy link
Collaborator

our api's are designed specific to our application so we will not recommend to use our Api's for budling the application

@kartikpersistent
Copy link
Collaborator

you can use neo4j graphrag python package for building the gen ai application

@abdullah91111
Copy link
Author

In my use case scenario I dont want to build on top of the application but just use the rest api and integrate it with my n8n automated workflow. Would that be possible.

@kartikpersistent
Copy link
Collaborator

in that case you can use by providing appropriate payload

@abdullah91111
Copy link
Author

abdullah91111 commented Feb 27, 2025

Issue: Unable to Extract Entity Relationships from a Wikipedia Page

Context

I’m using the n8n HTTP node to integrate with GraphRAG. The process consists of two steps:

  1. Uploading a Wikipedia document via /url/scanWorks Successfully
  2. Extracting entity relationships via /extractFails with a document node error

Step 1: Uploading the Wikipedia Document via /url/scan

I send a POST request to /url/scan with these parameters:

Request Configuration

Method: POST

URL: http://backend:8000/url/scan

Content-Type: Form-Data

Body Parameters:

  • uri: bolt://neo4j-apoc:7687
  • userName: neo4j
  • password: ***
  • database: neo4j
  • model: openai_gpt_4o
  • wiki_query: https://en.wikipedia.org/wiki/Albert_Einstein
  • source_type: Wikipedia

Response Output

{
  "status": "Success",
  "data": {
    "elapsed_api_time": "10.14"
  },
  "success_count": 1,
  "failed_count": 0,
  "message": "Source Node created successfully for source type: Wikipedia and source: https://en.wikipedia.org/wiki/Albert_Einstein",
  "file_name": [
    {
      "fileName": "Albert_Einstein",
      "fileSize": 8074,
      "url": "https://en.wikipedia.org/wiki/Albert_Einstein",
      "language": "en",
      "status": "Success"
    }
  ]
}


Step 2: Extracting Entity Relationships via /extract
After successfully uploading the Wikipedia document, I attempt to extract entity relationships using /extract.

Request Configuration
Method: POST
URL: http://backend:8000/extract
Content-Type: Form-Data
Body Parameters:
uri: bolt://neo4j-apoc:7687
userName: neo4j
password: ***
database: neo4j
model: openai_gpt_4o
file_name: Albert_Einstein
wiki_query: https://en.wikipedia.org/wiki/Albert_Einstein
source_type: Wikipedia
allowedNodes: Document, Chunk, Entity
allowedRelationship: PART_OF, HAS_ENTITY
token_chunk_size: 512
chunk_overlap: 52
language: en

### **Error Response**  
2025-02-27 19:17:00 2025-02-27 15:17:00,680 - Total Pages from Wikipedia = 24
2025-02-27 19:17:00 2025-02-27 15:17:00,712 - Time taken database connection: 0.03 seconds
2025-02-27 19:17:00 2025-02-27 15:17:00,783 - Index already exist,Skipping creation. Time taken: 0.07 seconds
2025-02-27 19:17:00 2025-02-27 15:17:00,783 - Break down file into chunks
2025-02-27 19:17:00 2025-02-27 15:17:00,784 - Split file into smaller chunks
2025-02-27 19:17:00 2025-02-27 15:17:00,812 - creating FIRST_CHUNK and NEXT_CHUNK relationships between chunks
2025-02-27 19:17:00 2025-02-27 15:17:00,929 - Time taken to create list chunkids with chunk document: 0.15 seconds
2025-02-27 19:17:00 2025-02-27 15:17:00,932 - Time taken to get the current status of document node: 0.00 seconds
2025-02-27 19:17:00 2025-02-27 15:17:00,932 - Unable to get the status of document node.
2025-02-27 19:17:01 [2025-02-27 15:17:01 +0000] [13] [ERROR] Exception in ASGI application
2025-02-27 19:17:01 Traceback (most recent call last):
2025-02-27 19:17:01   File "/code/score.py", line 234, in extract_knowledge_graph_from_file
2025-02-27 19:17:01     uri_latency, result = await extract_graph_from_file_Wikipedia(uri, userName, password, database, model, wiki_query, language, file_name, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, retry_condition, additional_instructions)
2025-02-27 19:17:01   File "/code/src/main.py", line 278, in extract_graph_from_file_Wikipedia
2025-02-27 19:17:01     return await processing_source(uri, userName, password, database, model, file_name, pages, allowedNodes, allowedRelationship, token_chunk_size, chunk_overlap, chunks_to_combine, additional_instructions=additional_instructions)
2025-02-27 19:17:01   File "/code/src/main.py", line 458, in processing_source
2025-02-27 19:17:01     raise LLMGraphBuilderException(error_message)
2025-02-27 19:17:01 src.shared.llm_graph_builder_exception.LLMGraphBuilderException: Unable to get the status of document node.

@abdullah91111
Copy link
Author

For more context, I checked the status of the document node "Albert_Einstein" under properties, and the status is "New," so I don't understand why the status isn't passed in /extract endpoint.

@kartikpersistent
Copy link
Collaborator

@praveshkumar1988

@praveshkumar1988
Copy link
Collaborator

Hi @abdullah91111

You need pass parameter wikiquery and filename are same because in the extraction WikipediaLoader takes query string to search instead of wiki URL. Params looks like..

wiki_query: Albert_Einstein
source_type: Wikipedia
file_name: Albert_Einstein
token_chunk_size: 200
chunk_overlap: 20
chunks_to_combine: 1

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

4 participants