prabinpanta0 commited on
Commit
07b8c67
1 Parent(s): 2e16305

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -65
app.py DELETED
@@ -1,65 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from transformers import pipeline
4
- from huggingface_hub import login
5
-
6
- # Get the Hugging Face token from environment variables
7
- HF_TOKEN = os.getenv('HF')
8
-
9
- if not HF_TOKEN:
10
- raise ValueError("The HF environment variable is not set. Please set it to your Hugging Face token.")
11
-
12
- # Authenticate with Hugging Face and save the token to the Git credentials helper
13
- login(HF_TOKEN, add_to_git_credential=True)
14
-
15
- # Create the pipeline for text generation using the specified model
16
- pipe = pipeline("text-generation", model="distilbert/distilgpt2", token=HF_TOKEN)
17
-
18
- # Define the initial prompt for the system
19
- system_prompt = """
20
- You are an AI model designed to provide concise information about big data analytics across various fields without mentioning the question. Respond with a focused, one-line answer that captures the essence of the key risk, benefit, or trend associated with the topic.
21
-
22
- input: What do you consider the most significant risk of over-reliance on big data analytics in stock market risk management?
23
- output: Increased market volatility.
24
-
25
- input: What is a major benefit of big data analytics in healthcare?
26
- output: Enhanced patient care through personalized treatment.
27
-
28
- input: What is a key challenge of big data analytics in retail?
29
- output: Maintaining data privacy and security.
30
-
31
- input: What is a primary advantage of big data analytics in manufacturing?
32
- output: Improved production efficiency and predictive maintenance.
33
-
34
- input: What is a significant risk associated with big data analytics in education?
35
- output: Potential widening of the achievement gap if data is not used equitably.
36
- """
37
-
38
- def generate(text):
39
- try:
40
- # Combine the system prompt with the user's input
41
- prompt = system_prompt + f"\ninput: {text}\noutput:"
42
-
43
- # Generate the response using the pipeline
44
- responses = pipe(prompt, max_length=1024, num_return_sequences=1)
45
- response_text = responses[0]['generated_text'].split("output:")[-1].strip()
46
-
47
- return response_text if response_text else "No valid response generated."
48
-
49
- except Exception as e:
50
- return str(e)
51
-
52
- iface = gr.Interface(
53
- fn=generate,
54
- inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
55
- outputs="text",
56
- title="Big Data Analytics Assistant",
57
- description="Provides concise information about big data analytics across various fields.",
58
- live=False
59
- )
60
-
61
- def launch_custom_interface():
62
- iface.launch()
63
-
64
- if __name__ == "__main__":
65
- launch_custom_interface()