File size: 5,046 Bytes
ae67bc1
 
 
 
 
3c30c07
ae67bc1
 
 
3c30c07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae67bc1
 
3c30c07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9411465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import streamlit as st
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2

# Set your Clarifai credentials and model details
PAT = 'bfdeb4029ef54d23a2e608b0aa4c00e4'
USER_ID = 'openai'

# Streamlit app
st.title("AI Integration App")

# Choose model type
model_type = st.radio("Select Model Type", ["GPT-4 Turbo", "GPT-4 Vision", "DALL-E", "Text-to-Speech"])

# Input text prompt from the user
raw_text = st.text_input("Enter a text prompt:", 'I love your product very much')

# Button to generate result
if st.button("Generate Result"):
    if model_type == "GPT-4 Turbo":
        # Connect to Clarifai API for GPT-4 Turbo
        channel = ClarifaiChannel.get_grpc_channel()
        stub = service_pb2_grpc.V2Stub(channel)
        metadata = (('authorization', 'Key ' + PAT),)
        userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id='chat-completion')
        
        # Make a request to Clarifai API for GPT-4 Turbo
        post_model_outputs_response = stub.PostModelOutputs(
            service_pb2.PostModelOutputsRequest(
                user_app_id=userDataObject,
                model_id='gpt-4-turbo',
                version_id='182136408b4b4002a920fd500839f2c8',
                inputs=[
                    resources_pb2.Input(
                        data=resources_pb2.Data(
                            text=resources_pb2.Text(
                                raw=raw_text
                            )
                        )
                    )
                ]
            ),
            metadata=metadata
        )
        
        # Display the generated result if the request is successful
        if post_model_outputs_response.status.code != status_code_pb2.SUCCESS:
            st.error(f"Clarifai API request failed: {post_model_outputs_response.status.description}")
        else:
            output = post_model_outputs_response.outputs[0].data.image.base64
            st.image(output, caption='Generated Image', use_column_width=True)

    elif model_type == "GPT-4 Vision":
        # Connect to Clarifai API for GPT-4 Vision
        # Replace the following lines with actual GPT-4 Vision logic
        st.warning("GPT-4 Vision integration code goes here.")
        
    elif model_type == "DALL-E":
        # Connect to Clarifai API for DALL-E
        # Replace the following lines with actual DALL-E logic
        st.warning("DALL-E integration code goes here.")
        
    elif model_type == "Text-to-Speech":
        # Connect to Clarifai API for Text-to-Speech
        # Replace the following lines with actual Text-to-Speech logic
        st.warning("Text-to-Speech integration code goes here.")

# Add the beautiful social media icon section
st.markdown("""
  <div align="center">
      <a href="https://github.com/pyresearch/pyresearch" style="text-decoration:none;">
        <img src="https://user-images.githubusercontent.com/34125851/226594737-c21e2dda-9cc6-42ef-b4e7-a685fea4a21d.png" width="2%" alt="" /></a>
      <img src="https://user-images.githubusercontent.com/34125851/226595799-160b0da3-c9e0-4562-8544-5f20460f7cc9.png" width="2%" alt="" />
        <a href="https://www.linkedin.com/company/pyresearch/" style="text-decoration:none;">
        <img src="https://user-images.githubusercontent.com/34125851/226596446-746ffdd0-a47e-4452-84e3-bf11ec2aa26a.png" width="2%" alt="" /></a>
      <img src="https://user-images.githubusercontent.com/34125851/226595799-160b0da3-c9e0-4562-8544-5f20460f7cc9.png" width="2%" alt="" />
      <a href="https://twitter.com/Noorkhokhar10" style="text-decoration:none;">
        <img src="https://user-images.githubusercontent.com/34125851/226599162-9b11194e-4998-440a-ba94-c8a5e1cdc676.png" width="2%" alt="" /></a>
      <img src="https://user-images.githubusercontent.com/34125851/226595799-160b0da3-c9e0-4562-8544-5f20460f7cc9.png" width="2%" alt="" />    
      <a href="https://www.youtube.com/@Pyresearch" style="text-decoration:none;">
        <img src="https://user-images.githubusercontent.com/34125851/226599904-7d5cc5c0-89d2-4d1e-891e-19bee1951744.png" width="2%" alt="" /></a>
      <img src="https://user-images.githubusercontent.com/34125851/226595799-160b0da3-c9e0-4562-8544-5f20460f7cc9.png" width="2%" alt="" />
      <a href="https://www.facebook.com/Pyresearch" style="text-decoration:none;">
        <img src="https://user-images.githubusercontent.com/34125851/226600380-a87a9142-e8e0-4ec9-bf2c-dd6e9da2f05a.png" width="2%" alt="" /></a>
      <img src="https://user-images.githubusercontent.com/34125851/226595799-160b0da3-c9e0-4562-8544-5f20460f7cc9.png" width="2%" alt="" />
      <a href="https://www.instagram.com/pyresearch/" style="text-decoration:none;">  
        <img src="https://user-images.githubusercontent.com/34125851/226601355-ffe0b597-9840-4e10-bbef-43d6c74b5a9e.png" width="2%" alt="" /></a>      
  </div>
  <hr>
""", unsafe_allow_html=True)