|
import streamlit as st |
|
import openai |
|
import os |
|
|
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY", "sk-None-RVvMry6BpMfG8KxYS6hTT3BlbkFJSOfj2bCwA1EmTRrAHo5y") |
|
|
|
|
|
def classify_lines_with_gpt3(text): |
|
response = openai.Completion.create( |
|
engine="text-davinci-003", |
|
prompt=f"Classify the following Finnish contract specifications into categories: Urakka sisältää: Urakka ei sisältää: Tilaajan velvoitteet:Käytäntöjen tarkennukset:Hintojen tarkennukset: Muu:.\n\n{text}\n\n", |
|
max_tokens=1024, |
|
n=1, |
|
stop=None, |
|
temperature=0.5, |
|
) |
|
|
|
classified_text = response.choices[0].text.strip() |
|
return classified_text |
|
|
|
st.title("Finnish Contract Specifications Categorizer with GPT-3") |
|
|
|
st.write("Enter the contract specifications in Finnish:") |
|
|
|
|
|
contract_text = st.text_area("Contract Specifications (Finnish):", height=300) |
|
|
|
if st.button("Classify"): |
|
if contract_text: |
|
classified_text = classify_lines_with_gpt3(contract_text) |
|
|
|
st.write("Classified Contract Specifications:") |
|
st.write(classified_text) |
|
else: |
|
st.write("Please enter the contract specifications.") |