Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,31 +96,7 @@ temperature=0.5,
|
|
| 96 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
|
| 97 |
custom_role_conversions=None,
|
| 98 |
)
|
| 99 |
-
|
| 100 |
-
def image_generator(prompt: str) -> bytes:
|
| 101 |
-
"""Generate an image based on a text description.
|
| 102 |
-
Args:
|
| 103 |
-
prompt: Detailed description of the image you want to generate
|
| 104 |
-
Returns:
|
| 105 |
-
The image data as bytes that can be displayed
|
| 106 |
-
"""
|
| 107 |
-
import requests
|
| 108 |
-
|
| 109 |
-
API_URL = "https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5"
|
| 110 |
-
|
| 111 |
-
# Make API request without authentication headers
|
| 112 |
-
response = requests.post(
|
| 113 |
-
API_URL,
|
| 114 |
-
json={"inputs": prompt}
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
# Check if the request was successful
|
| 118 |
-
if response.status_code != 200:
|
| 119 |
-
raise Exception(f"Error generating image: {response.text}")
|
| 120 |
-
|
| 121 |
-
# Return the raw image bytes
|
| 122 |
-
return response.content
|
| 123 |
-
|
| 124 |
# Import tool from Hub
|
| 125 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 126 |
search_tool = DuckDuckGoSearchTool()
|
|
@@ -129,7 +105,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 129 |
|
| 130 |
agent = CodeAgent(
|
| 131 |
model=model,
|
| 132 |
-
tools=[final_answer,enhanced_translate,
|
| 133 |
max_steps=6,
|
| 134 |
verbosity_level=1,
|
| 135 |
grammar=None,
|
|
|
|
| 96 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
|
| 97 |
custom_role_conversions=None,
|
| 98 |
)
|
| 99 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# Import tool from Hub
|
| 101 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 102 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 105 |
|
| 106 |
agent = CodeAgent(
|
| 107 |
model=model,
|
| 108 |
+
tools=[final_answer,enhanced_translate,image_generation_tool,search_tool ], ## add your tools here (don't remove final answer)
|
| 109 |
max_steps=6,
|
| 110 |
verbosity_level=1,
|
| 111 |
grammar=None,
|