Spaces:
Sleeping
Sleeping
Update app.py
Browse files11 unmodified lines1213141516171824 unmodified lines434445464748495051525354555657585960616211 unmodified linesraise ValueError("Hugging Face API key not found. Please set the 'APIHUGGING' secret.")# Initialize Hugging Face Inference Clientclient = InferenceClient(api_key=API_KEY)# Function to extract text from various file typesdef extract_file_content(file_path):24 unmodified lines# Extract content from the uploaded filefile_content = extract_file_content(file)# Prepare conversation historymessages = [{"role": "user", "content": f"{prompt}\n\nFile Content:\n{file_content}"}]# Call Hugging Face APIbot_response = client.chat_completions.create(model="Qwen/Qwen2.5-Coder-32B-Instruct",messages=messages,max_tokens=500)# Collect and return the bot's responsereturn bot_response.choices[0].message.contentexcept Exception as e:return f"Error: {str(e)}"11 unmodified lines1213141516171824 unmodified lines4344454647484950515253545511 unmodified linesraise ValueError("Hugging Face API key not found. Please set the 'APIHUGGING' secret.")# Initialize Hugging Face Inference Clientclient = InferenceClient(api_token=API_KEY, model="Qwen/Qwen2.5-Coder-32B-Instruct")# Function to extract text from various file typesdef extract_file_content(file_path):24 unmodified lines# Extract content from the uploaded filefile_content = extract_file_content(file)# Prepare input for the modelinput_text = f"{prompt}\n\nFile Content:\n{file_content}"# Call Hugging Face API for text completionresponse = client.text_generation(input=input_text, max_new_tokens=50000)return responseexcept Exception as e:return f"Error: {str(e)}"
app.py+6-13