thivav commited on
Commit
ebfef12
β€’
1 Parent(s): 750833f

initial commit

Browse files
.github/workflows/sync_to_huggingface_hub.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to HuggingFace hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push --force https://thivav:[email protected]/spaces/thivav/chat_with_gemini main
.gitignore CHANGED
@@ -157,4 +157,6 @@ cython_debug/
157
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
- #.idea/
 
 
 
157
  # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ .idea/
161
+
162
+ vscode/
README.md CHANGED
@@ -1,2 +1,12 @@
1
- # gemini_conversational_chatbot
2
- Google Gemini Chatbot
 
 
 
 
 
 
 
 
 
 
 
1
+ title: Chat With Gemini
2
+ emoji: πŸ€–
3
+ colorFrom: pink
4
+ colorTo: pink
5
+ sdk: streamlit
6
+ sdk_version: 1.31.0
7
+ app_file: app.py
8
+ pinned: false
9
+
10
+ # Chatbot with Gemini
11
+
12
+ [Google Gemini Chatbot - Playground](https://huggingface.co/spaces/thivav/chat_with_gemini)
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ import streamlit as st
3
+
4
+
5
+ def main():
6
+ """main"""
7
+
8
+ st.set_page_config(
9
+ page_title="Gemini Chatbot",
10
+ page_icon="πŸ€–",
11
+ layout="centered",
12
+ initial_sidebar_state="collapsed",
13
+ )
14
+
15
+ st.header("The Gemini Chatbot πŸ€–", divider="rainbow")
16
+
17
+ st.subheader(
18
+ "Enjoy :red[talking] with :green[Google Gemini] :sunglasses:"
19
+ )
20
+
21
+ st.markdown("[check out the repository](https://github.com/ThivaV/gemini_chatbot)")
22
+
23
+ gemini_key = st.text_input("Enter your Google Gemini API key πŸ‘‡", type="password")
24
+
25
+ genai.configure(api_key=gemini_key)
26
+
27
+ model = genai.GenerativeModel("gemini-pro")
28
+ chat = model.start_chat(history=[])
29
+
30
+ for message in st.session_state.messages:
31
+ with st.chat_message(message["role"]):
32
+ st.markdown(message["content"])
33
+
34
+ if prompt := st.chat_input("Say something"):
35
+ # user message
36
+ with st.chat_message("user"):
37
+ st.markdown(prompt)
38
+ st.session_state.messages.append({"role": "user", "content": prompt})
39
+
40
+ response = chat.send_message(prompt, stream=True)
41
+ complete_response = ""
42
+ with st.chat_message("assistant"):
43
+ for chunk in response:
44
+ complete_response += chunk.text
45
+ st.write(chunk.text)
46
+
47
+ st.session_state.messages.append(
48
+ {"role": "assistant", "content": complete_response}
49
+ )
50
+
51
+
52
+ if __name__ == "__main__":
53
+
54
+ # initialize streamlit session state
55
+ if "messages" not in st.session_state:
56
+ st.session_state.messages = []
57
+
58
+ main()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit==1.29.0
2
+ google-generativeai==0.3.2