Spaces:
Runtime error
Runtime error
Commit ·
d6f2caa
1
Parent(s): 519bc36
Upload copy_of_chatbot_using_palm2.py
Browse files
copy_of_chatbot_using_palm2.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Copy of Chatbot Using Palm2.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colaboratory.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1MUwDOHPis5F5KsSboYLU1NN8apLmjiVE
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
!pip install -q google-generativeai
|
| 11 |
+
!pip install gradio
|
| 12 |
+
|
| 13 |
+
import google.generativeai as palm
|
| 14 |
+
import gradio as gr
|
| 15 |
+
|
| 16 |
+
palm.configure(api_key='AIzaSyArybMiPDZARDCz7yZBjzEMx6zXgOXHtoc')
|
| 17 |
+
|
| 18 |
+
models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
|
| 19 |
+
model = models[0].name
|
| 20 |
+
|
| 21 |
+
def get_text_response(user_message,history):
|
| 22 |
+
completion = palm.generate_text(
|
| 23 |
+
model=model,
|
| 24 |
+
prompt=user_message,
|
| 25 |
+
temperature=0.25, # temperature=0 >> more deterministic results // temperature=1 >> more randomness
|
| 26 |
+
max_output_tokens=100 # maximum length of response
|
| 27 |
+
|
| 28 |
+
)
|
| 29 |
+
return completion.result
|
| 30 |
+
|
| 31 |
+
demo = gr.ChatInterface(get_text_response, examples=["How are you doing?","What are your interests?","Which places do you like to visit?"])
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
demo.launch()
|