N.Achyuth Reddy commited on
Commit
f66e095
·
1 Parent(s): 1a9f9fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -36,27 +36,8 @@ def transcribe(wav_path):
36
  "transcribe", # str in 'Task' Radio component
37
  api_name="/predict"
38
  )
39
-
40
- # Prediction function
41
- 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):
42
- with st.status("Starting client"):
43
- client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
44
- st.write("Requesting Audio Transcriber")
45
- with st.status("Requesting AgriTure v1"):
46
- st.write("Requesting API")
47
- response = client.predict(
48
- message, # str in 'Message' Textbox component
49
- system_prompt, # str in 'Optional system prompt' Textbox component
50
- max_new_tokens, # int | float (numeric value between 0 and 4096)
51
- temperature, # int | float (numeric value between 0.0 and 1.0)
52
- Topp,
53
- 500,
54
- Repetitionpenalty, # int | float (numeric value between 1.0 and 2.0)
55
- api_name="/chat"
56
- )
57
- st.write("Done")
58
- return response
59
 
 
60
  # Streamlit UI
61
  st.title(TITLE)
62
  st.write(DESCRIPTION)
@@ -121,7 +102,14 @@ def text_to_speech(text, language='en', filename='output.mp3'):
121
  os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
122
 
123
 
124
- response = client.predict(
 
 
 
 
 
 
 
125
  message, # str in 'Message' Textbox component
126
  system_prompt, # str in 'Optional system prompt' Textbox component
127
  max_new_tokens, # int | float (numeric value between 0 and 4096)
@@ -131,7 +119,8 @@ response = client.predict(
131
  Repetitionpenalty, # int | float (numeric value between 1.0 and 2.0)
132
  api_name="/chat"
133
  )
 
 
134
 
135
-
136
  # Example usage
137
  text_to_speech(response)
 
36
  "transcribe", # str in 'Task' Radio component
37
  api_name="/predict"
38
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+
41
  # Streamlit UI
42
  st.title(TITLE)
43
  st.write(DESCRIPTION)
 
102
  os.system(f'start {filename}') # This works on Windows. For other OS, you might need a different command.
103
 
104
 
105
+ # Prediction function
106
+ 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):
107
+ with st.status("Starting client"):
108
+ client = Client("https://huggingface-projects-llama-2-7b-chat.hf.space/")
109
+ st.write("Requesting Audio Transcriber")
110
+ with st.status("Requesting AgriTure v1"):
111
+ st.write("Requesting API")
112
+ response = client.predict(
113
  message, # str in 'Message' Textbox component
114
  system_prompt, # str in 'Optional system prompt' Textbox component
115
  max_new_tokens, # int | float (numeric value between 0 and 4096)
 
119
  Repetitionpenalty, # int | float (numeric value between 1.0 and 2.0)
120
  api_name="/chat"
121
  )
122
+ st.write("Done")
123
+ return response
124
 
 
125
  # Example usage
126
  text_to_speech(response)