DHRUV SHEKHAWAT commited on
Commit
72ee1e9
·
1 Parent(s): 9206c2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -6,8 +6,6 @@ url = 'https://paidapi-proxy003-webraftai.run-us-west2.goorm.app/v1/chat/complet
6
  st.set_page_config(page_title="WebraftAI Chat", page_icon=":robot_face:")
7
  st.markdown("<h1 style='text-align: center;'>WebraftAI Chat</h1>", unsafe_allow_html=True)
8
 
9
-
10
-
11
  if 'generated' not in st.session_state:
12
  st.session_state['generated'] = []
13
  if 'past' not in st.session_state:
@@ -87,19 +85,20 @@ def evaluate(model, question, max_tokens=4096, top_p=0.7,temperature=0.1):
87
  sentence = response['choices'][0]['message']['content']
88
  else:
89
  sentie = response
90
- sentence = f"API Returned: ```{sentie}``` \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
91
 
92
 
93
  except requests.exceptions.JSONDecodeError as e:
94
  sentie= response.content
95
- sentence = f"API Returned: ```{sentie}``` \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
96
  return sentence
97
 
98
 
99
  def generate_response(prompt):
100
  st.session_state['messages'].append({"role": "user", "content": prompt})
 
101
  if prompt.startswith("draw"):
102
- data = {"prompt": prompt,
103
  "model": "realistic-vision-v1-4"
104
  }
105
 
@@ -111,12 +110,12 @@ def generate_response(prompt):
111
 
112
  response = response.json()
113
  imageurl = response['data'][0]['url']
114
- ie = f"Here is the generated image: {imageurl} \n Model used: `realistic-vision-v1-4`"
115
  st.session_state['messages'].append({"role": "assistant", "content": ie})
116
 
117
  except requests.exceptions.JSONDecodeError as e:
118
  sentie = response.content
119
- ie= f"Image generation API returned: ```{sentie}``` \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
120
  st.session_state['messages'].append({"role": "assistant", "content": ie})
121
  return ie,total_tokens,prompt_tokens,completion_tokens
122
 
 
6
  st.set_page_config(page_title="WebraftAI Chat", page_icon=":robot_face:")
7
  st.markdown("<h1 style='text-align: center;'>WebraftAI Chat</h1>", unsafe_allow_html=True)
8
 
 
 
9
  if 'generated' not in st.session_state:
10
  st.session_state['generated'] = []
11
  if 'past' not in st.session_state:
 
85
  sentence = response['choices'][0]['message']['content']
86
  else:
87
  sentie = response
88
+ sentence = f"API Returned: \n ```{sentie}``` \n \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
89
 
90
 
91
  except requests.exceptions.JSONDecodeError as e:
92
  sentie= response.content
93
+ sentence = f"API Returned:\n ```{sentie}``` \n \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
94
  return sentence
95
 
96
 
97
  def generate_response(prompt):
98
  st.session_state['messages'].append({"role": "user", "content": prompt})
99
+ prompt = prompt.lower()
100
  if prompt.startswith("draw"):
101
+ data = {"prompt": prompt.replace("draw",""),
102
  "model": "realistic-vision-v1-4"
103
  }
104
 
 
110
 
111
  response = response.json()
112
  imageurl = response['data'][0]['url']
113
+ ie = f"Here is the generated image:\n {imageurl} \n \n Model used: `realistic-vision-v1-4`"
114
  st.session_state['messages'].append({"role": "assistant", "content": ie})
115
 
116
  except requests.exceptions.JSONDecodeError as e:
117
  sentie = response.content
118
+ ie= f"Image generation API returned:\n ```{sentie}``` \n \n Is the API not working? check https://stats.uptimerobot.com/KkZE2T84mj \n If you are still encountering errors then please open a ticket from our discord server at https://discord.gg/webraftai . "
119
  st.session_state['messages'].append({"role": "assistant", "content": ie})
120
  return ie,total_tokens,prompt_tokens,completion_tokens
121