Spaces:
Running
Running
Update GPT4KG.py
Browse files
GPT4KG.py
CHANGED
@@ -5,6 +5,7 @@ import numpy as np
|
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import torch
|
7 |
import openai
|
|
|
8 |
from PIL import Image
|
9 |
|
10 |
system_text = """You are an expert AI that extracts knowledge graphs from text and outputs JSON files with the extracted knowledge, and nothing more. Here's how the JSON is broken down.
|
@@ -110,7 +111,7 @@ class KnowledgeGraph:
|
|
110 |
except:
|
111 |
pass
|
112 |
messages.append({"role":"user","content":text})
|
113 |
-
output = openai.ChatCompletion.create(model="gpt-4",messages=messages)["choices"][0]["message"].to_dict()["content"]
|
114 |
return output
|
115 |
|
116 |
def learn(self,text,show_output=False):
|
|
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import torch
|
7 |
import openai
|
8 |
+
from openai import OpenAI
|
9 |
from PIL import Image
|
10 |
|
11 |
system_text = """You are an expert AI that extracts knowledge graphs from text and outputs JSON files with the extracted knowledge, and nothing more. Here's how the JSON is broken down.
|
|
|
111 |
except:
|
112 |
pass
|
113 |
messages.append({"role":"user","content":text})
|
114 |
+
output = openai.ChatCompletion.create(model="gpt-4-1106-preview",messages=messages)["choices"][0]["message"].to_dict()["content"]
|
115 |
return output
|
116 |
|
117 |
def learn(self,text,show_output=False):
|