Vatsal Gupta commited on
Commit
79b6c7d
·
unverified ·
2 Parent(s): 8c51745e2127d8

Merge pull request #2 from gvatsal60/fix/pre-commit_VG

Browse files
.pre-commit-config.yaml CHANGED
@@ -21,11 +21,9 @@ repos:
21
  - id: check-symlinks
22
  - id: check-toml
23
  - id: check-vcs-permalinks
24
- - id: check-xml
25
  - id: check-yaml
26
  - id: debug-statements
27
  - id: destroyed-symlinks
28
- # - id: detect-aws-credentials
29
  - id: detect-private-key
30
  - id: double-quote-string-fixer
31
  - id: end-of-file-fixer
@@ -42,41 +40,11 @@ repos:
42
  rev: "v1.10.0"
43
  hooks:
44
  - id: python-use-type-annotations
45
- # Clang-format for formatting C, C++, and JavaScript files
46
- - repo: https://github.com/pre-commit/mirrors-clang-format
47
- rev: "v21.1.0"
48
- hooks:
49
- - id: clang-format
50
- # ESLint for linting JavaScript and TypeScript files
51
- - repo: https://github.com/pre-commit/mirrors-eslint
52
- rev: "v9.35.0"
53
- hooks:
54
- - id: eslint
55
  # Runs mypy to check Python type annotations.
56
  - repo: https://github.com/pre-commit/mirrors-mypy
57
  rev: "v1.18.1"
58
  hooks:
59
  - id: mypy
60
- # Lints SCSS files to enforce style and best practices.
61
- - repo: https://github.com/pre-commit/mirrors-scss-lint
62
- rev: "v0.60.0"
63
- hooks:
64
- - id: scss-lint
65
- # Runs JSHint to analyze JavaScript code for potential errors.
66
- - repo: https://github.com/pre-commit/mirrors-jshint
67
- rev: "v2.13.6"
68
- hooks:
69
- - id: jshint
70
- # Uses fixmyjs to automatically fix simple JavaScript issues.
71
- - repo: https://github.com/pre-commit/mirrors-fixmyjs
72
- rev: "v2.0.0"
73
- hooks:
74
- - id: fixmyjs
75
- # Runs CSSLint to check CSS files for errors and stylistic issues.
76
- - repo: https://github.com/pre-commit/mirrors-csslint
77
- rev: "v1.0.5"
78
- hooks:
79
- - id: csslint
80
  # ShellCheck hook for linting shell scripts
81
  - repo: https://github.com/shellcheck-py/shellcheck-py
82
  rev: "v0.11.0.1"
@@ -114,23 +82,6 @@ repos:
114
  rev: "0.2.2"
115
  hooks:
116
  - id: checkmake
117
- # SQLFluff for linting and fixing SQL files
118
- - repo: https://github.com/sqlfluff/sqlfluff
119
- rev: "3.4.2"
120
- hooks:
121
- - id: sqlfluff-lint
122
- - id: sqlfluff-fix
123
- # RuboCop for linting Ruby files
124
- - repo: https://github.com/rubocop/rubocop
125
- rev: "v1.80.2"
126
- hooks:
127
- - id: rubocop
128
- # Terraform-py for formatting and validating Terraform files
129
- - repo: https://github.com/AleksaC/terraform-py
130
- rev: "v1.13.2"
131
- hooks:
132
- - id: tf-fmt
133
- - id: tf-validate
134
  # Gitleaks for detecting secrets in Git repositories
135
  - repo: https://github.com/gitleaks/gitleaks
136
  rev: "v8.28.0"
 
21
  - id: check-symlinks
22
  - id: check-toml
23
  - id: check-vcs-permalinks
 
24
  - id: check-yaml
25
  - id: debug-statements
26
  - id: destroyed-symlinks
 
27
  - id: detect-private-key
28
  - id: double-quote-string-fixer
29
  - id: end-of-file-fixer
 
40
  rev: "v1.10.0"
41
  hooks:
42
  - id: python-use-type-annotations
 
 
 
 
 
 
 
 
 
 
43
  # Runs mypy to check Python type annotations.
44
  - repo: https://github.com/pre-commit/mirrors-mypy
45
  rev: "v1.18.1"
46
  hooks:
47
  - id: mypy
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  # ShellCheck hook for linting shell scripts
49
  - repo: https://github.com/shellcheck-py/shellcheck-py
50
  rev: "v0.11.0.1"
 
82
  rev: "0.2.2"
83
  hooks:
84
  - id: checkmake
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  # Gitleaks for detecting secrets in Git repositories
86
  - repo: https://github.com/gitleaks/gitleaks
87
  rev: "v8.28.0"
.vscode/dockercompose.code-snippets DELETED
@@ -1 +0,0 @@
1
- /workspaces/gemini-chatbot/snippets/dockercompose.code-snippets
 
 
.vscode/dockerfile.code-snippets DELETED
@@ -1 +0,0 @@
1
- /workspaces/gemini-chatbot/snippets/dockerfile.code-snippets
 
 
.vscode/make.code-snippets DELETED
@@ -1 +0,0 @@
1
- /workspaces/gemini-chatbot/snippets/make.code-snippets
 
 
.vscode/python.code-snippets DELETED
@@ -1 +0,0 @@
1
- /workspaces/gemini-chatbot/snippets/python.code-snippets
 
 
.vscode/settings.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "checkma"
4
- ]
5
- }
 
 
 
 
 
 
.vscode/sh.code-snippets DELETED
@@ -1 +0,0 @@
1
- /workspaces/gemini-chatbot/snippets/sh.code-snippets
 
 
src/app.py CHANGED
@@ -9,22 +9,22 @@ import streamlit as st
9
 
