subashpoudel commited on
Commit
bb3134a
·
1 Parent(s): c51708f
api/routers/analytics_chatbot.py CHANGED
@@ -53,7 +53,8 @@ def get_analytics(request: AnalyticsChatRequest):
53
 
54
  if request.image_base64 and not response_to_cache.get('description'):
55
  description = generate_analytics_description(user_query, request.image_base64)
56
- response_to_cache['description'] = description
 
57
 
58
  redis_client.set(cache_key, json.dumps(response_to_cache), ex=3000)
59
  return response_to_cache
 
53
 
54
  if request.image_base64 and not response_to_cache.get('description'):
55
  description = generate_analytics_description(user_query, request.image_base64)
56
+ if description is not None:
57
+ response_to_cache['description'] = description
58
 
59
  redis_client.set(cache_key, json.dumps(response_to_cache), ex=3000)
60
  return response_to_cache
src/genai/analytics_chatbot/handlers/analytics_description.py CHANGED
@@ -15,19 +15,21 @@ os.environ['GOOGLE_API_KEY']=os.getenv('GOOGLE_API_KEY')
15
  # '''
16
 
17
  def generate_analytics_description(query,image_base64):
18
- if image_base64 != 'string':
19
- client = genai.Client()
20
- response = client.models.generate_content(
21
- model='gemini-2.5-flash',
22
- contents=[
23
- types.Part.from_bytes(
24
- data=image_base64,
25
- mime_type='image/jpeg',
26
- ),
27
- analytics_description_prompt(query)
28
- ]
29
- )
30
- print('The image description:', response.text)
31
- return response.text
 
 
32
 
33
 
 
15
  # '''
16
 
17
  def generate_analytics_description(query,image_base64):
18
+ if image_base64=='string':
19
+ return None
20
+ client = genai.Client()
21
+ response = client.models.generate_content(
22
+ model='gemini-2.5-flash',
23
+ contents=[
24
+ types.Part.from_bytes(
25
+ data=image_base64,
26
+ mime_type='image/jpeg',
27
+ ),
28
+ analytics_description_prompt(query)
29
+ ]
30
+ )
31
+ print('The image description:', response.text)
32
+ return response.text
33
+
34
 
35