MuntasirHossain commited on
Commit
11fe09f
·
verified ·
1 Parent(s): 9f4675b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  import os
3
- api_token = os.getenv("HF_TOKEN")
 
 
4
 
5
  from langchain.llms.base import LLM
6
  from transformers import AutoTokenizer
@@ -21,14 +23,15 @@ from langchain_community.llms import HuggingFaceHub, HuggingFaceEndpoint
21
  import torch
22
 
23
 
24
- from langchain.llms.base import LLM
25
- from transformers import AutoTokenizer
26
- from huggingface_hub import HfApi
27
- import requests
28
-
29
  list_llm = ["meta-llama/Llama-3.1-8B-Instruct"] # , "HuggingFaceH4/zephyr-7b-beta"] # "mistralai/Mistral-7B-Instruct-v0.2" # meta-llama/Meta-Llama-3-8B-Instruct
30
  list_llm_simple = [os.path.basename(llm) for llm in list_llm]
31
 
 
 
 
 
 
 
32
  # class ZephyrLLM(LLM):
33
  # def __init__(self, repo_id, huggingfacehub_api_token, max_new_tokens=512, temperature=0.7, **kwargs):
34
  # super().__init__(**kwargs)
@@ -288,4 +291,5 @@ def demo():
288
 
289
 
290
  if __name__ == "__main__":
 
291
  demo()
 
1
  import gradio as gr
2
  import os
3
+ # api_token = os.getenv("HF_TOKEN")
4
+
5
+ from dotenv import load_dotenv
6
 
7
  from langchain.llms.base import LLM
8
  from transformers import AutoTokenizer
 
23
  import torch
24
 
25
 
 
 
 
 
 
26
  list_llm = ["meta-llama/Llama-3.1-8B-Instruct"] # , "HuggingFaceH4/zephyr-7b-beta"] # "mistralai/Mistral-7B-Instruct-v0.2" # meta-llama/Meta-Llama-3-8B-Instruct
27
  list_llm_simple = [os.path.basename(llm) for llm in list_llm]
28
 
29
+ def retrieve_api():
30
+ """Retrieve HuggingFace API Key"""
31
+ _ = load_dotenv()
32
+ global huggingfacehub_api_token
33
+ api_token = os.environ.get("HUGGINGFACE_API_KEY")
34
+
35
  # class ZephyrLLM(LLM):
36
  # def __init__(self, repo_id, huggingfacehub_api_token, max_new_tokens=512, temperature=0.7, **kwargs):
37
  # super().__init__(**kwargs)
 
291
 
292
 
293
  if __name__ == "__main__":
294
+ retrieve_api()
295
  demo()