diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a9a238e..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -jsonlines -openai -numpy -langchain -requests -tiktoken -tqdm -nltk \ No newline at end of file diff --git a/web/api/chat.py b/web/api/chat.py index 23bf86f..13c9f81 100644 --- a/web/api/chat.py +++ b/web/api/chat.py @@ -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 \ No newline at end of file + return completion diff --git a/web/api/requirements.txt b/web/api/requirements.txt index bf95cbd..ce36a42 100644 --- a/web/api/requirements.txt +++ b/web/api/requirements.txt @@ -1,4 +1,4 @@ openai==0.27.2 numpy==1.24.2 tenacity==8.2.2 -# aiohttp==3.8.3 \ No newline at end of file +tiktoken diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index 581e57f..3754ca2 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -25,14 +25,7 @@ const ShowEntry: React.FC<{entry: Entry}> = ({entry}) => { const Home: NextPage = () => { - const [ entries, setEntries ] = useState([ - {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([]); const [ query, setQuery ] = useState(""); const [ loading, setLoading ] = useState(false); @@ -100,7 +93,6 @@ const Home: NextPage = () => { coordinate sharing the embeddings to avoid redundancy.

-

Chat with the friendly robot: