Jofthomas HF staff commited on
Commit
f020752
·
1 Parent(s): 1b5ca84

Update TextGen/router.py

Browse files
Files changed (1) hide show
  1. TextGen/router.py +14 -12
TextGen/router.py CHANGED
@@ -10,7 +10,7 @@ from langchain.chains import LLMChain
10
  from langchain.prompts import PromptTemplate
11
  from TextGen.suno import custom_generate_audio, get_audio_information,generate_lyrics
12
  from TextGen.gemini import generate_story,place_objects,generate_map_markdown
13
- #from TextGen.diffusion import generate_image
14
  #from coqui import predict
15
  from langchain_google_genai import (
16
  ChatGoogleGenerativeAI,
@@ -56,7 +56,9 @@ class Message(BaseModel):
56
  npc: str | None = None
57
  messages: List[str] | None = None
58
  class ImageGen(BaseModel):
59
- prompt: str | None = None
 
 
60
  class VoiceMessage(BaseModel):
61
  npc: str | None = None
62
  input: str | None = None
@@ -321,15 +323,15 @@ async def generate_song():
321
  infos=get_audio_information(f"{data[0]['id']},{data[1]['id']}")
322
  return infos
323
 
324
- #@app.post('/generate_image')
325
- #def Imagen(image:ImageGen=None):
326
- # pil_image =generate_image(image.prompt)
327
- #
328
- #
329
- # # Convert the PIL Image to bytes
330
- # img_byte_arr = BytesIO()
331
- # pil_image.save(img_byte_arr, format='PNG')
332
- # img_byte_arr = img_byte_arr.getvalue()
333
  #
334
  # Return the image as a PNG response
335
- # return Response(content=img_byte_arr, media_type="image/png")
 
10
  from langchain.prompts import PromptTemplate
11
  from TextGen.suno import custom_generate_audio, get_audio_information,generate_lyrics
12
  from TextGen.gemini import generate_story,place_objects,generate_map_markdown
13
+ from TextGen.diffusion import generate_image
14
  #from coqui import predict
15
  from langchain_google_genai import (
16
  ChatGoogleGenerativeAI,
 
56
  npc: str | None = None
57
  messages: List[str] | None = None
58
  class ImageGen(BaseModel):
59
+ name:str
60
+ prompt: str
61
+
62
  class VoiceMessage(BaseModel):
63
  npc: str | None = None
64
  input: str | None = None
 
323
  infos=get_audio_information(f"{data[0]['id']},{data[1]['id']}")
324
  return infos
325
 
326
+ @app.post('/generate_image')
327
+ def Imagen(image:ImageGen=None):
328
+ pil_image =generate_image(image.prompt)
329
+
330
+
331
+ # Convert the PIL Image to bytes
332
+ img_byte_arr = BytesIO()
333
+ pil_image.save(img_byte_arr, format='PNG')
334
+ img_byte_arr = img_byte_arr.getvalue()
335
  #
336
  # Return the image as a PNG response
337
+ return Response(content=img_byte_arr, media_type="image/png")