10
  def initialize_session():
11
  """ Initialize session state variables. """
12
- if "messages" not in st.session_state:
13
- st.session_state["messages"] = [{
14
- "role": "assistant",
15
- "content": "How can I help you?"
16
  }]
17
- if "ready" not in st.session_state:
18
- st.session_state["ready"] = False
19
 
20
 
21
  def validate_inputs(_api_key: str, _model_name: str) -> bool:
22
  """ Validate if API key and model name are provided. """
23
  if not _api_key:
24
- st.info("Please add your Google API Key to continue...")
25
  return False
26
  if not _model_name:
27
- st.info("Please select a model to continue...")
28
  return False
29
  return True
30
 
@@ -55,49 +55,49 @@ def generate_response(_model: genai.GenerativeModel, _prompt: str) -> str | None
55
 
56
  with st.sidebar:
57
  api_key = st.text_input(
58
- label="Google API Key",
59
- key="_api_key",
60
- type="password",
61
- help="Get your API key from https://aistudio.google.com/apikey",
62
- placeholder="Enter your Google API Key",
63
  )
64
  model_name = st.selectbox(
65
- label="Select Model",
66
  options=[
67
- "gemini-2.5-pro",
68
- "gemini-2.5-flash",
69
- "gemini-2.5-flash-lite",
70
- "gemini-2.0-flash",
71
- "gemini-2.0-flash-lite",
72
  ],
73
  index=None,
74
- help="Choose a Gemini model"
75
  )
76
 
77
- st.title("💬 Q&A Chatbot")
78
 
79
  initialize_session()
80
 
81
  for msg in st.session_state.messages:
82
- st.chat_message(msg["role"]).write(msg["content"])
83
 
84
  # Only enable chat input if API key and model are set
85
  INPUT_DISABLED = not validate_inputs(api_key, model_name)
86
  prompt = st.chat_input(disabled=INPUT_DISABLED)
87
 
88
  if prompt and not INPUT_DISABLED:
89
- st.session_state.messages.append({"role": "user", "content": prompt})
90
- st.chat_message("user").write(prompt)
91
 
92
  model = get_model(api_key, model_name)
93
  if model:
94
  response = generate_response(model, prompt)
95
  if response:
96
  st.session_state.messages.append(
97
- {"role": "assistant", "content": response})
98
- st.chat_message("assistant").write(response)
99
  else:
100
  st.session_state.messages.append(
101
- {"role": "assistant", "content": "Sorry, I couldn't process your request."})
102
- st.chat_message("assistant").write(
103
  "Sorry, I couldn't process your request.")
 
9
 
10
  def initialize_session():
11
  """ Initialize session state variables. """
12
+ if 'messages' not in st.session_state:
13
+ st.session_state['messages'] = [{
14
+ 'role': 'assistant',
15
+ 'content': 'How can I help you?'
16
  }]
17
+ if 'ready' not in st.session_state:
18
+ st.session_state['ready'] = False
19
 
20
 
21
  def validate_inputs(_api_key: str, _model_name: str) -> bool:
22
  """ Validate if API key and model name are provided. """
23
  if not _api_key:
24
+ st.info('Please add your Google API Key to continue...')
25
  return False
26
  if not _model_name:
27
+ st.info('Please select a model to continue...')
28
  return False
29
  return True
30
 
 
55
 
56
  with st.sidebar:
57
  api_key = st.text_input(
58
+ label='Google API Key',
59
+ key='_api_key',
60
+ type='password',
61
+ help='Get your API key from https://aistudio.google.com/apikey',
62
+ placeholder='Enter your Google API Key',
63
  )
64
  model_name = st.selectbox(
65
+ label='Select Model',
66
  options=[
67
+ 'gemini-2.5-pro',
68
+ 'gemini-2.5-flash',
69
+ 'gemini-2.5-flash-lite',
70
+ 'gemini-2.0-flash',
71
+ 'gemini-2.0-flash-lite',
72
  ],
73
  index=None,
74
+ help='Choose a Gemini model'
75
  )
76
 
77
+ st.title('💬 Q&A Chatbot')
78
 
79
  initialize_session()
80
 
81
  for msg in st.session_state.messages:
82
+ st.chat_message(msg['role']).write(msg['content'])
83
 
84
  # Only enable chat input if API key and model are set
85
  INPUT_DISABLED = not validate_inputs(api_key, model_name)
86
  prompt = st.chat_input(disabled=INPUT_DISABLED)
87
 
88
  if prompt and not INPUT_DISABLED:
89
+ st.session_state.messages.append({'role': 'user', 'content': prompt})
90
+ st.chat_message('user').write(prompt)
91
 
92
  model = get_model(api_key, model_name)
93
  if model:
94
  response = generate_response(model, prompt)
95
  if response:
96
  st.session_state.messages.append(
97
+ {'role': 'assistant', 'content': response})
98
+ st.chat_message('assistant').write(response)
99
  else:
100
  st.session_state.messages.append(
101
+ {'role': 'assistant', 'content': "Sorry, I couldn't process your request."})
102
+ st.chat_message('assistant').write(
103
  "Sorry, I couldn't process your request.")