Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,12 @@ import base64
|
|
6 |
import cv2
|
7 |
from moviepy.editor import VideoFileClip
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Set API key and organization ID from environment variables
|
10 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
11 |
openai.organization = os.getenv('OPENAI_ORG_ID')
|
@@ -27,21 +33,10 @@ def process_text():
|
|
27 |
)
|
28 |
st.write("Assistant: " + completion.choices[0].message.content)
|
29 |
|
30 |
-
def process_text_old():
|
31 |
-
text_input = st.text_input("Enter your text:")
|
32 |
-
if text_input:
|
33 |
-
response = openai.Completion.create(
|
34 |
-
model=MODEL,
|
35 |
-
prompt=f"You are a helpful assistant. Help me with my math homework! {text_input}",
|
36 |
-
max_tokens=100,
|
37 |
-
temperature=0.5,
|
38 |
-
)
|
39 |
-
st.write("Assistant: " + response.choices[0].text.strip())
|
40 |
-
|
41 |
def process_image(image_input):
|
42 |
if image_input:
|
43 |
base64_image = base64.b64encode(image_input.read()).decode("utf-8")
|
44 |
-
response =
|
45 |
model=MODEL,
|
46 |
prompt=f"You are a helpful assistant that responds in Markdown. Help me with my math homework! What's the area of the triangle? [image: data:image/png;base64,{base64_image}]",
|
47 |
max_tokens=100,
|
|
|
6 |
import cv2
|
7 |
from moviepy.editor import VideoFileClip
|
8 |
|
9 |
+
# documentation
|
10 |
+
# 1. Cookbook: https://cookbook.openai.com/examples/gpt4o/introduction_to_gpt4o
|
11 |
+
# 2. Configure your Project and Orgs to limit/allow Models: https://platform.openai.com/settings/organization/general
|
12 |
+
# 3. Watch your Billing! https://platform.openai.com/settings/organization/billing/overview
|
13 |
+
|
14 |
+
|
15 |
# Set API key and organization ID from environment variables
|
16 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
17 |
openai.organization = os.getenv('OPENAI_ORG_ID')
|
|
|
33 |
)
|
34 |
st.write("Assistant: " + completion.choices[0].message.content)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
def process_image(image_input):
|
37 |
if image_input:
|
38 |
base64_image = base64.b64encode(image_input.read()).decode("utf-8")
|
39 |
+
response = client.chat.completions.create(
|
40 |
model=MODEL,
|
41 |
prompt=f"You are a helpful assistant that responds in Markdown. Help me with my math homework! What's the area of the triangle? [image: data:image/png;base64,{base64_image}]",
|
42 |
max_tokens=100,
|