Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiaprodhan committed Apr 19, 2024
1 parent 1c71ef7 commit 8884ead
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions llm_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: openai==0.28 in /usr/local/lib/python3.10/dist-packages (0.28.0)\n",
"Requirement already satisfied: requests>=2.20 in /usr/local/lib/python3.10/dist-packages (from openai==0.28) (2.31.0)\n",
Expand Down Expand Up @@ -93,7 +93,7 @@
" self.driver = GraphDatabase.driver(url, auth=(user, password))\n",
" openai.api_key = openai_api_key\n",
" # time.sleep(60)\n",
" # construct schema\n",
" \n",
" self.schema = self.generate_schema()\n",
"\n",
"\n",
Expand Down Expand Up @@ -132,7 +132,7 @@
" {\"role\": \"system\", \"content\": self.get_system_message()},\n",
" {\"role\": \"user\", \"content\": question},\n",
" ]\n",
" # Used for Cypher healing flows\n",
" \n",
" if history:\n",
" messages.extend(history)\n",
" #time.sleep(60)\n",
Expand All @@ -159,7 +159,7 @@
" {\"role\": \"user\", \"content\": prompt + triples}\n",
" ]\n",
" response = openai.ChatCompletion.create(\n",
" model=\"gpt-4\", # Use an appropriate model\n",
" model=\"gpt-4\", \n",
" messages=messages,\n",
" temperature=0.0,\n",
" max_tokens=1000\n",
Expand All @@ -168,7 +168,7 @@
" return response.choices[0].message.content\n",
"\n",
" def run(self, question, history=None, retry=True):\n",
" # Construct Cypher statement\n",
" \n",
" time.sleep(60)\n",
" cypher = self.construct_cypher(question, history)\n",
" print(\"cypher generated by chatgpt\")\n",
Expand All @@ -188,13 +188,11 @@
" #print(\"ELSE- line number 114\")\n",
" print(response)\n",
" return response\n",
" # Self-healing flow\n",
" \n",
" except CypherSyntaxError as e:\n",
" # If out of retries\n",
" \n",
" if not retry:\n",
" return \"Invalid Cypher syntax\"\n",
" # Self-healing Cypher flow by\n",
" # providing specific error to GPT-4\n",
" print(\"Retrying\")\n",
" #time.sleep(60)\n",
" return self.run(\n",
Expand Down Expand Up @@ -223,7 +221,7 @@
" url=\"neo4j+s://b68740ea.databases.neo4j.io\",\n",
" user=\"neo4j\",\n",
" password=\"_lJbg6-mIWPdVXmtjTrAgcmBJFq7iHRJ8iHRBRDuDDc\",\n",
" openai_api_key=\"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\",\n",
" #openai_api_key=\"\",\n",
")\n"
]
},
Expand All @@ -240,8 +238,8 @@
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"output_type": "stream",
"text": [
"Please write your question: how many phases in cell cycle\n",
"cypher generated by chatgpt\n",
Expand Down Expand Up @@ -291,9 +289,9 @@
]
},
{
"output_type": "error",
"ename": "KeyboardInterrupt",
"evalue": "Interrupted by user",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
Expand Down Expand Up @@ -342,4 +340,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 8884ead

Please sign in to comment.