Zeel commited on
Commit
a33d4cf
·
1 Parent(s): bc03a4d

push to production

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -11,6 +11,9 @@ from langchain_groq.chat_models import ChatGroq
11
  from langchain_google_genai import GoogleGenerativeAI
12
  from streamlit_feedback import streamlit_feedback
13
  from huggingface_hub import HfApi
 
 
 
14
  st.set_page_config(layout="wide")
15
 
16
  # Load environment variables : Groq and Hugging Face API keys
@@ -271,6 +274,27 @@ import uuid
271
  answer = f"!!!Faced an error while working on your query. Please try again!!!"
272
 
273
  response = {"role": "assistant", "content": answer, "gen_code": code, "ex_code": code, "last_prompt": prompt, "error": error}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
  # Get response from agent
276
  # response = ask_question(model_name=model_name, question=prompt)
@@ -290,10 +314,10 @@ import uuid
290
  # contact details
291
  contact_details = """
292
  **Feel free to reach out to us:**
293
- - [Yash J Bachwana](mailto:[email protected])
294
- (Lead Developer, IIT Gandhinagar)
295
  - [Zeel B Patel](https://patel-zeel.github.io/)
296
  (PhD Student, IIT Gandhinagar)
 
 
297
  - [Nipun Batra](https://nipunbatra.github.io/)
298
  (Faculty, IIT Gandhinagar)
299
  """
 
11
  from langchain_google_genai import GoogleGenerativeAI
12
  from streamlit_feedback import streamlit_feedback
13
  from huggingface_hub import HfApi
14
+ from datasets import load_dataset, get_dataset_config_info
15
+ from PIL import Image
16
+
17
  st.set_page_config(layout="wide")
18
 
19
  # Load environment variables : Groq and Hugging Face API keys
 
274
  answer = f"!!!Faced an error while working on your query. Please try again!!!"
275
 
276
  response = {"role": "assistant", "content": answer, "gen_code": code, "ex_code": code, "last_prompt": prompt, "error": error}
277
+
278
+ # Update to HuggingFace dataset
279
+ dataset_config = get_dataset_config_info("SustainabilityLabIITGN/VayuBuddy_logs", token=hf_token)
280
+ splits = dataset_config.splits
281
+ last_split = list(splits.keys())[-1]
282
+ last_split_size = splits[last_split].num_examples
283
+
284
+ if last_split_size >= 100:
285
+ current_split = str(int(last_split) + 1)
286
+ else:
287
+ current_split = last_split
288
+
289
+ try:
290
+ img = Image.open(answer)
291
+ answer = None
292
+ image = answer
293
+ except:
294
+ image = None
295
+
296
+ ds = ds.add_item({"prompt": prompt, "code": code, "answer": answer, "error": error, "model": model_name, "image": image})
297
+ ds.push_to_hub("SustainabilityLabIITGN/VayuBuddy_logs", split=current_split, token=hf_token)
298
 
299
  # Get response from agent
300
  # response = ask_question(model_name=model_name, question=prompt)
 
314
  # contact details
315
  contact_details = """
316
  **Feel free to reach out to us:**
 
 
317
  - [Zeel B Patel](https://patel-zeel.github.io/)
318
  (PhD Student, IIT Gandhinagar)
319
+ - Yash J Bachwana
320
+ (Developer, IIT Gandhinagar)
321
  - [Nipun Batra](https://nipunbatra.github.io/)
322
  (Faculty, IIT Gandhinagar)
323
  """