pyresearch commited on
Commit
8f483ed
·
1 Parent(s): 84abd57

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -6,6 +6,8 @@ from clarifai_grpc.grpc.api.status import status_code_pb2
6
  # Set up the Streamlit app
7
  st.title("OpenAI Models Integration")
8
 
 
 
9
  # Display HTML content
10
  html_content = """
11
  <div align="center">
@@ -47,6 +49,10 @@ You can simply use pip to install the latest version of pyresearch.
47
 
48
  st.markdown(html_content, unsafe_allow_html=True)
49
 
 
 
 
 
50
  # Model selection
51
  model_option = st.selectbox("Select Model", ["GPT-4 Turbo", "GPT-4 Vision", "DALL-E API", "Text-to-Speech (TTS)"])
52
 
@@ -89,11 +95,14 @@ def make_api_request(model_id, model_version_id, raw_text):
89
  if model_option == "GPT-4 Turbo":
90
  model_id = 'gpt-4-turbo'
91
  model_version_id = '182136408b4b4002a920fd500839f2c8'
92
- raw_text = st.text_area("Enter text prompt:", 'I love your product very much')
93
  if st.button("Generate Text"):
94
  output_text = make_api_request(model_id, model_version_id, raw_text)
95
  st.write("Generated Text:", output_text)
96
 
 
 
 
97
  # GPT-4 Vision
98
  elif model_option == "GPT-4 Vision":
99
  model_id = 'gpt-4-vision-alternative'
@@ -101,6 +110,12 @@ elif model_option == "GPT-4 Vision":
101
  raw_text = st.text_area("Enter text prompt for vision:", 'A penguin watching the sunset.')
102
  if st.button("Generate Image (GPT-4 Vision)"):
103
  output_image = make_api_request(model_id, model_version_id, raw_text)
104
- st.image(output_image, caption='Generated Image', use_column_width=True)
105
 
106
- # D
 
 
 
 
 
 
 
 
6
  # Set up the Streamlit app
7
  st.title("OpenAI Models Integration")
8
 
9
+ # ... (previous code)
10
+
11
  # Display HTML content
12
  html_content = """
13
  <div align="center">
 
49
 
50
  st.markdown(html_content, unsafe_allow_html=True)
51
 
52
+ # Continue with the rest of the Streamlit app code...
53
+ # ... (as provided in the previous response)
54
+
55
+
56
  # Model selection
57
  model_option = st.selectbox("Select Model", ["GPT-4 Turbo", "GPT-4 Vision", "DALL-E API", "Text-to-Speech (TTS)"])
58
 
 
95
  if model_option == "GPT-4 Turbo":
96
  model_id = 'gpt-4-turbo'
97
  model_version_id = '182136408b4b4002a920fd500839f2c8'
98
+ raw_text = st.text_area("Enter text prompt:", 'I love your Pyresearch very much')
99
  if st.button("Generate Text"):
100
  output_text = make_api_request(model_id, model_version_id, raw_text)
101
  st.write("Generated Text:", output_text)
102
 
103
+ # GPT-4 Vision
104
+ # ... (previous code)
105
+
106
  # GPT-4 Vision
107
  elif model_option == "GPT-4 Vision":
108
  model_id = 'gpt-4-vision-alternative'
 
110
  raw_text = st.text_area("Enter text prompt for vision:", 'A penguin watching the sunset.')
111
  if st.button("Generate Image (GPT-4 Vision)"):
112
  output_image = make_api_request(model_id, model_version_id, raw_text)
 
113
 
114
+ try:
115
+ # Attempt to display the image
116
+ st.image(output_image, caption='Generated Image', use_column_width=True)
117
+ except Exception as e:
118
+ st.error(f"Error displaying image: {e}")
119
+
120
+ # ...
121
+