N.Achyuth Reddy commited on
Commit
d06f4eb
·
1 Parent(s): e027992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -25
app.py CHANGED
@@ -4,28 +4,7 @@ from st_audiorec import st_audiorec
4
  from gtts import gTTS
5
  import os
6
 
7
- # Initialize response variable
8
- response = ""
9
-
10
- # Prediction function
11
- def predict(message, system_prompt='Your name is OpenGPT. You are developed by Achyuth. You need to mostly focus on giving information about future agriculture and advanced farming. Empower yourself farming future with cutting-edge technology and sustainable practices. You need to cultivate a greener and more productive. Your developer is studying in The Hyderabad Public School Kadapa.', temperature=0.7, max_new_tokens=4096, Topp=0.5, Repetitionpenalty=1.2):
12
- with st.status("Starting client"):
13
- client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
14
- st.write("Requesting Audio Transcriber")
15
- with st.status("Requesting AgriTure v1"):
16
- st.write("Requesting API")
17
- response = client.predict(
18
- message,
19
- system_prompt,
20
- max_new_tokens,
21
- temperature,
22
- Topp,
23
- 500,
24
- Repetitionpenalty,
25
- api_name="/chat"
26
- )
27
- st.write("Done")
28
- return response
29
 
30
  # Function to convert text to speech
31
  def text_to_speech(text, language='en', filename='output.mp3'):
@@ -38,10 +17,8 @@ def text_to_speech(text, language='en', filename='output.mp3'):
38
  # Play the audio file
39
  os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
40
 
41
- # Streamlit UI
42
  # ... (previous code remains unchanged)
43
- textinput = st.text_input("Ask AgriTure anything...")
44
-
45
  # React to user input
46
  if prompt := textinput:
47
  # Display user message in chat message container
 
4
  from gtts import gTTS
5
  import os
6
 
7
+ # ... (previous code remains unchanged)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Function to convert text to speech
10
  def text_to_speech(text, language='en', filename='output.mp3'):
 
17
  # Play the audio file
18
  os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
19
 
 
20
  # ... (previous code remains unchanged)
21
+
 
22
  # React to user input
23
  if prompt := textinput:
24
  # Display user message in chat message container