Spaces:
Sleeping
Sleeping
Commit ·
12d8c76
1
Parent(s): 8a33787
final
Browse files- inference.py +7 -1
- test_local.py +11 -0
inference.py
CHANGED
|
@@ -228,7 +228,13 @@ async def main() -> None:
|
|
| 228 |
# Use API_KEY as the API key — injected by the hackathon validator
|
| 229 |
client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY)
|
| 230 |
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
try:
|
| 233 |
for task_config in TASKS:
|
| 234 |
await run_task(client, env, task_config)
|
|
|
|
| 228 |
# Use API_KEY as the API key — injected by the hackathon validator
|
| 229 |
client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY)
|
| 230 |
|
| 231 |
+
if IMAGE_NAME:
|
| 232 |
+
env = await CsvCleanerEnv.from_docker_image(IMAGE_NAME)
|
| 233 |
+
else:
|
| 234 |
+
# Since uvicorn is already running on port 8000 inside the HF Space container, connect locally
|
| 235 |
+
env = CsvCleanerEnv(base_url="http://localhost:8000")
|
| 236 |
+
await env.connect()
|
| 237 |
+
|
| 238 |
try:
|
| 239 |
for task_config in TASKS:
|
| 240 |
await run_task(client, env, task_config)
|
test_local.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
from client import CsvCleanerEnv
|
| 3 |
+
|
| 4 |
+
async def main():
|
| 5 |
+
env = CsvCleanerEnv(base_url='http://localhost:8000')
|
| 6 |
+
await env.connect()
|
| 7 |
+
print('Connected!')
|
| 8 |
+
await env.close()
|
| 9 |
+
|
| 10 |
+
if __name__ == "__main__":
|
| 11 |
+
asyncio.run(main())
|