Spaces:
Build error
Build error
Update app.py
Browse files136 unmodified lines1371381391401401411421431 unmodified line14514614714814914814915015115286 unmodified lines2392402412422432422432442452462 unmodified lines2492502512522532542552522532542552562572588 unmodified lines26726826927027027127227330 unmodified lines30430530630730730830931016 unmodified lines3273283293303303313323337 unmodified lines341342343344345344345346347347348349349350351352352353354355162 unmodified lines5185195205215215225235243 unmodified lines5285295305315325315325335345351 unmodified line5375385395405415425435405415425435445455461 unmodified line5485495505515515525535545555565565575585592 unmodified lines562563564565566565566567568569136 unmodified linesdef database_tool(question): # print(question) sql_query = generate_sql_query(question) print(sql_query) #print(sql_query) return run_query(sql_query)
1 unmodified line # print(question) base_url = os.getenv("ASN_API_URL") complete_url = f"{base_url}branchMaster.id=343&transactionUid={question}&userId=164&transactionType=ASN" print("complete url") print(complete_url) #print("complete url") #print(complete_url) try: response = requests.get(complete_url) data = response.json()86 unmodified lines print(f"Document data tool enter: {question}") # query_string = question['tags'][0] if 'tags' in question and question['tags'] else "" query_response = query_vector_store(vector_store, question, config={"callbacks": [langfuse_handler]}) print("query****") print(query_response) #print("query****") #print(query_response) # summarized_response = summarize_document(query_response) # print("summary***") # print(summarized_response)2 unmodified lines
def send_email_with_attachment(recipient_email, subject, body, image_data): try: print(recipient_email) print(subject) print(body) print(image_data) #print(recipient_email) #print(subject) #print(body) #print(image_data) sender_email = os.getenv("EMAIL_SENDER") sender_password = os.getenv("EMAIL_PASSWORD") 8 unmodified lines """ # Open the file to be sent attachment = open(attachment_path, "rb") print("Attached the image") #print("Attached the image") # Instance of MIMEBase and named as p part = MIMEBase('application', 'octet-stream') 30 unmodified lines server.sendmail(sender_email, recipient_email, text) server.quit() except error: except Exception as error: print(error) # return 116 unmodified lines
def inventory_report(question): print(question) #print(question)
7 unmodified lines else: return "warehouse name not found"
print(apis[0]["url"]) print(apis[0]["params"]) #print(apis[0]["url"]) #print(apis[0]["params"]) data = make_api_request(apis[0]["url"], apis[0]["params"]) print(warehouse_name) #print(warehouse_name) if data: print(data) #print(data) # Extracting the id for the warehouse with the name "WH" warehouse_id = next((item['id'] for item in data['result'] if item['name'] == warehouse_name), None) print(warehouse_id) #print(warehouse_id) if warehouse_id is None: return "Please provide a warehouse name available in the database." # print(f"The id for the warehouse named {name} is: {warehouse_id}")162 unmodified lines user_question = "Could not request results from Google Speech Recognition service."
while iterations < max_iterations: print(user_question) #print(user_question) """if "send email to" in user_question: email_match = re.search(r"send email to ([\w\.-]+@[\w\.-]+)", user_question) if email_match:3 unmodified lines """
response = agent_executor.invoke({"input": user_question}, config={"callbacks": [langfuse_handler]}) print("name") print(warehouse_name) #print("name") #print(warehouse_name) if isinstance(response, dict): response_text = response.get("output", "") else:1 unmodified line if "invalid" not in response_text.lower(): break iterations += 1 print(os.getenv("IMAGE_PATH")) print(response_text) print("validating. ") print(os.getenv("IMAGE_PATH") in response_text) #print(os.getenv("IMAGE_PATH")) #print(response_text) #print("validating. ") #print(os.getenv("IMAGE_PATH") in response_text) if iterations == max_iterations: return "The agent could not generate a valid response within the iteration limit."
1 unmodified line if os.getenv("IMAGE_PATH") in response_text: # Open the image file img = Image.open(os.getenv("IMAGE_PATH")) print(img) #print(img) # Convert the PIL Image to a base64 encoded string buffered = BytesIO() img.save(buffered, format="PNG") img_str = base64.b64encode(buffered.getvalue()).decode("utf-8") print(img_str) #print(img_str) img = f'<img src="data:image/png;base64,{img_str}" style="width:500px; height:400px;">' # image = gr.Image(value=img_str) chatbot.append((user_question, img))2 unmodified lines match = re.search(email_pattern, user_question) if match: user_email = match.group() # Return the matched email print("user_email") print(user_email) #print("user_email") #print(user_email) # email send if user_email: # Send email with the chart image attachedapp.py+28-28