Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,11 +12,12 @@ genai.configure(api_key="AIzaSyD2o8vjePJb6z8vT_PVe82lVWMD3_cBL0g")
|
|
| 12 |
def predict(message :str ,history : Optional[List],topic : Optional[str] = "OIC") -> str:
|
| 13 |
model = genai.GenerativeModel("gemini-pro")
|
| 14 |
his = []
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
chat = model.start_chat(
|
| 21 |
history=his
|
| 22 |
)
|
|
|
|
| 12 |
def predict(message :str ,history : Optional[List],topic : Optional[str] = "OIC") -> str:
|
| 13 |
model = genai.GenerativeModel("gemini-pro")
|
| 14 |
his = []
|
| 15 |
+
if history:
|
| 16 |
+
for i,j in history:
|
| 17 |
+
his.extend([
|
| 18 |
+
{"role": "user", "parts": i},
|
| 19 |
+
{"role": "model", "parts": j},
|
| 20 |
+
])
|
| 21 |
chat = model.start_chat(
|
| 22 |
history=his
|
| 23 |
)
|