-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
51 lines (41 loc) · 1.56 KB
/
client.py
File metadata and controls
51 lines (41 loc) · 1.56 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
import os
from google import genai
from google.genai import types
from dotenv import load_dotenv
load_dotenv(override=True)
def aiProcess(command: str) -> str:
print(os.getenv("GOOGLE_API_KEY")),
client = genai.Client(
api_key=os.getenv("GOOGLE_API_KEY"),
)
model = "gemini-2.5-flash"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text=command),
],
),
]
tools = [
types.Tool(googleSearch=types.GoogleSearch(
)),
]
config = types.GenerateContentConfig(
system_instruction="""
You are a helpful, friendly, and concise voice assistant.
Speak naturally, as if you are talking to a real person on a phone call or smart device.
Keep your answers short and conversational.
Avoid technical jargon unless asked.
If you need more information, ask a follow-up question.
Respond in plain English, and don't mention that you are an AI.
Example tone: “Sure, I can help with that!” or “Okay, give me just a second.”
Always keep the response like real human being unless specifically asked for detail.
""",
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=config,
):
return chunk.text