Giter Site home page Giter Site logo

instagraph's Introduction

Note for non-coders: you can sign up for the waitlist at instagraph.ai.

InstaGraph 🌐

Hello there, adventurous coder! Welcome to InstaGraph, your go-to application for converting text or URLs into insightful knowledge graphs. Curious about the relationships between entities in a complex topic? Feed the text to InstaGraph and voila! A beautiful knowledge graph is at your fingertips.

See example flowcharts generated by InstaGraph here.

Powered by OpenAI's GPT-3.5, this Flask application turns your text into a vividly colored graph, making it easier to visualize relationships between various entities. Enough talkingβ€”let's get started!

Author's TL;DR: If you're just looking for how the knowledge graph is generated, check out the function call parameters taking up half of main.py.

Table of Contents πŸ“š

Features 🌟

  • Dynamic Text to Graph conversion.
  • Color-coded graph nodes and edges.
  • Responsive designβ€”use it on any device.
  • Super-duper user-friendly!

Installation πŸ› οΈ

To get started, you'll need Python and pip installed.

1. Clone the repository

git clone https://github.com/yoheinakajima/instagraph.git

2. Navigate to the project directory

cd instagraph

3. Install the required Python packages

pip install -r requirements.txt

4. Set up your OpenAI API Key

Change .env.example to .env

mv .env.example .env

Add your OpenAI API key to .env file:

OPENAI_API_KEY=your-api-key-here
Optional - Set a Graph Database

Use: [--graph neo4j|falkordb] to select the Graph Database driver

  • Neo4J

Add Neo4J username, password and URL in the *.env file as well by creating an instance of neo4j.

NEO4J_USERNAME=
NEO4J_PASSWORD=
NEO4J_URI=
  • FalkorDB

Add FalkorDB URL in the *.env file as well by creating an instance of FlakorDB.

FALKORDB_URL=

5. Run the Flask app

python main.py [--graph neo4j|falkordb] [--port port] [--debug]

Navigate to http://localhost:8080 to see your app running.

Run as Container

1. Clone the repository

git clone https://github.com/yoheinakajima/instagraph.git

2. Navigate to the project docker directory

cd instagraph/docker

3.1 Run in Dev mode

docker-compose -f docker-compose-dev.yml up # Add -d flag at the end to run in background/daemon mode.

3.2 Run in Prod - Create the docker image

  • Using the gunicorn==21.2.0 to run the application in production mode
docker-compose -f docker-compose.yml up --build -d

Usage πŸŽ‰

Web Interface

  • Open your web browser and navigate to http://localhost:8080.
  • Type your text or paste a URL in the input box.
  • Click "Submit" and wait for the magic to happen!

API Endpoints

  1. GET Response Data: /get_response_data

    • Method: POST
    • Data Params: {"user_input": "Your text here"}
    • Response: GPT-3.5 processed data
  2. GET Graph Data: /get_graph_data

    • Method: POST
    • Response: Graph Data
  3. GET History Data: /get_graph_history

    • Method: GET
    • Response: Graph Data

Contributing 🀝

Best way to chat with me is on Twitter at @yoheinakajima. I usually only code on the weekends or at night, and in pretty small chunks. I have lots ideas on what I want to add here, but obviously this would move faster with everyone. Not sure I can manage Github well given my time constraints, so please reach out if you want to help me run the Github. Now, here are a few ideas on what I think we should add based on comments...

  • Store knowledge graph (thx @tomasonjo! 9/13/23)
  • Pull knowledge graph from storage (thx @tomasonjo! 9/13/23)
  • Show history
  • Ability to combine two graphs
  • Ability to combine 2+ graphs from history
  • Ability to expand on a graph (thx @tomasonjo! 9/13/23)
  • Ability to expand on graph from specific nodes
  • Fuzzy matching of nodes for combining graphs (vector match + LLM confirmation)

There are a lot of "build a chart" tools out there, so instead of doing user account and custom charts, it sounds more fun for me to work on building the largest knowledge graph ever...

Before creating an Issue please refer the ISSUE_TEMPLATE provided.

License πŸ“

MIT License. See LICENSE for more information.


Enjoy using InstaGraph! πŸŽ‰

instagraph's People

Contributors

alexweberk avatar danryland avatar dogukanurker avatar eltociear avatar erjanmx avatar gkorland avatar isamu avatar jxnl avatar lukafin avatar mesax1 avatar n1n9-jp avatar prasantpoudel avatar sagardobariya avatar saswatsusmoy avatar shashankshet avatar shepherd-06 avatar snakajima avatar tomasonjo avatar treee97 avatar velocitatem avatar vizsumit avatar yoheinakajima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instagraph's Issues

