File size: 1,025 Bytes
e460bb5
c1548d4
e460bb5
c1548d4
71ad11e
e460bb5
 
71ad11e
e460bb5
a91e5a1
71ad11e
5f28fdf
c1548d4
 
68add6e
86c27ed
2d7fa2c
86c27ed
 
 
518063c
86c27ed
2d7fa2c
86c27ed
 
 
0d2d23e
 
 
 
 
 
c1548d4
 
4238098
c1548d4
 
 
 
 
 
4238098
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import google.generativeai as palm
import gradio as gr
import os 
import json

# Set your API key
palm.configure(api_key=os.environ['PALM_KEY'])

# Select the PaLM 2 model
# model = 'models/text-bison-001'


def responsenew(data):
    response = palm.chat(messages=data)
    if "payment" in response.last:
        respo = {
            "message": "Click the button below to view premium services and recharge options: ",
            "action": "payment",
            "function": "nothing"
        }
    elif "friends" in response.last:
        respo = {
            "message": "Click the option below to view list of your friends: ",
            "action": "show_friends",
            "function": "nothing"
        }
    else:
        respo = {
            "message": response.last,
            "action": "nothing",
            "function": "nothing"
        }
    print(data)
    return json.dumps(respo)

gradio_interface = gr.Interface(
  fn = responsenew,
  inputs = "text",
  outputs = "text" 
)
gradio_interface.launch()