File size: 1,293 Bytes
cbbb853 5b6c885 cbbb853 5b6c885 432f311 5b6c885 e3283b1 5b6c885 e3283b1 5b6c885 e3283b1 5b6c885 e3283b1 5b6c885 e3283b1 5b6c885 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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.") |