From ba452b6ae187d515710f09cac125703e9ab17233 Mon Sep 17 00:00:00 2001 From: Simon Bohnen Date: Sun, 18 Apr 2021 01:44:44 +0200 Subject: [PATCH 1/7] curie for completion again --- backend/gptapi.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/backend/gptapi.py b/backend/gptapi.py index ecdd4f1..ff7559d 100644 --- a/backend/gptapi.py +++ b/backend/gptapi.py @@ -17,7 +17,7 @@ header_contenttype = "application/json" search_model = "ada" -completion_model = "davinci" +completion_model = "curie" examples_context = """6.6.1.3 Decent Working Time @@ -65,8 +65,6 @@ def get_answer(question: str, paragraphs: List[str]): - # question = "Is a payment under duress deemed an act of corruption?" - response = requests.post( answers_url, headers={ @@ -86,3 +84,26 @@ def get_answer(question: str, paragraphs: List[str]): } ) return response.json()['answers'][0] + + +compl_model = "davinci" +completion_url = f"https://api.openai.com/v1/engines/{compl_model}/completions" + + +def get_completion(question: str): + response = requests.post( + completion_url, + headers={ + "Authorization": header_auth, + "Content-Type": header_contenttype + }, + json={ + "prompt": """ + What is the german legal warranty period? + """, + "max_tokens": 50, + "temperature": 0.1, + "n": 1, + } + ) + return response.json()['choices'][0]['text'] From e49b89796e1e1ab2489d5615478cefb91693bd18 Mon Sep 17 00:00:00 2001 From: avrecum Date: Sun, 18 Apr 2021 02:00:31 +0200 Subject: [PATCH 2/7] [backend] dockerfile for deployment --- backend/Dockerfile | 15 +++++++++++++++ backend/requirements.txt | 22 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..5a6dfc0 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,15 @@ +FROM python:latest + +RUN pip install --upgrade pip + +COPY . /usr/src/app + +RUN CFLAGS="-Wno-narrowing" pip install cld2-cffi +RUN pip install -r /usr/src/app/requirements.txt + +EXPOSE 5000 +WORKDIR /usr/src/app +CMD ["uvicorn", "index:app", "--host", "0.0.0.0" ,"--port", "5000", "--log-level", "info"] + + + diff --git a/backend/requirements.txt b/backend/requirements.txt index a47aae6..a602ded 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,9 +1,25 @@ +certifi==2020.12.5 +cffi==1.14.5 +chardet==4.0.0 +cld2-cffi==0.1.4 click==7.1.2 fastapi==0.63.0 h11==0.12.0 +idna==2.10 +joblib==1.0.1 +multi-rake==0.0.1 +nltk==3.6.1 +numpy==1.20.2 +openai==0.6.3 +pycparser==2.20 pydantic==1.8.1 +pyrsistent==0.17.3 +python-dotenv==0.17.0 +regex==2021.4.4 +requests==2.25.1 +six==1.15.0 starlette==0.13.6 +tqdm==4.60.0 typing-extensions==3.7.4.3 -uvicorn==0.13.4 -python-dotenv==0.17.0 -openai==0.6.3 \ No newline at end of file +urllib3==1.26.4 +uvicorn==0.13.4 \ No newline at end of file From ed3bcb7d4bf6d9596202a1a9f228585e261eec0b Mon Sep 17 00:00:00 2001 From: avrecum Date: Sun, 18 Apr 2021 02:18:03 +0200 Subject: [PATCH 3/7] merge --- backend/README.md | 7 ++ frontend/package.json | 4 + frontend/public/index.html | 10 +- frontend/src/App.css | 38 ------- frontend/src/App.tsx | 27 +++-- frontend/src/constants/apiEndpoints.ts | 2 +- frontend/src/index.tsx | 3 +- frontend/src/logo.svg | 7 -- frontend/yarn.lock | 148 ++++++++++++++++++++++++- 9 files changed, 187 insertions(+), 59 deletions(-) delete mode 100644 frontend/src/App.css delete mode 100644 frontend/src/logo.svg diff --git a/backend/README.md b/backend/README.md index 841489c..5cb0683 100644 --- a/backend/README.md +++ b/backend/README.md @@ -16,3 +16,10 @@ Start backend server (development): ``` uvicorn index:app --host 0.0.0.0 --port 5000 --log-level debug --reload ``` + +# Build and run dockerfile + +``` +docker build -t comprehendum . +docker run comprehendum (-d for detached mode) +``` diff --git a/frontend/package.json b/frontend/package.json index ee6a070..82a3b3b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ "react-scripts": "4.0.3", "semantic-ui-css": "^2.4.1", "semantic-ui-react": "^2.0.3", + "styled-components": "^5.2.3", "typescript": "^4.0.3", "web-vitals": "^0.2.4", "workbox-background-sync": "^5.1.3", @@ -54,5 +55,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "@types/styled-components": "^5.1.9" } } diff --git a/frontend/public/index.html b/frontend/public/index.html index 6a9f8c2..6dc40fb 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -5,8 +5,16 @@ - + + +