Spaces:
Runtime error
Runtime error
| # -*- coding: utf-8 -*- | |
| """Copy of Chatbot Using Palm2.ipynb | |
| Automatically generated by Colaboratory. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1H642l9_H5oFebQPEWzvy6tS67E0b9Ed- | |
| """ | |
| import google.generativeai as palm | |
| import gradio as gr | |
| palm.configure(api_key='AIzaSyC5eNCtrd4ooYj6Bzk5ejQoJx9HrjGHqu8') | |
| models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods] | |
| model = models[0].name | |
| models = palm.list_models() | |
| print("Available models:") | |
| for m in models: | |
| print(f"{m.name} - {m.supported_generation_methods}") | |
| #def get_text_response(user_message,history): | |
| # response = palm.chat(messages=user_message) | |
| # return response.last | |
| #demo = gr.ChatInterface(get_text_response, examples=["How are you doing?","What are your interests?","Which places do you like to visit?"]) | |
| 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() |