Docfile commited on
Commit
2a3b1c5
·
verified ·
1 Parent(s): 468847d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -19
app.py CHANGED
@@ -3,25 +3,12 @@ import gradio as gr
3
  from langchain_google_genai import ChatGoogleGenerativeAI
4
  from langchain import LLMChain, PromptTemplate
5
  from langchain.memory import ConversationBufferMemory
 
 
 
 
 
6
 
7
- safety_settings = [
8
- {
9
- "category": "HARM_CATEGORY_HARASSMENT",
10
- "threshold": "BLOCK_NONE"
11
- },
12
- {
13
- "category": "HARM_CATEGORY_HATE_SPEECH",
14
- "threshold": "BLOCK_NONE"
15
- },
16
- {
17
- "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
18
- "threshold": "BLOCK_NONE"
19
- },
20
- {
21
- "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
22
- "threshold": "BLOCK_NONE"
23
- },
24
- ]
25
 
26
  import getpass
27
 
@@ -50,7 +37,12 @@ memory = ConversationBufferMemory(memory_key="chat_history")
50
 
51
  llm_chain = LLMChain(
52
  llm=ChatGoogleGenerativeAI(model="gemini-1.5-flash-lastest"),
53
- safety_settings=safety_settings,
 
 
 
 
 
54
  prompt=prompt,
55
  verbose=True,
56
  memory=memory,
 
3
  from langchain_google_genai import ChatGoogleGenerativeAI
4
  from langchain import LLMChain, PromptTemplate
5
  from langchain.memory import ConversationBufferMemory
6
+ from langchain.llms.google_genai import (
7
+ HarmBlockThreshold,
8
+ HarmCategory,
9
+ )
10
+
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  import getpass
14
 
 
37
 
38
  llm_chain = LLMChain(
39
  llm=ChatGoogleGenerativeAI(model="gemini-1.5-flash-lastest"),
40
+ safety_settings={
41
+ HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
42
+ HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
43
+ HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
44
+ HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
45
+ },
46
  prompt=prompt,
47
  verbose=True,
48
  memory=memory,