8956 / app.py
eshhh's picture
Rename copy_of_chatbot_using_palm2.py to app.py
2527d1f
# -*- coding: utf-8 -*-
"""Copy of Chatbot Using Palm2.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lULf1PgAnm8N-8ePk5BkKsYRPrZsZylD
"""
#!pip install -q google-generativeai
#!pip install gradio
import google.generativeai as palm
import gradio as gr
palm.configure(api_key='AIzaSyDE3XsINEJkVZR2-P3KT_x3CX5kT1G-dQU')
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()