Team Ai
Apppublic

Akshaya03/codeChatbot

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py41 linesDownload Raw Back to root
1# -*- coding: utf-8 -*-2"""Copy of Chatbot Using Palm2.ipynb3 4Automatically generated by Colaboratory.5 6Original file is located at7    https://colab.research.google.com/drive/1gxylDkf4dYC_VtrpBGfpevKtt-o_miyo8"""9 10 11 12import google.generativeai as palm13import gradio as gr14 15 16palm.configure(api_key='AIzaSyDvpyE73ZBnaLICza4FJdpJ2xZWTdXUB4I')17 18models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]19model = models[0].name20 21#def get_text_response(user_message,history):22  #  response = palm.chat(messages=user_message)23  #  return response.last24 25#demo = gr.ChatInterface(get_text_response, examples=["How are you doing?","What are your interests?","Which places do you like to visit?"])26 27def get_text_response(user_message,history):28  completion = palm.generate_text(29    model=model,30    prompt=user_message,31    temperature=0.25,32    # temperature=0 >> more deterministic results // temperature=1 >> more randomness33    max_output_tokens=10034    # maximum length of response35)36  return completion.result37 38demo = gr.ChatInterface(get_text_response, examples=["How are you doing?","What are your interests?","Which places do you like to visit?"])39 40if __name__ == "__main__":41  demo.launch()