Spaces:
Building
Building
Commit
·
e985eb9
1
Parent(s):
915c689
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ genai.configure(api_key=os.getenv('PALM_API_KEY'))
|
|
8 |
|
9 |
# Gradio
|
10 |
title = '🦒Playground w/ Google PaLM v2'
|
11 |
-
description = """Click below tab and start with your message"""
|
12 |
|
13 |
def generate_text(prompt: str):
|
14 |
print("Generating Text...")
|
@@ -17,7 +17,7 @@ def generate_text(prompt: str):
|
|
17 |
response = genai.generate_text(prompt=prompt)
|
18 |
result = response.result
|
19 |
except Exception as e:
|
20 |
-
result = "
|
21 |
print(f"Exception {e} occured\n")
|
22 |
print(f"Bot Message:\n{result}\n")
|
23 |
return result
|
@@ -33,6 +33,7 @@ chat_defaults = {
|
|
33 |
chat_history = []
|
34 |
|
35 |
def generate_chat(prompt: str, chat_messages=chat_history):
|
|
|
36 |
context = "You are an intelligent chatbot powered by biggest technology company."
|
37 |
print("Generating Chat Message...")
|
38 |
print(f"User Message:\n{prompt}\n")
|
@@ -45,12 +46,12 @@ def generate_chat(prompt: str, chat_messages=chat_history):
|
|
45 |
)
|
46 |
result = response.last
|
47 |
if result is None:
|
48 |
-
result = "
|
49 |
chat_messages = chat_messages[:-1]
|
50 |
else:
|
51 |
chat_messages.append(result)
|
52 |
except Exception as e:
|
53 |
-
result = "
|
54 |
chat_messages = chat_messages[:-1]
|
55 |
print(f"Exception {e} occured\n")
|
56 |
chat_history = chat_messages
|
@@ -61,7 +62,7 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
|
61 |
gr.Markdown(
|
62 |
f"""
|
63 |
# {title}
|
64 |
-
|
65 |
""")
|
66 |
|
67 |
with gr.Tab('Just Text'):
|
|
|
8 |
|
9 |
# Gradio
|
10 |
title = '🦒Playground w/ Google PaLM v2'
|
11 |
+
description = """Click below tab and start with your message in English"""
|
12 |
|
13 |
def generate_text(prompt: str):
|
14 |
print("Generating Text...")
|
|
|
17 |
response = genai.generate_text(prompt=prompt)
|
18 |
result = response.result
|
19 |
except Exception as e:
|
20 |
+
result = "Apologies but something went wrong. Please try again later."
|
21 |
print(f"Exception {e} occured\n")
|
22 |
print(f"Bot Message:\n{result}\n")
|
23 |
return result
|
|
|
33 |
chat_history = []
|
34 |
|
35 |
def generate_chat(prompt: str, chat_messages=chat_history):
|
36 |
+
print(chat_messages)
|
37 |
context = "You are an intelligent chatbot powered by biggest technology company."
|
38 |
print("Generating Chat Message...")
|
39 |
print(f"User Message:\n{prompt}\n")
|
|
|
46 |
)
|
47 |
result = response.last
|
48 |
if result is None:
|
49 |
+
result = "Apologies but something went wrong. Please try again later."
|
50 |
chat_messages = chat_messages[:-1]
|
51 |
else:
|
52 |
chat_messages.append(result)
|
53 |
except Exception as e:
|
54 |
+
result = "Apologies but something went wrong. Please try again later."
|
55 |
chat_messages = chat_messages[:-1]
|
56 |
print(f"Exception {e} occured\n")
|
57 |
chat_history = chat_messages
|
|
|
62 |
gr.Markdown(
|
63 |
f"""
|
64 |
# {title}
|
65 |
+
### {description}
|
66 |
""")
|
67 |
|
68 |
with gr.Tab('Just Text'):
|