File size: 2,939 Bytes
efa79a1
 
 
 
 
 
 
 
 
 
 
 
 
 
cd88fd2
 
 
 
 
efa79a1
 
 
 
 
 
cd88fd2
 
 
 
efa79a1
 
 
 
50bbdce
 
 
efa79a1
 
 
52b9d25
 
efa79a1
4998ab5
efa79a1
 
fbced17
efa79a1
cd88fd2
efa79a1
 
 
 
cd88fd2
1bc30dd
cd88fd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4998ab5
7ac241b
 
 
 
 
 
cd88fd2
7ac241b
 
 
 
 
 
 
 
 
 
 
 
8778279
7ac241b
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
93
94
95
96
import streamlit as st
from langchain import OpenAI, PromptTemplate, LLMChain
from langchain.text_splitter import CharacterTextSplitter
from langchain.chains.mapreduce import MapReduceChain
from langchain.prompts import PromptTemplate
from langchain.chat_models import AzureChatOpenAI
from langchain.chains.summarize import load_summarize_chain
from langchain.chains import AnalyzeDocumentChain
from PyPDF2 import PdfReader
from langchain.document_loaders import TextLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.document_loaders import PyPDFLoader
import os
import openai
import requests
import time
import os
import urllib.request
from PIL import Image
import os


os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"

image_api_base = 'https://openaistudio255.openai.azure.com/'
image_api_key  =  os.environ["OPENAI_SECRETKEY"]


openai.api_type = "azure"
openai.api_base = "https://embeddinguseopenai.openai.azure.com/"
openai.api_version = "2023-03-15-preview"
openai.api_key = os.environ["OPENAI_API_KEY"]



 


image = Image.open('Wipro logo.png')
st.image(image)

st.title(" ideate sustainabile product designs with AI")


st.header("What is your idea? Type it here and the AI will co-design your concept")

yourquestion = st.text_input('Your topic', 'modern car design with solar panels on the top')
st.write('Your input is ', yourquestion)



if st.button("Visuvalize for ideas "):
    body = { "caption": yourquestion , "resolution": "512x512" }

    imageapi_version = '2022-08-03-preview'
    url = "{}dalle/text-to-image?api-version={}".format(image_api_base, imageapi_version)
    headers= { "api-key": image_api_key, "Content-Type": "application/json" }

    
    submission = requests.post(url, headers=headers, json=body)
    operation_location = submission.headers['Operation-Location']
    retry_after = submission.headers['Retry-after']
    status = ""

    while (status != "Succeeded"):
       time.sleep(int(retry_after))
       response = requests.get(operation_location, headers=headers)
       status = response.json()['status']
    image_url = response.json()['result']['contentUrl']
     
    st.image(image_url, width = 512)


if True==False:
    if st.button("Ask for ideas "):
        template = """
        You are an AI assistant. 
        {concept}
        """
    
        yourquestionideas = "List creative ideas of " + yourquestion
    
        response = openai.ChatCompletion.create(
          engine="gpt-35-turbo",
          messages = [{"role":"system","content":"You are an AI assistant that can come up with creative product ideas."},{"role":"user","content":yourquestionideas}],
          temperature=0.99,
          max_tokens=800,
          top_p=1,
          frequency_penalty=0,
          presence_penalty=0,
          stop=None)
    
        # Run the chain only specifying the input  .
        st.write(response)