diff --git a/streamlit_app.py b/streamlit_app.py index 7a0ed1272052..852cbbd3200f 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -2,39 +2,33 @@ import numpy as np import pandas as pd import streamlit as st +from py2neo import Graph +import openai -""" -# Welcome to Streamlit! +# Connect to the Neo4j database +graph = Graph("bolt://localhost:7687", auth=("neo4j", "password")) -Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:. -If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community -forums](https://discuss.streamlit.io). +# Set your OpenAI API key +openai.api_key = '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' -In the meantime, below is an example of what you can do with just a few lines of code: -""" +# Create a Streamlit interface to input a natural language query +natural_language_query = st.text_input('Enter your natural language query here') -num_points = st.slider("Number of points in spiral", 1, 10000, 1100) -num_turns = st.slider("Number of turns in spiral", 1, 300, 31) +if natural_language_query: + # Use OpenAI's API to generate a Cypher query from the natural language query + response = openai.ChatCompletion.create( + model="gpt-3.5-turbo", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": natural_language_query} + ] + ) + cypher_query = response['choices'][0]['message']['content'] -indices = np.linspace(0, 1, num_points) -theta = 2 * np.pi * num_turns * indices -radius = indices + st.write(cyper_query) -x = radius * np.cos(theta) -y = radius * np.sin(theta) + # Execute the Cypher query against the Neo4j database + #results = graph.run(cypher_query).data() -df = pd.DataFrame({ - "x": x, - "y": y, - "idx": indices, - "rand": np.random.randn(num_points), -}) - -st.altair_chart(alt.Chart(df, height=700, width=700) - .mark_point(filled=True) - .encode( - x=alt.X("x", axis=None), - y=alt.Y("y", axis=None), - color=alt.Color("idx", legend=None, scale=alt.Scale()), - size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])), - )) + # Display the results in the Streamlit app + #st.write(results) \ No newline at end of file