MoRa2001 commited on
Commit
dff2fa0
1 Parent(s): 21579d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -10,29 +10,34 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
10
  ## paramas
11
 
12
  def fit_text(text:str):
13
- ## prompts
14
- system_prompt = 'You are a smart input form for Dall-E model'
15
- user_prompt = f'''It receives the text from the user {text}, translates it into English,
16
- and reorganizes the text to make the Dall-E model understand it and use it easily to create a good image.
17
- '''
18
- ## messages
 
 
 
 
19
  messages = [
20
  {'role': 'system', 'content': system_prompt},
21
  {'role': 'user', 'content': user_prompt}
22
- ]
23
 
24
- ## Using ChatGPT for ChatCompletion
25
  response = openai.ChatCompletion.create(
26
  model='gpt-3.5-turbo',
27
  messages=messages,
28
  temperature=0.7,
29
  max_tokens=1000,
30
- )
31
 
32
  response = response['choices'][0]['message']['content']
33
 
34
  return response
35
 
 
36
  def generate_image(description:str):
37
  response = openai.Image.create(
38
  prompt=description, ## The description for the image
 
10
  ## paramas
11
 
12
  def fit_text(text:str):
13
+ ## Optimized system prompt
14
+ system_prompt = 'Generate an image based on the provided description.'
15
+
16
+ user_prompt = f'''Given the input text "{text}", please generate an image that embodies the following characteristics:
17
+ - Clear and detailed representation
18
+ - Relevant to the provided description
19
+ - Incorporating key elements and context
20
+ - Creative and visually appealing'''
21
+
22
+ ## Messages
23
  messages = [
24
  {'role': 'system', 'content': system_prompt},
25
  {'role': 'user', 'content': user_prompt}
26
+ ]
27
 
28
+ ## Using ChatGPT for Chat Completion
29
  response = openai.ChatCompletion.create(
30
  model='gpt-3.5-turbo',
31
  messages=messages,
32
  temperature=0.7,
33
  max_tokens=1000,
34
+ )
35
 
36
  response = response['choices'][0]['message']['content']
37
 
38
  return response
39
 
40
+
41
  def generate_image(description:str):
42
  response = openai.Image.create(
43
  prompt=description, ## The description for the image