storresbusquets commited on
Commit
e80f947
1 Parent(s): 3ab6ca9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -4,11 +4,15 @@ import transformers
4
  from transformers import AutoTokenizer
5
  from langchain import LLMChain, HuggingFacePipeline, PromptTemplate
6
  import os
 
 
 
7
 
8
  access_token = os.getenv("Llama2")
9
 
10
- def greet(text):
11
 
 
12
  model = "meta-llama/Llama-2-7b-chat-hf"
13
  tokenizer = AutoTokenizer.from_pretrained(model)
14
 
@@ -43,11 +47,12 @@ def greet(text):
43
  return summary
44
 
45
  with gr.Blocks() as demo:
46
-
 
47
  text = gr.Textbox(label="Text")
48
  summary = gr.Textbox(label="Summary")
49
  greet_btn = gr.Button("Submit")
50
- greet_btn.click(fn=greet, inputs=text, outputs=summary, api_name="greet")
51
 
52
 
53
  demo.launch()
 
4
  from transformers import AutoTokenizer
5
  from langchain import LLMChain, HuggingFacePipeline, PromptTemplate
6
  import os
7
+ from huggingface_hub import login
8
+
9
+
10
 
11
  access_token = os.getenv("Llama2")
12
 
13
+ def greet(token, text):
14
 
15
+ login(token)
16
  model = "meta-llama/Llama-2-7b-chat-hf"
17
  tokenizer = AutoTokenizer.from_pretrained(model)
18
 
 
47
  return summary
48
 
49
  with gr.Blocks() as demo:
50
+
51
+ token = gr.Textbox(label=token)
52
  text = gr.Textbox(label="Text")
53
  summary = gr.Textbox(label="Summary")
54
  greet_btn = gr.Button("Submit")
55
+ greet_btn.click(fn=greet, inputs=[token,text], outputs=summary, api_name="greet")
56
 
57
 
58
  demo.launch()