DenverJones commited on
Commit
bf8ef9d
·
verified ·
1 Parent(s): f2aa8b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,6 +1,7 @@
 
1
  from huggingface_hub import InferenceClient
2
 
3
- # Instantiate InferenceClient without 'repo_id'
4
  client = InferenceClient()
5
 
6
  @tool
@@ -13,11 +14,11 @@ def generate_image(description: str) -> str:
13
  str: A URL to the generated image.
14
  """
15
  try:
16
- # Specify the model explicitly when making the call
17
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
18
  result = client.text_to_image(model=model_id, prompt=description)
19
 
20
- # Assuming the result contains a 'url' field
21
  if 'url' in result[0]:
22
  return f"Here's your generated image: {result[0]['url']}"
23
  else:
 
1
+ from smolagents import tool # Ensure 'tool' is imported from smolagents
2
  from huggingface_hub import InferenceClient
3
 
4
+ # Initialize the InferenceClient
5
  client = InferenceClient()
6
 
7
  @tool
 
14
  str: A URL to the generated image.
15
  """
16
  try:
17
+ # Replace with the correct model
18
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
19
  result = client.text_to_image(model=model_id, prompt=description)
20
 
21
+ # Check if 'url' is in the result and return it
22
  if 'url' in result[0]:
23
  return f"Here's your generated image: {result[0]['url']}"
24
  else: