Spaces:

npc0 commited on
Commit
395be3e
1 Parent(s): 89e4920

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,13 +1,19 @@
 
1
  import gradio as gr
2
- from pyswip import Prolog
3
- prolog = Prolog()
4
- prolog.consult("knowledge_base.pl")
5
 
6
  def yes_man(message, history):
7
- # % Define the person
8
- prolog.assertz("us_citizen(john_doe)")
9
- prolog.assertz("lawfully_residing(john_doe, 'U.S.', date(1996, 1, 1))")
10
- prolog.assertz("condition(john_doe, 'Blind')")
 
 
 
 
 
 
 
11
  if message.endswith("?"):
12
  return prolog.query_once("eligible_for_ssi(john_doe)")
13
  else:
 
1
+ import tempfile
2
  import gradio as gr
3
+ import janus_swi as janus
 
 
4
 
5
  def yes_man(message, history):
6
+ janus.consult("knowledge_base.pl")
7
+ tmp = tempfile.NamedTemporaryFile(suffix='.pl')
8
+
9
+ # Open the file for writing.
10
+ with open(tmp.name, 'w') as f:
11
+ f.write("""% Define the person
12
+ us_citizen(john_doe)
13
+ lawfully_residing(john_doe, 'U.S.', date(1996, 1, 1))
14
+ condition(john_doe, 'Blind')""")
15
+ janus.consult(tmp.name)
16
+ tmp.close()
17
  if message.endswith("?"):
18
  return prolog.query_once("eligible_for_ssi(john_doe)")
19
  else: