YADUUG commited on
Commit
f75d5b6
·
verified ·
1 Parent(s): 8389e46

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from huggingface_hub import InferenceClient
3
+
4
+ # Initialize the Hugging Face Inference Client
5
+ client = InferenceClient(
6
+ base_url="https://api-inference.huggingface.co/models/llama3-8b",
7
+ token="your_huggingface_api_token_here",
8
+ )
9
+
10
+ # Function to generate project tasks using LLaMA 3 8B
11
+ def generate_project_tasks(domain):
12
+ prompt = f"Create two simple project tasks for an internship in {domain}."
13
+ tasks = ""
14
+ for message in client.chat_completion(
15
+ messages=[{"role": "user", "content": prompt}],
16
+ max_tokens=500,
17
+ stream=True,
18
+ ):
19
+ tasks += message.choices[0].delta.content
20
+ return tasks
21
+
22
+ # Streamlit app layout
23
+ st.title("AI Internship Task Generator")
24
+ st.write("Enter the internship domain to generate two project tasks:")
25
+
26
+ # Input field for internship domain
27
+ domain = st.text_input("Internship Domain", "")
28
+
29
+ # Button to generate tasks
30
+ if st.button("Generate Tasks"):
31
+ if domain:
32
+ # Generate tasks and display them
33
+ tasks = generate_project_tasks(domain)
34
+ st.write("### Generated Project Tasks")
35
+ st.write(tasks)
36
+
37
+ # Save tasks to a text file
38
+ file_name = f"{domain}_project_tasks.txt"
39
+ with open(file_name, "w") as file:
40
+ file.write(tasks)
41
+
42
+ st.write(f"Tasks have been saved to {file_name}.")
43
+
44
+ else:
45
+ st.error("Please enter a domain.")
46
+