Praneeth KVS commited on
Commit
3bf1b75
·
verified ·
1 Parent(s): 272694c

Update agrichat_bot.py

Browse files
Files changed (1) hide show
  1. agrichat_bot.py +10 -3
agrichat_bot.py CHANGED
@@ -6,7 +6,7 @@ Automatically generated by Colaboratory.
6
  Original file is located at
7
  https://colab.research.google.com/drive/1x6nj6FVHwQDucH0LD-skTOqRwKkDuwCZ
8
  """
9
-
10
  !pip install -q -U google-generativeai
11
 
12
  pip install gradio
@@ -21,7 +21,7 @@ from google.colab import userdata
21
  #GOOGLE_API_KEY=userdata.get('G-API_key2')
22
  #genai.configure(api_key=GOOGLE_API_KEY)
23
 
24
- '''
25
  def gemini_chat(message, history):
26
  GOOGLE_API_KEY = 'AIzaSyBJeLAdQIoMkF8cHrNpCFrtb0iU_QAgk84'
27
  genai.configure(api_key=GOOGLE_API_KEY)
@@ -30,7 +30,7 @@ def gemini_chat(message, history):
30
  prompt = 'Question :' + message + '- ' + 'If this Question is related to agriculture, farming, pests, agricultute practices, farmers, crops, crop management, soil, irrigation, various aspects of agriculture, pest control, weather forecasting, market prices, general farming queries, relevant stuff then consider the question as valid and generate answer(only the answer, not the description of what the instruction I have provided in about 30-40 words), otherwise reply that, I am sorry, but I cannot provide an answer to that question as it is inappropriate or not related to agriculture. One more point to remember is to make sure to be interactive, such as greeting the users if they say hi & introduce yourself & how can you help them with(related to farming & agriculture) but dont say that it is not related to agriculture only if the user is greeting or introducing, or say welcome if user says thank you etc. but make sure you never reveal that you are made using Gemini, if needed respond saying that contact author for more information)'
31
  response = chat.send_message(prompt)
32
  return response.text
33
- '''
34
  def gemini_chat(message):
35
  return('This is '+message)
36
 
@@ -53,4 +53,11 @@ iface.launch(debug=True)
53
  #!git config --global credential.helper store
54
 
55
  #!gradio deploy
 
 
 
 
 
56
 
 
 
 
6
  Original file is located at
7
  https://colab.research.google.com/drive/1x6nj6FVHwQDucH0LD-skTOqRwKkDuwCZ
8
  """
9
+ '''
10
  !pip install -q -U google-generativeai
11
 
12
  pip install gradio
 
21
  #GOOGLE_API_KEY=userdata.get('G-API_key2')
22
  #genai.configure(api_key=GOOGLE_API_KEY)
23
 
24
+
25
  def gemini_chat(message, history):
26
  GOOGLE_API_KEY = 'AIzaSyBJeLAdQIoMkF8cHrNpCFrtb0iU_QAgk84'
27
  genai.configure(api_key=GOOGLE_API_KEY)
 
30
  prompt = 'Question :' + message + '- ' + 'If this Question is related to agriculture, farming, pests, agricultute practices, farmers, crops, crop management, soil, irrigation, various aspects of agriculture, pest control, weather forecasting, market prices, general farming queries, relevant stuff then consider the question as valid and generate answer(only the answer, not the description of what the instruction I have provided in about 30-40 words), otherwise reply that, I am sorry, but I cannot provide an answer to that question as it is inappropriate or not related to agriculture. One more point to remember is to make sure to be interactive, such as greeting the users if they say hi & introduce yourself & how can you help them with(related to farming & agriculture) but dont say that it is not related to agriculture only if the user is greeting or introducing, or say welcome if user says thank you etc. but make sure you never reveal that you are made using Gemini, if needed respond saying that contact author for more information)'
31
  response = chat.send_message(prompt)
32
  return response.text
33
+
34
  def gemini_chat(message):
35
  return('This is '+message)
36
 
 
53
  #!git config --global credential.helper store
54
 
55
  #!gradio deploy
56
+ '''
57
+ import gradio as gr
58
+
59
+ def greet(name):
60
+ return "Hello " + name + "!!"
61
 
62
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
63
+ iface.launch()