| from google import genai | |
| from google.genai import types | |
| class Google_Gemini_LLM: | |
| def __init__(self, api_key, model="gemini-1.5-flash"): | |
| self.api_key = api_key | |
| self.model = model | |
| self.client = genai.Client(api_key=api_key) | |
| self.LLM_tools = [] | |
| def generate_content(self, contents): | |
| tools = types.Tool(function_declarations=self.LLM_tools) | |
| config = types.GenerateContentConfig(tools=[tools]) | |
| response = self.client.models.generate_content( | |
| model=self.model, contents=contents, config=config | |
| ) | |
| return response.candidates[0].content.parts[0] | |
| def append_function_tools(self, tools): | |
| for tool in tools: | |
| self.LLM_tools.append(tool) | |