Spaces:
Runtime error
Runtime error
Update app.py
Browse files2 unmodified lines345678910118 unmodified lines20212223242526272829303132333419 unmodified lines545556575859602 unmodified linesfrom huggingface_hub import InferenceClientimport spaces # Mandatory import for Hugging Face ZeroGPU compiler# Initialize the client, fetching your HF_TOKEN secret securelyclient = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct",token=os.environ.get("HF_TOKEN"))8 unmodified linesdef dummy_gpu_compiler_satisfier():return "ZeroGPU check passed"# 2. History assembly and API request execution running on CPUdef generate_php_code(message, history):# Ensure the dummy decorator compiles correctly on ZeroGPUtry:dummy_gpu_compiler_satisfier()except Exception:pass# Double-check that the Space successfully picked up your environment tokentoken = os.environ.get("HF_TOKEN")if not token:return "Error: HF_TOKEN is missing. Please add it to your Space's 'Settings -> Variables and secrets' as a secret."19 unmodified linesmessages.append({"role": "user", "content": message})try:# Request final code generationcompletion = client.chat_completion(messages,max_tokens=2048,2 unmodified lines345678910118 unmodified lines202122232425262728293031323319 unmodified lines5354555657582 unmodified linesfrom huggingface_hub import InferenceClientimport spaces # Mandatory import for Hugging Face ZeroGPU compiler# We use the natively-hosted 7B model to bypass third-party routing errors completelyclient = InferenceClient("Qwen/Qwen2.5-Coder-7B-Instruct",token=os.environ.get("HF_TOKEN"))8 unmodified linesdef dummy_gpu_compiler_satisfier():return "ZeroGPU check passed"# 2. History assembly and API execution running on CPUdef generate_php_code(message, history):# Keep the ZeroGPU compiler happytry:dummy_gpu_compiler_satisfier()except Exception:passtoken = os.environ.get("HF_TOKEN")if not token:return "Error: HF_TOKEN is missing. Please add it to your Space's 'Settings -> Variables and secrets' as a secret."19 unmodified linesmessages.append({"role": "user", "content": message})try:completion = client.chat_completion(messages,max_tokens=2048,
app.py+4-6