File size: 1,258 Bytes
8c2f5a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be43ce0
8c2f5a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5bab70b
8c2f5a2
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 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()