suriya7 commited on
Commit
972af27
1 Parent(s): 2ad8b75

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +72 -73
model.py CHANGED
@@ -1,73 +1,72 @@
1
- import google.generativeai as genai
2
- import os
3
- from dotenv import load_dotenv
4
-
5
- load_dotenv()
6
- os.environ["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY")
7
- genai.configure(api_key="AIzaSyDA6zE16NjMSYefmnIo74aJ8cacoDxJsrE")
8
-
9
-
10
- class AllModels:
11
- def __init__(self):
12
- self.model = genai.GenerativeModel('gemini-1.5-flash-latest')
13
-
14
-
15
- def road_map_model(self,subjects):
16
- prompt = f"""Create an HTML format roadmap for learning {subjects} with proving week task . The roadmap should include the following sections:
17
-
18
- Introduction: Brief overview of the subject and its importance.
19
-
20
- Foundation: Fundamental concepts and theories to grasp before diving deeper.
21
-
22
- Intermediate Level: More advanced topics building upon the foundation.
23
-
24
- Advanced Level: Complex concepts, techniques, or applications within the subject.
25
-
26
- Resources: List of recommended books, online courses, tutorials, and websites for further learning using hyperlink tag.
27
-
28
- Projects: Hands-on projects or exercises to reinforce learning and apply knowledge.
29
-
30
- Conclusion: Summary of key takeaways and encouragement for further exploration.
31
-
32
- The HTML format should be visually appealing with appropriate headings, subheadings, bullet points, and hyperlinks where necessary. Ensure clarity and logical progression in the roadmap.
33
- NOTE: The roadmap should be provided in pure HTML format without any Markdown or other formatting styles and In the html format dont need style tags and title tags"""
34
-
35
- response = self.model.generate_content([prompt.format(subjects=subjects)])
36
- return response.text
37
-
38
-
39
- def summary_model(self,input_doc=None,image=None):
40
- if input_doc:
41
- prompt = """you are an intelligent assistant using the giving document summarize it shortly
42
- document:
43
- {document}
44
- """
45
- response = self.model.generate_content([prompt.format(document=input_doc)])
46
- return response.text
47
- elif image:
48
- prompt = """you are an intelligent assistant using the giving image summarize it and its content."""
49
- response = self.model.generate_content([prompt,image])
50
- return response.text
51
-
52
-
53
-
54
-
55
- def book_creator(self,book_name):
56
- prompt = """"Generate a detailed and extensive book titled '{book_title}'.
57
- Please provide the content in HTML format with appropriate tags for headings, paragraphs,
58
- NOTE: The book should be provided in pure "HTML" format without any "Markdown" or other formatting styles and In the html format dont need style tags and title tags
59
- Ensure the HTML is well-structured and valid. Here is the beginning of the book in HTML:\n\n
60
- <html>\n<head>\n<title>'{book_title}'</title>\n</head>\n<body>\n"
61
- <h1>'{book_title}'</h1>\n"
62
- <div>\n"""
63
-
64
- response = self.model.generate_content([prompt.format(book_title=book_name)])
65
- return response.text
66
-
67
- def note_model(self,img):
68
- prompt = """You are an intelligent Notes creator.create a notes using given screenshot
69
- important note: if the screenshot not contain any text means you must say 'please upload a valid screenshot."""
70
-
71
- response = self.model.generate_content([prompt,img])
72
- return response.text
73
-
 
1
+ import google.generativeai as genai
2
+ import os
3
+
4
+
5
+ os.environ["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY")
6
+ genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
7
+
8
+
9
+ class AllModels:
10
+ def __init__(self):
11
+ self.model = genai.GenerativeModel('gemini-1.5-flash-latest')
12
+
13
+
14
+ def road_map_model(self,subjects):
15
+ prompt = f"""Create an HTML format roadmap for learning {subjects} with proving week task . The roadmap should include the following sections:
16
+
17
+ Introduction: Brief overview of the subject and its importance.
18
+
19
+ Foundation: Fundamental concepts and theories to grasp before diving deeper.
20
+
21
+ Intermediate Level: More advanced topics building upon the foundation.
22
+
23
+ Advanced Level: Complex concepts, techniques, or applications within the subject.
24
+
25
+ Resources: List of recommended books, online courses, tutorials, and websites for further learning using hyperlink tag.
26
+
27
+ Projects: Hands-on projects or exercises to reinforce learning and apply knowledge.
28
+
29
+ Conclusion: Summary of key takeaways and encouragement for further exploration.
30
+
31
+ The HTML format should be visually appealing with appropriate headings, subheadings, bullet points, and hyperlinks where necessary. Ensure clarity and logical progression in the roadmap.
32
+ NOTE: The roadmap should be provided in pure HTML format without any Markdown or other formatting styles and In the html format dont need style tags and title tags"""
33
+
34
+ response = self.model.generate_content([prompt.format(subjects=subjects)])
35
+ return response.text
36
+
37
+
38
+ def summary_model(self,input_doc=None,image=None):
39
+ if input_doc:
40
+ prompt = """you are an intelligent assistant using the giving document summarize it shortly
41
+ document:
42
+ {document}
43
+ """
44
+ response = self.model.generate_content([prompt.format(document=input_doc)])
45
+ return response.text
46
+ elif image:
47
+ prompt = """you are an intelligent assistant using the giving image summarize it and its content."""
48
+ response = self.model.generate_content([prompt,image])
49
+ return response.text
50
+
51
+
52
+
53
+
54
+ def book_creator(self,book_name):
55
+ prompt = """"Generate a detailed and extensive book titled '{book_title}'.
56
+ Please provide the content in HTML format with appropriate tags for headings, paragraphs,
57
+ NOTE: The book should be provided in pure "HTML" format without any "Markdown" or other formatting styles and In the html format dont need style tags and title tags
58
+ Ensure the HTML is well-structured and valid. Here is the beginning of the book in HTML:\n\n
59
+ <html>\n<head>\n<title>'{book_title}'</title>\n</head>\n<body>\n"
60
+ <h1>'{book_title}'</h1>\n"
61
+ <div>\n"""
62
+
63
+ response = self.model.generate_content([prompt.format(book_title=book_name)])
64
+ return response.text
65
+
66
+ def note_model(self,img):
67
+ prompt = """You are an intelligent Notes creator.create a notes using given screenshot
68
+ important note: if the screenshot not contain any text means you must say 'please upload a valid screenshot."""
69
+
70
+ response = self.model.generate_content([prompt,img])
71
+ return response.text
72
+