Aasher commited on
Commit
9c11e3d
·
1 Parent(s): db5439f

feat: Implement Auth in Axiom

Browse files
Files changed (2) hide show
  1. chainlit.yaml +13 -0
  2. src/axiom/app.py +15 -2
chainlit.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ auth:
2
+ required: true
3
+ providers:
4
+ - google
5
+ - github
6
+
7
+ outh_providers:
8
+ google:
9
+ client_id: ${OAUTH_GOOGLE_CLIENT_ID}
10
+ client_secret: ${OAUTH_GOOGLE_CLIENT_SECRET}
11
+ github:
12
+ client_id: ${OAUTH_GITHUB_CLIENT_ID}
13
+ client_secret: ${OAUTH_GITHUB_CLIENT_SECRET}
src/axiom/app.py CHANGED
@@ -7,14 +7,14 @@ from langchain_core.messages import AIMessageChunk, HumanMessage
7
 
8
  from chainlit.input_widget import Select, Slider
9
 
 
10
  import os, uuid, base64
11
  from dotenv import load_dotenv
12
 
13
  _ : bool = load_dotenv()
14
 
15
- #################################
16
  # Function to Encode Images
17
- #################################
18
  async def process_image(image: cl.Image):
19
  """
20
  Processes an image file, reads its data, and converts it to a base64 encoded string.
@@ -33,6 +33,19 @@ async def process_image(image: cl.Image):
33
  print(f"Error reading image file: {e}")
34
  return {"type": "text", "text": f"Error processing image {image.name}."}
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  #################################
37
  # Quick Starter Questions
38
  #################################
 
7
 
8
  from chainlit.input_widget import Select, Slider
9
 
10
+ from typing import Optional
11
  import os, uuid, base64
12
  from dotenv import load_dotenv
13
 
14
  _ : bool = load_dotenv()
15
 
16
+
17
  # Function to Encode Images
 
18
  async def process_image(image: cl.Image):
19
  """
20
  Processes an image file, reads its data, and converts it to a base64 encoded string.
 
33
  print(f"Error reading image file: {e}")
34
  return {"type": "text", "text": f"Error processing image {image.name}."}
35
 
36
+ #################################
37
+ # User Authentication
38
+ #################################
39
+ @cl.oauth_callback
40
+ def oauth_callback(
41
+ provider_id: str,
42
+ token: str,
43
+ raw_user_data: dict[str, str],
44
+ default_user: cl.User,
45
+ ) -> Optional[cl.User]:
46
+
47
+ return default_user
48
+
49
  #################################
50
  # Quick Starter Questions
51
  #################################