-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
59 lines (37 loc) · 1.24 KB
/
test.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pprint
import google.generativeai as palm
palm.configure(api_key='AIzaSyDslGELzeDfdc3DLufleR1y2Reie8RSGfk')
model = palm.get_model('models/chat-bison-001')
prompt = "what is 30 + 70"
response = palm.chat(
model=model,
# prompt=prompt,
temperature=0,
# The maximum length of the response
# max_output_tokens=800,
messages=[prompt]
)
print(response.last)
# import vertexai
# from vertexai.preview.language_models import ChatModel
# def doChat():
# # initialize vertexai
# # projectname = "my-project"
# # location = "us-central1"
# vertexai.init(project="your-project-name", location="your-project-location")
# # load model
# chat_model = ChatModel.from_pretrained("chat-bison@001")
# # define model parameters
# parameters = {
# "temperature": 0.2,
# "max_output_tokens": 256,
# "top_p": 0.8,
# "top_k": 40,
# }
# # starts a chat session with the model
# chat = chat_model.start_chat()
# # sends message to the language model and gets a response
# response = chat.send_message("hi", **parameters) # user says "hi"
# return response
# # Invoke doChat()
# print(doChat()) # bot replies "Hi there! How can I help you today?"