Davide Fiocco commited on
Commit
d293ad6
1 Parent(s): 1894fdf

Update streamlit and openai libraries

Browse files
Files changed (2) hide show
  1. app.py +9 -9
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,25 +1,25 @@
1
  import streamlit as st
2
- import openai
3
 
4
  st.title("Summarize text with OpenAI's API")
5
- st.write("Summarize text by using OpenAI's beta")
6
 
7
  key = st.secrets["api-key"]
 
 
 
 
8
  temperature = st.slider("Temperature:", min_value = 0.0, max_value = 0.3, step = 0.05)
9
  prompt = st.text_area("Insert text to summarize:")
10
 
11
  if (key and prompt):
12
- openai.api_key = key
13
 
14
- result = openai.Completion.create(
15
- engine ="davinci",
16
  prompt= f"{prompt} \n\n tl;dr ",
17
  temperature=temperature,
18
- max_tokens=20,
19
  top_p=1.0,
20
  frequency_penalty=0.0,
21
- presence_penalty=0.0
22
- )
23
 
24
  st.write("Summary:")
25
- st.write(result["choices"][0]["text"])
 
1
  import streamlit as st
2
+ from openai import OpenAI
3
 
4
  st.title("Summarize text with OpenAI's API")
 
5
 
6
  key = st.secrets["api-key"]
7
+ client = OpenAI(api_key=key)
8
+
9
+ st.write("Summarize text by using OpenAI's API")
10
+
11
  temperature = st.slider("Temperature:", min_value = 0.0, max_value = 0.3, step = 0.05)
12
  prompt = st.text_area("Insert text to summarize:")
13
 
14
  if (key and prompt):
 
15
 
16
+ result = client.completions.create(model="gpt-3.5-turbo-instruct",
 
17
  prompt= f"{prompt} \n\n tl;dr ",
18
  temperature=temperature,
19
+ max_tokens=200,
20
  top_p=1.0,
21
  frequency_penalty=0.0,
22
+ presence_penalty=0.0)
 
23
 
24
  st.write("Summary:")
25
+ st.write(result.choices[0].text)
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- openai
 
 
1
+ openai==1.11.1
2
+ streamlit==1.31.0