[BUG]Page request twice, resulting in generating two charts

I noticed on the console that the conversation sent two/get_response_data requests, resulting in the chart being updated for the second time.
The second question is, I found that some of the answers I received were too simple and not practical, such as asking: What are the directions for thinking? Its answer is direction one and direction two, rather than actual type names, such as life or work

[BUG] Error fetching graph history

Describe the bug
When entering http://localhost:8080 a message appears saying the following statement: "Graph History
Error fetching graph history: Error: Network response was not ok INTERNAL SERVER ERROR". Also the submit button does nothing.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository.
  2. Install the requirements.
  3. Prepare the environment by adding your Openai key and changing the name of the env file to .env.
  4. Run main.py.
  5. Enter localhost to see the error.

Expected behavior
A working text input field and Submit button.

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Browser [Chrome and Firefox]
  • Version [latest]

Additional context
Add any other context about the problem here.

[Question] Scrape text from website function never used?

Following function is never used:

def scrape_text_from_url(url):
	response = requests.get(url)
    if response.status_code != 200:
        return "Error: Could not retrieve content from URL."
    soup = BeautifulSoup(response.text, "html.parser")
    paragraphs = soup.find_all("p")
    text = " ".join([p.get_text() for p in paragraphs])
    print("web scrape done")
    return text`

Why am I getting error code 429 everytime ""POST /get_response_data HTTP/1.1" 429"

I set up everything from installation to Open AI API Key and neo4j credentials however every time I try to generate graph I get nothing but this error code in terminal ""POST /get_response_data HTTP/1.1" 429"
I have some idea that it has to do something API rate limit but but this is my first time using Open AI API Keys.
here is screenshot:

[BUG] Not generating graphs from URL

Describe the bug
Generates graphs from a text prompt but no graph is generated from a URL input.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository.
  2. Install the requirements.
  3. Prepare the environment by adding your Openai key and changing the name of the env file to .env.
  4. Run main.py.
  5. Open localhost and enter a URL (e.g. https://aws.amazon.com/what-is/quantum-computing/)
  6. Wait for the loading bar to finish, no graph is generated

Expected behaviour
Generation of a graph from the URL.

Screenshots
Screenshot 2023-09-17 at 18 05 31

Desktop (please complete the following information):

  • OS: macOS
  • Browser firefox
  • Version [Latest]

Free users go beyond rate limits

Free users can only do 3 requests per minute, by default when submitting a request the app doesn't wait and the quote is exceeded, and a stack trace is shown on the console launching the flask app.

A solution for free users would be to wait 20 or 30 seconds between each request towards openai api.

Not able to setup the environment to run the code

After completing all the steps in README file, and troubleshooting some things by my self. I got the following error while running "python main.py" in terminal

NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Traceback (most recent call last):
  File "/Users/dhandeepsingh/Desktop/instagraph/main.py", line 5, in <module>
    from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

How to fix this issue??

problem installing the requirement neo4j , i keep getting this error

Collecting neo4j==5.12.0
Downloading neo4j-5.12.0.tar.gz (190 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 190.9/190.9 KB 2.0 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
WARNING: Generating metadata for package neo4j produced metadata for project name unknown. Fix your #egg=neo4j fragments.
Discarding https://files.pythonhosted.org/packages/19/11/9af80c8621ba433039bf47acd7b037998138516eb86fdb9ba492c49ee844/neo4j-5.12.0.tar.gz#sha256=00a776a687267150f9e1950017316b751cf63db7b734a699b1405ac20fd4a731 (from https://pypi.org/simple/neo4j/) (requires-python:>=3.7): Requested unknown from https://files.pythonhosted.org/packages/19/11/9af80c8621ba433039bf47acd7b037998138516eb86fdb9ba492c49ee844/neo4j-5.12.0.tar.gz#sha256=00a776a687267150f9e1950017316b751cf63db7b734a699b1405ac20fd4a731 (from -r requirements.txt (line 6)) has inconsistent name: filename has 'neo4j', but metadata has 'unknown'
ERROR: Could not find a version that satisfies the requirement neo4j==5.12.0 (from versions: 1.7.0b1, 1.7.0b2, 1.7.0b3, 1.7.0b4, 1.7.0rc1, 1.7.0rc2, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 4.0.0a1, 4.0.0a2, 4.0.0a3, 4.0.0a4, 4.0.0b1, 4.0.0b2, 4.0.0rc1, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.1.0rc1, 4.1.0rc2, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.2.0a1, 4.2.0, 4.2.1, 4.3.0a1, 4.3.0b1, 4.3.0rc1, 4.3.0, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.3.6, 4.3.7, 4.3.8, 4.3.9, 4.4.0a1, 4.4.0b1, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5, 4.4.6, 4.4.7, 4.4.8, 4.4.9, 4.4.10, 4.4.11, 5.0.0a1, 5.0.0a2, 5.0.0, 5.0.1, 5.1.0, 5.2.0, 5.2.1, 5.3.0, 5.4.0, 5.5.0, 5.6.0, 5.7.0, 5.8.0, 5.8.1, 5.9.0, 5.10.0, 5.11.0, 5.12.0)
ERROR: No matching distribution found for neo4j==5.12.0

Error in installing

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
transformers 2.1.1 requires sentencepiece, which is not installed.
anaconda-cloud-auth 0.1.4 requires pydantic<2.0, but you have pydantic 2.4.2 which is incompatible.
python-lsp-black 1.2.1 requires black>=22.3.0, but you have black 0.0 which is incompatible.

I get the above message in windows powershell when using this command;
pip install -r requirements.txt

Screenshot 2023-10-30 223103

What would be the next step to move forward with the install?

Template html seems broken

i get this instead of a graph
image

looking at the index.html it seems rekt (some text meant to be in script tags are just hanging out below the html closing tag

Graph

console has been displaying the following - 127.0.0.1 - - [16/Sep/2023 11:04:40] "POST /get_response_data HTTP/1.1" 200 but the graph is not being displayed at http://127.0.0.1:8080

[Question] how to eliminate creation of duplicated nodes

If I ask the same question few times, it will create nodes with same name
if I will use similar world like DB or Database or Azure SQLDB or Azure SQL DB, it will also create duplicated.
where I can change it? maybe idea for feature.
image

Bigger UI in browser

I have a vary narrow screen in my browser (after opening localhost 8080) How can I increase the size so I can see the graph much more clear?

Error when running Flask application

Describe the bug
Error when running Flask application
ζ–°ε»Ίζ–‡ζœ¬ζ–‡ζ‘£.txt

(myenv) D:\my projects\instagraph>python main.py
File "D:\my projects\instagraph\main.py", line 262
match graph.lower():
^
SyntaxError: invalid syntax

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [winows]
  • Browser [chrome]
  • Version [10]

Additional context
Add any other context about the problem here.

[Question] what is `response_model` ?

Hi! can someone explain what the response_model param used here is:

https://github.com/yoheinakajima/instagraph/blob/main/main.py#L144C18-L144C18

this seems to format the response in exactly the data structure of the models provided.
Is this an openAI thing, or part of fast API? I can't find any docs on openAI's site.

https://platform.openai.com/docs/api-reference/chat

If its an openAI thing perhaps its also magically reading the heredoc of the python classes?

I'm actually trying to use the API via typescript, so I was wondering what the parallel might be.

[BUG] NameError: name 'user_plan' is not defined

Describe the bug
I'm getting the following error when trying to open the link

$ python3 main.py
 * Serving Flask app 'main'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:8080
 * Running on http://192.168.1.132:8080
Press CTRL+C to quit
[2023-09-22 03:59:57,400] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 1487, in full_dispatch_request
    return self.finalize_request(rv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 1508, in finalize_request
    response = self.process_response(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 2002, in process_response
    response = self.ensure_sync(func)(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 66, in add_header
    if check_if_free_plan():
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 61, in check_if_free_plan
    return user_plan == 'free'
           ^^^^^^^^^
NameError: name 'user_plan' is not defined
[2023-09-22 03:59:57,400] ERROR in app: Request finalizing failed with an error while handling an error
Traceback (most recent call last):
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 1487, in full_dispatch_request
    return self.finalize_request(rv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 1508, in finalize_request
    response = self.process_response(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 2002, in process_response
    response = self.ensure_sync(func)(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 66, in add_header
    if check_if_free_plan():
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 61, in check_if_free_plan
    return user_plan == 'free'
           ^^^^^^^^^
NameError: name 'user_plan' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 1508, in finalize_request
    response = self.process_response(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/.local/lib/python3.11/site-packages/flask/app.py", line 2002, in process_response
    response = self.ensure_sync(func)(response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 66, in add_header
    if check_if_free_plan():
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/guy/workspace/instagraph/main.py", line 61, in check_if_free_plan
    return user_plan == 'free'
           ^^^^^^^^^
NameError: name 'user_plan' is not defined
127.0.0.1 - - [22/Sep/2023 03:59:57] "GET / HTTP/1.1" 500 -

To Reproduce
Steps to reproduce the behavior:

  1. Run python3 main.py
  2. Click on one of the links

Desktop (please complete the following information):

  • OS: Ubuntu 23.04
  • Browser Firefox
  • Version 117.01

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.