Stanlito commited on
Commit
698a47e
·
verified ·
1 Parent(s): 47fa9fe

Upload 3 files

Browse files
Files changed (3) hide show
  1. .env +4 -0
  2. app.py +49 -0
  3. requirements.txt +3 -0
.env ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ELEVENLddABS_API_KEY = ""
2
+ OPENAI_API_KEY = "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"
3
+ TWILIO_ACCOUNT_SID = 'AC9bc4038b43c2abc63d16a0eec75a3a0b'
4
+ TWILIO_AUTH_TOKEN = '6008c28dd0ef8d47beed448d871cd68d'
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+ import streamlit as st
4
+ import openai
5
+
6
+
7
+ # Function to chat with GPT
8
+ def chat_with_gpt(prompt):
9
+ load_dotenv()
10
+ openai.api_key = os.getenv("OPENAI_API_KEY")
11
+
12
+ result = openai.chat.completions.create(
13
+ model="gpt-3.5-turbo",
14
+ messages=[
15
+ {
16
+ "role": "user",
17
+ "content": prompt
18
+ }
19
+ ]
20
+ )
21
+ return result.choices[0].message.content
22
+
23
+
24
+ # Streamlit UI
25
+ def main():
26
+ st.title("Generation and Analysis Tool with OpenAI")
27
+
28
+ # Add text input field
29
+ prompt = st.text_input("Please enter a question or request:")
30
+
31
+ # Interaction options
32
+ max_tokens = st.sidebar.slider("Max Tokens", min_value=10, max_value=200, value=50, step=10,
33
+ help="Maximum number of tokens to generate")
34
+ temperature = st.sidebar.slider("Temperature", min_value=0.1, max_value=1.0, value=0.5, step=0.1,
35
+ help="Controls the randomness of the generated text. Higher values make the text "
36
+ "more random.")
37
+
38
+ # Add a button to trigger the chat
39
+ if st.button("Enter"):
40
+ if prompt.strip() == '':
41
+ st.warning("Please enter a valid prompt.")
42
+ else:
43
+ response = chat_with_gpt(prompt)
44
+ st.success("Here's the response:")
45
+ st.write(response)
46
+
47
+
48
+ if __name__ == "__main__":
49
+ main()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit>=1.31.1
2
+ openai>=1.12.0
3
+ python-dotenv>=1.0.1