File size: 955 Bytes
d6f2caa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- coding: utf-8 -*-
"""Copy of Chatbot Using Palm2.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1MUwDOHPis5F5KsSboYLU1NN8apLmjiVE
"""


import google.generativeai as palm
import gradio as gr

palm.configure(api_key='AIzaSyArybMiPDZARDCz7yZBjzEMx6zXgOXHtoc')

models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
model = models[0].name

def get_text_response(user_message,history):
  completion = palm.generate_text(
    model=model,
    prompt=user_message,
    temperature=0.25,  # temperature=0 >> more deterministic results // temperature=1 >> more randomness
    max_output_tokens=100    # maximum length of response

)
  return completion.result

demo = gr.ChatInterface(get_text_response, examples=["How are you doing?","What are your interests?","Which places do you like to visit?"])

if __name__ == "__main__":
  demo.launch()