-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno.py
More file actions
66 lines (55 loc) · 2.47 KB
/
no.py
File metadata and controls
66 lines (55 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# To run this code you need to install the following dependencies:
# pip install google-genai
import base64
import os
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key=os.environ.get("GEMINI_API_KEY"),
)
model = "gemini-1.5-flash"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""what is python?"""),
],
),
types.Content(
role="model",
parts=[
types.Part.from_text(text="""Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. It's known for its clear syntax and relatively easy learning curve, making it popular for both beginners and experienced programmers.
Python is used in a wide variety of applications, including:
* **Web development:** Frameworks like Django and Flask make building web applications efficient.
* **Data science and machine learning:** Libraries like NumPy, Pandas, and Scikit-learn provide powerful tools for data analysis and model building.
* **Scripting and automation:** Python is excellent for automating tasks and writing scripts to manage systems.
* **Desktop applications:** Frameworks like Tkinter, PyQt, and Kivy allow the creation of graphical user interfaces (GUIs).
* **Game development:** Libraries like Pygame simplify game development.
* **Embedded systems:** Python is increasingly used in embedded systems due to its lightweight nature (MicroPython).
Essentially, Python's versatility and ease of use have made it one of the most popular and widely used programming languages in the world.
"""),
],
),
types.Content(
role="user",
parts=[
types.Part.from_text(text="""INSERT_INPUT_HERE"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
response_mime_type="text/plain",
system_instruction=[
types.Part.from_text(text="""Python
User can give input as Python related questions, the bot will answer"""),
],
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if __name__ == "__main__":
generate()