Skip to content

0.7.1 #20

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

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ verify_ssl = true
name = "pypi"

[packages]
streamlit-player = "*"
graph-data-generator = "*"
streamlit-extras = "*"
neo4j-uploader = "*"
streamlit = "*"

[dev-packages]

Expand Down
799 changes: 110 additions & 689 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion graph_data_generator_streamlit/ui/config_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ def config_ui():

# Display current app version
# TODO: Pull this directly from the pyproject.toml
version = "0.7.0"
version = "0.7.1"
st.write(f"Version {version}")
1 change: 0 additions & 1 deletion graph_data_generator_streamlit/ui/data_importer_ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import streamlit as st
import streamlit.components.v1 as components
from streamlit_extras.colored_header import colored_header

def data_importer_ui():
is_local = st.checkbox("Use HTTP", value=False, help="Select Use HTTP if connecting with a local Neo4j instance.")
Expand Down
17 changes: 13 additions & 4 deletions graph_data_generator_streamlit/ui/ideate_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import random
import base64
import ast

# Yes yes - move all the non-ui stuff into a controller or something already

Expand Down Expand Up @@ -156,6 +157,7 @@ def triples_prompt(prompt: str)-> str:
Each relationship must have 3 items in the list.
Limit the number of relationships to 12.
Return only the data, do not explain.
Only return a list of 3 item lists.

For example, the prompt: `Alice is Bob's roommate` should return [["Alice", "roommate", "Bob"]]

Expand All @@ -177,12 +179,17 @@ def agraph_nodes_edges(response: str | list) -> tuple[list[Node], list[Edge]]:
Raises:
...
"""
logging.debug(f'Response recieved: {response}')
logging.debug(f'agraph_nodes_edges() response recieved: {response}')
# Response will be a list of 3 item tuples

# Convert to list of lists - if needed
if isinstance(response, str):
answers = json.loads(response)
try:
answers = json.loads(response)
except:
logging.debug(f'Unable to parse string to list with json.loads. Attempting ast...')
answers = ast.literal_eval(response)

elif isinstance(response, list):
answers = response
else:
Expand Down Expand Up @@ -220,8 +227,10 @@ def agraph_nodes_edges(response: str | list) -> tuple[list[Node], list[Edge]]:

@st.cache_data
def generate_openai_response(prompt)-> str:
# TODO: Make this configurable
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
# model="gpt-4",
messages=[{"role": "user", "content": prompt}]
)
# TODO: Validate reponse
Expand Down Expand Up @@ -255,7 +264,7 @@ def ideate_ui():
if st.button('Load Sample', key="graphgpt_sample"):
st.session_state["SAMPLE_PROMPT"] = sample_prompt

prompt = st.text_input("Prompt", value=st.session_state["SAMPLE_PROMPT"])
prompt = st.text_area("Prompt", value=st.session_state["SAMPLE_PROMPT"])
if prompt is None or prompt == "":
return

Expand All @@ -271,7 +280,7 @@ def ideate_ui():
nodes, edges = agraph_nodes_edges(response)

# Configure and display agraph
config = Config(width=800, height=400, directed=True)
config = Config(width=1000, height=400, directed=True)
if nodes is None:
return

Expand Down
1 change: 0 additions & 1 deletion graph_data_generator_streamlit/ui/instructions_ui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from streamlit_player import st_player
import streamlit as st

def instructions_ui():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mock-graph-data-generator-streamlit"
version = "0.7.0"
version = "0.7.1"
description = ""
authors = ["Jason Koo <jalakoo@gmail.com>"]
readme = "README.md"
Expand Down