test / app.py
Nuthanon's picture
Update app.py
5b6c885 verified
raw
history blame
1.29 kB
import streamlit as st
import openai
import os
# Set your OpenAI API key here or set it as an environment variable
openai.api_key = os.getenv("OPENAI_API_KEY", "sk-None-RVvMry6BpMfG8KxYS6hTT3BlbkFJSOfj2bCwA1EmTRrAHo5y")
# Function to classify lines using GPT-3
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:")
# Text area for large text input
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.")