Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,53 @@
|
|
1 |
import gradio as gr
|
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 |
-
# Set up Gradio interface
|
35 |
-
with gr.Blocks() as demo:
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
|
43 |
-
# Launch the interface
|
44 |
-
if __name__ == "__main__":
|
45 |
-
|
46 |
|
47 |
|
48 |
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
gr.load("models/mistralai/Mistral-7B-v0.1").launch()
|
4 |
+
|
5 |
+
|
6 |
+
# import gradio as gr
|
7 |
+
# from transformers import AutoModelForCausalLM, AutoTokenizer
|
8 |
+
# import torch
|
9 |
+
# import os
|
10 |
+
|
11 |
+
# # Get the Hugging Face token from environment variables
|
12 |
+
# hf_token = os.getenv("API_KEY")
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
# # Load model and tokenizer
|
17 |
+
# model_name = "mistralai/Mistral-7B-v0.1"
|
18 |
+
# model = AutoModelForCausalLM.from_pretrained(
|
19 |
+
# model_name,
|
20 |
+
# device_map="auto",
|
21 |
+
# use_auth_token=hf_token
|
22 |
+
# )
|
23 |
+
# tokenizer = AutoTokenizer.from_pretrained(
|
24 |
+
# model_name,
|
25 |
+
# use_auth_token=hf_token
|
26 |
+
# )
|
27 |
+
|
28 |
+
# # Define the generation function
|
29 |
+
# def generate_response(prompt):
|
30 |
+
# # Tokenize input text
|
31 |
+
# inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
32 |
+
|
33 |
+
# # Generate response
|
34 |
+
# generated_ids = model.generate(**inputs, max_new_tokens=100, do_sample=True)
|
35 |
|
36 |
+
# # Decode and return response
|
37 |
+
# return tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
38 |
|
39 |
+
# # Set up Gradio interface
|
40 |
+
# with gr.Blocks() as demo:
|
41 |
+
# gr.Markdown("# Text Generation")
|
42 |
+
# input_text = gr.Textbox(placeholder="Enter your input here", lines=2)
|
43 |
+
# output_text = gr.Textbox(label="Generated Output", lines=2)
|
44 |
+
# submit_btn = gr.Button("Generate")
|
45 |
|
46 |
+
# submit_btn.click(generate_response, inputs=input_text, outputs=output_text)
|
47 |
|
48 |
+
# # Launch the interface
|
49 |
+
# if __name__ == "__main__":
|
50 |
+
# demo.launch()
|
51 |
|
52 |
|
53 |
|