wasm-speeker-sa / genai_chat_ai.py
ASG Models
Update genai_chat_ai.py
5bab70b verified
raw
history blame
1.26 kB
import os
import google.generativeai as genai
api_key = os.environ.get("id_gmkey")
genai.configure(api_key=api_key)
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
model = genai.GenerativeModel(
model_name="gemini-1.5-pro",
generation_config=generation_config,
# safety_settings = Adjust safety settings
# See https://ai.google.dev/gemini-api/docs/safety-settings
)
def create_chat_session():
chat_session = model.start_chat(
history=[
{
"role": "user",
"parts": [
os.environ.get("user_0") ,
],
},
{
"role": "model",
"parts": [
os.environ.get("model_0")
,
],
},
{
"role": "user",
"parts": [
os.environ.get("user_1"),
],
},
{
"role": "model",
"parts": [
os.environ.get("model_1")
,
],
}
]
)
return chat_session
AI=create_chat_session()