Spaces:
Running
Running
File size: 1,433 Bytes
8437892 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | from pathlib import Path
path = Path("app/generation/providers/huggingface_provider.py")
text = path.read_text(encoding="utf-8")
old = ''' if api_mode == "chat":
answer = self.call_chat_completion_api(prompt)
if answer:
return clean_hosted_output(answer)
answer = self.call_hf_inference_model_api(prompt)
if answer:
return clean_hosted_output(answer)
return ""
if api_mode == "inference":
answer = self.call_hf_inference_model_api(prompt)
if answer:
return clean_hosted_output(answer)
answer = self.call_chat_completion_api(prompt)
if answer:
return clean_hosted_output(answer)
return ""
'''
new = ''' if api_mode == "chat":
answer = self.call_chat_completion_api(prompt)
if answer:
return clean_hosted_output(answer)
return ""
if api_mode == "inference":
answer = self.call_hf_inference_model_api(prompt)
if answer:
return clean_hosted_output(answer)
return ""
'''
if old not in text:
print("Could not find old fallback block. No change made.")
else:
text = text.replace(old, new)
path.write_text(text, encoding="utf-8")
print("Strict HF_API_MODE patch applied successfully.")
|