Skip to content

Commit

Permalink
chore: update Hugging Face API token in .env.sample and handle missin…
Browse files Browse the repository at this point in the history
…g token in LLM class
  • Loading branch information
Khushiyant committed Apr 29, 2024
1 parent 7307e88 commit 29467f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
API_TOKEN = "YOUR_API_TOKEN"
HUGGINGFACE_TOKEN = "YOUR_API_TOKEN"
File renamed without changes.
2 changes: 2 additions & 0 deletions quasarpy/algorithm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def _generate_online(self, prompt: str, **kwargs) -> str:
token = os.getenv("HUGGINGFACE_TOKEN")
except KeyError:
self.logger.error("Hugging Face API token not found in the environment variables.")
with open(".env", "w") as f:
f.write("HUGGINGFACE_TOKEN=YOUR_API_TOKEN")
raise

client = huggingface_hub.InferenceClient(token=token)
Expand Down

0 comments on commit 29467f0

Please sign in to comment.