awacke1 commited on
Commit
d54eb71
1 Parent(s): 19b3cb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -8,11 +8,24 @@ from moviepy.editor import VideoFileClip
8
  # Set API key and organization ID from environment variables
9
  openai.api_key = os.getenv('OPENAI_API_KEY')
10
  openai.organization = os.getenv('OPENAI_ORG_ID')
 
11
 
12
  # Define the model to be used
13
  MODEL = "gpt-4o"
14
 
15
  def process_text():
 
 
 
 
 
 
 
 
 
 
 
 
16
  text_input = st.text_input("Enter your text:")
17
  if text_input:
18
  response = openai.Completion.create(
 
8
  # Set API key and organization ID from environment variables
9
  openai.api_key = os.getenv('OPENAI_API_KEY')
10
  openai.organization = os.getenv('OPENAI_ORG_ID')
11
+ client = OpenAI(api_key= os.getenv('OPENAI_API_KEY'))
12
 
13
  # Define the model to be used
14
  MODEL = "gpt-4o"
15
 
16
  def process_text():
17
+ text_input = st.text_input("Enter your text:")
18
+ if text_input:
19
+ completion = client.chat.completions.create(
20
+ model=MODEL,
21
+ messages=[
22
+ {"role": "system", "content": "You are a helpful assistant. Help me with my math homework!"},
23
+ {"role": "user", "content": f"Hello! Could you solve {text_input}?"}
24
+ ]
25
+ )
26
+ st.write("Assistant: " + completion.choices[0].message.content)
27
+
28
+ def process_text_old():
29
  text_input = st.text_input("Enter your text:")
30
  if text_input:
31
  response = openai.Completion.create(