File size: 743 Bytes
6a0aea0
 
c74033b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)