|
import tempfile |
|
import gradio as gr |
|
import janus_swi as janus |
|
import nest_asyncio |
|
|
|
nest_asyncio.apply() |
|
|
|
def yes_man(message, history): |
|
janus.consult("knowledge_base.pl") |
|
|
|
|
|
|
|
|
|
with open("tmp.pl", 'w') as f: |
|
f.write("""% Define the person |
|
us_citizen(john_doe) |
|
lawfully_residing(john_doe, 'U.S.', date(1996, 1, 1)) |
|
condition(john_doe, 'Blind')""") |
|
|
|
janus.consult("tmp.pl") |
|
if message.endswith("?"): |
|
result = janus.query_once("eligible_for_ssi(john_doe)") |
|
else: |
|
result = '\n- '.join(list(janus.query("eligible_for_ssi(john_doe)"))) |
|
|
|
return result |
|
|
|
gr.ChatInterface( |
|
yes_man, |
|
title="Yes Man", |
|
description="Ask Yes Man any question", |
|
examples=["Hello", "Am I cool?", "Are tomatoes vegetables?"], |
|
).launch() |