Bofandra commited on
Commit
74c9f1a
·
verified ·
1 Parent(s): 0fa7c3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -5,6 +5,7 @@ import pandas as pd
5
  import torch
6
  import math
7
  import httpcore
 
8
  setattr(httpcore, 'SyncHTTPTransport', 'AsyncHTTPProxy')
9
 
10
  """
@@ -30,9 +31,11 @@ def respond(
30
  messages.append({"role": "assistant", "content": "I'd be happy to help! Please go ahead and provide the sentence you'd like me to analyze. Please specify whether you're referencing a particular verse or hadith (Prophetic tradition) from the Quran or Hadith, or if you're asking me to analyze a general statement."})
31
 
32
  #adding fatwa references
33
- device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
34
- selected_references = torch.load('selected_references.sav', map_location=torch.device(device))
35
- encoded_questions = torch.load('encoded_questions.sav', map_location=torch.device(device))
 
 
36
 
37
  task = 'Given a web search query, retrieve relevant passages that answer the query'
38
  queries = [
@@ -58,7 +61,9 @@ def respond(
58
  try:
59
  print(index)
60
  print(f'{row["user"]}')
61
- user = translator.translate(f'{row["user"]}', src='ar', dest='en').text
 
 
62
  print(user)
63
  #print(row['assistant'])
64
  assistant = translator.translate(row['assistant']).text
 
5
  import torch
6
  import math
7
  import httpcore
8
+ import pickle
9
  setattr(httpcore, 'SyncHTTPTransport', 'AsyncHTTPProxy')
10
 
11
  """
 
31
  messages.append({"role": "assistant", "content": "I'd be happy to help! Please go ahead and provide the sentence you'd like me to analyze. Please specify whether you're referencing a particular verse or hadith (Prophetic tradition) from the Quran or Hadith, or if you're asking me to analyze a general statement."})
32
 
33
  #adding fatwa references
34
+ #device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
35
+ #selected_references = torch.load('selected_references.sav', map_location=torch.device(device))
36
+ #encoded_questions = torch.load('encoded_questions.sav', map_location=torch.device(device))
37
+ selected_references = pickle.load(open('selected_references.sav','rb'))
38
+ encoded_questions = pickle.load(open('encoded_questions.sav','rb'))
39
 
40
  task = 'Given a web search query, retrieve relevant passages that answer the query'
41
  queries = [
 
61
  try:
62
  print(index)
63
  print(f'{row["user"]}')
64
+ translated = translator.translate(f'{row["user"]}', src='ar', dest='en')
65
+ print(translated)
66
+ user = translated.text
67
  print(user)
68
  #print(row['assistant'])
69
  assistant = translator.translate(row['assistant']).text