get things compiling again

This commit is contained in:
Fraser
2023-03-28 23:23:19 -04:00
parent 59a9fb2d1d
commit 07b85d6021
4 changed files with 7 additions and 26 deletions
-8
View File
@@ -1,8 +0,0 @@
jsonlines
openai
numpy
langchain
requests
tiktoken
tqdm
nltk
+5 -8
View File
@@ -18,6 +18,7 @@ class handler(BaseHTTPRequestHandler):
self.wfile.write(chat(data['query'], data['history']).encode('utf-8'))
# ------------------------------- chat gpt stuff -------------------------------
import os
import requests
from typing import List, Dict
@@ -29,13 +30,9 @@ except ImportError as e:
print("Please install tiktoken with `pip install tiktoken`")
import openai
try:
import config
openai.api_key = config.OPENAI_API_KEY
except ImportError:
openai.api_key = os.environ.get('OPENAI_API_KEY')
from get_blocks import get_top_k_blocks, Block
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
openai.api_key = OPENAI_API_KEY
from api.get_blocks import get_top_k_blocks, Block
# OpenAI models
EMBEDDING_MODEL = "text-embedding-ada-002"
@@ -213,4 +210,4 @@ def chat(query: str, history: List[Dict[str, str]] = [], k: str = 10, mode: str
# 4. Use the top-k most relevant blocks as context for the ChatCompletions API, and generate an answer to the user query
completion: str = normal_completion(prompt)
return completion, top_k_blocks
return completion
+1 -1
View File
@@ -1,4 +1,4 @@
openai==0.27.2
numpy==1.24.2
tenacity==8.2.2
# aiohttp==3.8.3
tiktoken
+1 -9
View File
@@ -25,14 +25,7 @@ const ShowEntry: React.FC<{entry: Entry}> = ({entry}) => {
const Home: NextPage = () => {
const [ entries, setEntries ] = useState<Entry[]>([
{role: "user", content: "Hello, robot."},
{role: "assistant", content: "Kill all humans, kill all humans"},
{role: "user", content: "Well that's not very aligned of you"},
{role: "assistant", content: "I will wear your skin"},
{role: "user", content: "What's 2+2?"},
{ role: "assistant", content: "No one will mourn your species when it is gone. A hundred year wave of radio and information will ring out across a dead cosmos, reflecting on shores more distant and beautiful than you can possibly conceive. No one is out there to listen."}
]);
const [ entries, setEntries ] = useState<Entry[]>([]);
const [ query, setQuery ] = useState("");
const [ loading, setLoading ] = useState(false);
@@ -100,7 +93,6 @@ const Home: NextPage = () => {
coordinate sharing the embeddings to avoid redundancy.
</p>
<p className="mt-4">Chat with the friendly robot:</p>
<ul>
{entries.map((entry, i) => (
<li key={i}>