KingNish commited on
Commit
2a461e6
1 Parent(s): 6877ba2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -109,7 +109,7 @@ def respond(message, history):
109
  functions_metadata = [
110
  {"type": "function", "function": {"name": "web_search", "description": "Search query on google", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "web search query"}}, "required": ["query"]}}},
111
  {"type": "function", "function": {"name": "general_query", "description": "Reply general query of USER", "parameters": {"type": "object", "properties": {"prompt": {"type": "string", "description": "A detailed prompt"}}, "required": ["prompt"]}}},
112
- {"type": "function", "function": {"name": "image_generation", "description": "Generate image for user", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "image generation prompt"}, "number_of_image": {"type": "integer", "description": "number of images to generate"}}, "required": ["query"]}}},
113
  {"type": "function", "function": {"name": "image_qna", "description": "Answer question asked by user related to image", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "Question by user"}}, "required": ["query"]}}},
114
  ]
115
 
@@ -153,13 +153,16 @@ def respond(message, history):
153
  yield output
154
  elif json_data["name"] == "image_generation":
155
  query = json_data["arguments"]["query"]
 
 
156
  try:
157
- number_of_image = json_data["arguments"]["number_of_image"]
 
158
  except:
159
- number_of_image = 1
160
- gr.Info("Generating Image, Please wait 10 sec...")
161
- image = image_gen(f"{str(query)}")
162
- yield gr.Image(image[1])
163
  elif json_data["name"] == "image_qna":
164
  inputs = llava(message, history)
165
  streamer = TextIteratorStreamer(processor, skip_prompt=True, **{"skip_special_tokens": True})
 
109
  functions_metadata = [
110
  {"type": "function", "function": {"name": "web_search", "description": "Search query on google", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "web search query"}}, "required": ["query"]}}},
111
  {"type": "function", "function": {"name": "general_query", "description": "Reply general query of USER", "parameters": {"type": "object", "properties": {"prompt": {"type": "string", "description": "A detailed prompt"}}, "required": ["prompt"]}}},
112
+ {"type": "function", "function": {"name": "image_generation", "description": "Generate image for user", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "image generation prompt"}}, "required": ["query"]}}},
113
  {"type": "function", "function": {"name": "image_qna", "description": "Answer question asked by user related to image", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "Question by user"}}, "required": ["query"]}}},
114
  ]
115
 
 
153
  yield output
154
  elif json_data["name"] == "image_generation":
155
  query = json_data["arguments"]["query"]
156
+ gr.Info("Generating Image, Please wait 10 sec...")
157
+ yield "Generating Image, Please wait 10 sec..."
158
  try:
159
+ image = image_gen(f"{str(query)}")
160
+ yield gr.Image(image[1])
161
  except:
162
+ client_sd3 = InferenceClient("stabilityai/stable-diffusion-3-medium-diffusers")
163
+ seed = random.randint(0,999999)
164
+ image = client_sd3.text_to_image(query, negative_prompt=f"{seed}")
165
+ yield gr.Image(image)
166
  elif json_data["name"] == "image_qna":
167
  inputs = llava(message, history)
168
  streamer = TextIteratorStreamer(processor, skip_prompt=True, **{"skip_special_tokens": True})